text,length,is_long_context,metric_val,label_metric "class ZCL_IM__GTT_SOF_LE_SHIPMNT definition public final create public . public section. interfaces IF_EX_BADI_LE_SHIPMENT . protected section. private section. ENDCLASS. CLASS ZCL_IM__GTT_SOF_LE_SHIPMNT IMPLEMENTATION. method IF_EX_BADI_LE_SHIPMENT~AT_SAVE. endmethod. METHOD if_ex_badi_le_shipment~before_update. INCLUDE /saptrx/constants. TYPE-POOLS: trxas. DATA: l_structure_package TYPE devclass, l_extflag TYPE flag. DATA: lv_count TYPE i, ls_comwa5 TYPE vbco5, ls_comwa6 TYPE vbco6, lv_fstop TYPE char255, lv_lstop TYPE char255, * Location Id lv_locid TYPE zgtt_locid, lv_appobjid TYPE /saptrx/aoid. DATA: ls_vttk_old TYPE vttkvb, ls_vttk TYPE vttkvb, ls_vttk_tmp TYPE vttk, ls_vtts_old TYPE vttsvb, ls_vtts_delta TYPE vttsvb, ls_vttp_delta TYPE vttpvb, ls_vtsp_delta TYPE vtspvb, ls_likp_delta TYPE likpvb, ls_likp TYPE likp, ls_likp_tmp TYPE likp, ls_vbfas TYPE vbfas, ls_vbfa_new TYPE vbfavb, ls_likp_new TYPE likp, ls_lips TYPE lips, ls_stop TYPE zgtt_stop_info, ls_dlv_watching_stop TYPE zgtt_dlv_watch_stop, ls_eerel TYPE zgtt_sof_ee_rel. DATA: lt_vbfas TYPE STANDARD TABLE OF vbfas, lt_vbfa_new TYPE STANDARD TABLE OF vbfavb, lt_vttk TYPE STANDARD TABLE OF vttkvb, lt_vtts_delta TYPE STANDARD TABLE OF vttsvb, lt_vttp_delta TYPE STANDARD TABLE OF vttpvb, lt_vttp_delta_tmp TYPE STANDARD TABLE OF vttpvb, lt_vtsp_delta TYPE STANDARD TABLE OF vtspvb, lt_vtsp_delta_tmp TYPE STANDARD TABLE OF vtspvb, lt_likp_delta TYPE STANDARD TABLE OF likpvb, lt_likp_new TYPE STANDARD TABLE OF likp, lt_lips TYPE STANDARD TABLE OF lips. DATA: lt_stops_tmp TYPE zgtt_stops, lt_dlv_watching_stops_tmp TYPE zgtt_dlv_watch_stops, lt_stops TYPE zgtt_stops, lt_dlv_watching_stops TYPE zgtt_dlv_watch_stops. DATA: lt_control TYPE /saptrx/bapi_trk_control_tab, lt_tracking_id TYPE /saptrx/bapi_trk_trkid_tab, ls_trxserv TYPE /saptrx/trxserv, lv_appsys TYPE logsys, lt_appobj_ctabs TYPE trxas_appobj_ctabs, lt_bapireturn TYPE bapiret2_t, lv_trxserver_id TYPE /saptrx/trxservername, lv_tzone TYPE timezone, lt_exp_events TYPE /saptrx/bapi_trk_ee_tab. DATA: ls_control TYPE LINE OF /saptrx/bapi_trk_control_tab, ls_tracking_id TYPE LINE OF /saptrx/bapi_trk_trkid_tab, ls_appobj_ctabs TYPE LINE OF trxas_appobj_ctabs, ls_expeventdata TYPE LINE OF /saptrx/bapi_trk_ee_tab. DATA: BEGIN OF ls_aotype, obj_type TYPE /saptrx/trk_obj_type, aot_type TYPE /saptrx/aotype, END OF ls_aotype. DATA: lt_aotype LIKE STANDARD TABLE OF ls_aotype, lt_aotype_item LIKE STANDARD TABLE OF ls_aotype. * Check package dependent BADI disabling l_structure_package = '/SAPTRX/SCEM_AI_R3'. CALL FUNCTION 'GET_R3_EXTENSION_SWITCH' EXPORTING i_structure_package = l_structure_package IMPORTING e_active = l_extflag EXCEPTIONS not_existing = 1 object_not_existing = 2 no_extension_object = 3 OTHERS = 4. IF sy-subrc <> 0. EXIT. ENDIF. IF l_extflag <> 'X'. EXIT. ENDIF. * Check if any tracking server defined CHECK im_shipments_before_update-tra_save_caller <> 'TRX'. CALL FUNCTION '/SAPTRX/EVENT_MGR_CHECK' EXCEPTIONS no_event_mgr_available = 1. IF sy-subrc <> 0. EXIT. ENDIF. * Check if at least 1 active extractor exists SELECT COUNT(*) INTO lv_count FROM /saptrx/aotypes WHERE trk_obj_type EQ 'ESC_SHIPMT' AND torelevant EQ 'X'. CHECK lv_count GE 1. CLEAR lv_count. SELECT COUNT(*) INTO lv_count FROM /saptrx/aotypes WHERE trk_obj_type EQ 'ESC_DELIV' AND torelevant EQ 'X'. CHECK lv_count GE 1. * GET CURRENT LOGICAL SYSTEM CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET' IMPORTING own_logical_system = lv_appsys. * Actual Business Time zone CALL FUNCTION 'GET_SYSTEM_TIMEZONE' IMPORTING timezone = lv_tzone EXCEPTIONS customizing_missing = 1 OTHERS = 2. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_INT_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_AZ_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_IF_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_PF_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_PR_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_PT_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_DM_HD'. APPEND ls_aotype TO lt_aotype. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_ITEM'. APPEND ls_aotype TO lt_aotype_item. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_INT_ITEM'. APPEND ls_aotype TO lt_aotype_item. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_AZ_ITEM'. APPEND ls_aotype TO lt_aotype_item. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_IF_ITEM'. APPEND ls_aotype TO lt_aotype_item. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_PF_ITEM'. APPEND ls_aotype TO lt_aotype_item. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_PR_ITEM'. APPEND ls_aotype TO lt_aotype_item. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_PT_ITEM'. APPEND ls_aotype TO lt_aotype_item. ls_aotype-obj_type = 'ESC_DELIV'. ls_aotype-aot_type = 'ZGTT_DE_ACC_DM_ITEM'. APPEND ls_aotype TO lt_aotype_item. * get the shipment header MOVE im_shipments_before_update-new_vttk TO lt_vttk. LOOP AT im_shipments_before_update-old_vttk INTO ls_vttk_old WHERE updkz = 'D'. APPEND ls_vttk_old TO lt_vttk. ENDLOOP. LOOP AT lt_vttk INTO ls_vttk WHERE shtyp EQ '0003'. CLEAR: lt_vttp_delta, lt_likp_delta, lt_vttp_delta_tmp, lt_vtsp_delta, lt_vtsp_delta_tmp, lt_vtts_delta. MOVE im_shipments_before_update-new_vttp TO lt_vttp_delta. APPEND LINES OF im_shipments_before_update-old_vttp TO lt_vttp_delta. MOVE lt_vttp_delta TO lt_vttp_delta_tmp. DELETE lt_vttp_delta WHERE ( updkz NE 'I' AND updkz NE 'D' ) OR tknum NE ls_vttk-tknum. IF lt_vttp_delta IS NOT INITIAL. LOOP AT lt_vttp_delta INTO ls_vttp_delta. MOVE ls_vttp_delta-vbeln TO ls_likp_delta-vbeln. COLLECT ls_likp_delta INTO lt_likp_delta. ENDLOOP. ENDIF. MOVE im_shipments_before_update-new_vtsp TO lt_vtsp_delta. APPEND LINES OF im_shipments_before_update-old_vtsp TO lt_vtsp_delta. MOVE lt_vtsp_delta TO lt_vtsp_delta_tmp. DELETE lt_vtsp_delta WHERE ( updkz NE 'I' AND updkz NE 'D' ) OR tknum NE ls_vttk-tknum. IF lt_vtsp_delta IS NOT INITIAL. LOOP AT lt_vtsp_delta INTO ls_vtsp_delta. READ TABLE lt_vttp_delta_tmp INTO ls_vttp_delta WITH KEY tknum = ls_vtsp_delta-tknum tpnum = ls_vtsp_delta-tpnum BINARY SEARCH. IF sy-subrc EQ 0. MOVE ls_vttp_delta-vbeln TO ls_likp_delta-vbeln. COLLECT ls_likp_delta INTO lt_likp_delta. ENDIF. ENDLOOP. ENDIF. MOVE im_shipments_before_update-new_vtts TO lt_vtts_delta. APPEND LINES OF im_shipments_before_update-old_vtts TO lt_vtts_delta. DELETE lt_vtts_delta WHERE tknum NE ls_vttk-tknum. IF lt_vtts_delta IS NOT INITIAL. LOOP AT lt_vtts_delta INTO ls_vtts_delta WHERE updkz = 'I' OR updkz = 'D'. CLEAR: ls_vtsp_delta, ls_vttp_delta. LOOP AT lt_vtsp_delta_tmp INTO ls_vtsp_delta WHERE tknum = ls_vtts_delta-tknum AND tsnum = ls_vtts_delta-tsnum. READ TABLE lt_vttp_delta_tmp INTO ls_vttp_delta WITH KEY tknum = ls_vtsp_delta-tknum tpnum = ls_vtsp_delta-tpnum BINARY SEARCH. IF sy-subrc EQ 0. MOVE ls_vttp_delta-vbeln TO ls_likp_delta-vbeln. COLLECT ls_likp_delta INTO lt_likp_delta. ENDIF. ENDLOOP. ENDLOOP. LOOP AT lt_vtts_delta INTO ls_vtts_delta WHERE updkz <> 'I' AND updkz <> 'D'. READ TABLE im_shipments_before_update-old_vtts INTO ls_vtts_old WITH KEY tknum = ls_vtts_delta-tknum tsnum = ls_vtts_delta-tsnum BINARY SEARCH. CHECK sy-subrc IS INITIAL. IF ls_vtts_delta-knota NE ls_vtts_old-knota OR ls_vtts_delta-vstel NE ls_vtts_old-vstel OR ls_vtts_delta-werka NE ls_vtts_old-werka OR ls_vtts_delta-kunna NE ls_vtts_old-kunna OR ls_vtts_delta-lifna NE ls_vtts_old-lifna OR ls_vtts_delta-kunnz NE ls_vtts_old-kunnz OR ls_vtts_delta-vstez NE ls_vtts_old-vstez OR ls_vtts_delta-lifnz NE ls_vtts_old-lifnz OR ls_vtts_delta-werkz NE ls_vtts_old-werkz OR ls_vtts_delta-knotz NE ls_vtts_old-knotz OR ls_vtts_delta-dptbg NE ls_vtts_old-dptbg OR ls_vtts_delta-uptbg NE ls_vtts_old-uptbg OR ls_vtts_delta-dpten NE ls_vtts_old-dpten OR ls_vtts_delta-upten NE ls_vtts_old-upten. . CLEAR: ls_vtsp_delta, ls_vttp_delta. LOOP AT lt_vtsp_delta_tmp INTO ls_vtsp_delta WHERE tknum = ls_vtts_delta-tknum AND tsnum = ls_vtts_delta-tsnum. READ TABLE lt_vttp_delta_tmp INTO ls_vttp_delta WITH KEY tknum = ls_vtsp_delta-tknum tpnum = ls_vtsp_delta-tpnum BINARY SEARCH. IF sy-subrc EQ 0. MOVE ls_vttp_delta-vbeln TO ls_likp_delta-vbeln. COLLECT ls_likp_delta INTO lt_likp_delta. ENDIF. ENDLOOP. ENDIF. ENDLOOP. ENDIF. CLEAR: lt_vbfa_new, lt_likp_new. LOOP AT lt_likp_delta INTO ls_likp_delta. CLEAR: ls_comwa6, lt_vbfas. MOVE-CORRESPONDING ls_likp_delta TO ls_comwa6. CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION' EXPORTING comwa = ls_comwa6 TABLES vbfa_tab = lt_vbfas. LOOP AT lt_vbfas INTO ls_vbfas WHERE vbtyp_n EQ '8' AND vbtyp_v EQ 'J'. SELECT SINGLE * INTO ls_likp FROM likp WHERE vbeln = ls_vbfas-vbelv AND lfart = 'LBNP'. CHECK sy-subrc EQ 0. SELECT SINGLE * INTO ls_vttk_tmp FROM vttk WHERE tknum = ls_vbfas-vbeln AND shtyp EQ '0003'. CHECK sy-subrc EQ 0. MOVE-CORRESPONDING ls_vbfas TO ls_vbfa_new. APPEND ls_vbfa_new TO lt_vbfa_new. ENDLOOP. SELECT SINGLE * INTO ls_likp FROM likp WHERE vbeln = ls_likp_delta-vbeln AND lfart = 'LBNP'. IF sy-subrc = 0. COLLECT ls_likp INTO lt_likp_new. ENDIF. ENDLOOP. LOOP AT lt_vttp_delta INTO ls_vttp_delta WHERE updkz = 'D'. DELETE lt_vbfa_new WHERE vbeln = ls_vttp_delta-tknum AND vbelv = ls_vttp_delta-vbeln. ENDLOOP. LOOP AT lt_vttp_delta INTO ls_vttp_delta WHERE updkz = 'I'. READ TABLE lt_vbfa_new WITH KEY vbeln = ls_vttp_delta-tknum vbelv = ls_vttp_delta-vbeln TRANSPORTING NO FIELDS. IF sy-subrc NE 0. SELECT SINGLE * INTO ls_likp FROM likp WHERE vbeln = ls_vttp_delta-vbeln AND lfart = 'LBNP'. CHECK sy-subrc EQ 0. CLEAR ls_vbfa_new. ls_vbfa_new-vbelv = ls_vttp_delta-vbeln. ls_vbfa_new-vbeln = ls_vttp_delta-tknum. COLLECT ls_vbfa_new INTO lt_vbfa_new. ENDIF. ENDLOOP. CHECK lt_likp_new IS NOT INITIAL. CLEAR: lt_stops, lt_dlv_watching_stops. LOOP AT lt_vbfa_new INTO ls_vbfa_new. CLEAR: lt_stops_tmp, lt_dlv_watching_stops_tmp. IF ls_vbfa_new-vbeln = ls_vttk-tknum. CALL FUNCTION 'ZGTT_GET_STOPS_FROM_SHIPMENT' EXPORTING iv_tknum = ls_vttk-tknum it_vtts_new = im_shipments_before_update-new_vtts it_vtsp_new = im_shipments_before_update-new_vtsp it_vttp_new = im_shipments_before_update-new_vttp IMPORTING et_stops = lt_stops_tmp et_dlv_watching_stops = lt_dlv_watching_stops_tmp. ELSE. CALL FUNCTION 'ZGTT_GET_STOPS_FROM_SHIPMENT' EXPORTING iv_tknum = ls_vbfa_new-vbeln IMPORTING et_stops = lt_stops_tmp et_dlv_watching_stops = lt_dlv_watching_stops_tmp. ENDIF. APPEND LINES OF lt_stops_tmp TO lt_stops. APPEND LINES OF lt_dlv_watching_stops_tmp TO lt_dlv_watching_stops. ENDLOOP. SORT lt_stops BY stopid loccat. SORT lt_dlv_watching_stops BY vbeln stopid loccat. DELETE ADJACENT DUPLICATES FROM lt_stops COMPARING stopid loccat. DELETE ADJACENT DUPLICATES FROM lt_dlv_watching_stops COMPARING vbeln stopid loccat. * *************************************************************COMPOSE IDOC-> LOOP AT lt_aotype INTO ls_aotype. SELECT SINGLE trxservername INTO lv_trxserver_id FROM /saptrx/aotypes WHERE trk_obj_type EQ ls_aotype-obj_type AND aotype EQ ls_aotype-aot_type. SELECT SINGLE trx_server_id trx_server INTO ( ls_trxserv-trx_server_id, ls_trxserv-trx_server ) FROM /saptrx/trxserv WHERE trx_server_id = lv_trxserver_id. CLEAR: lt_appobj_ctabs, lt_control, lt_tracking_id, lt_exp_events. LOOP AT lt_likp_new INTO ls_likp_new. CLEAR: ls_appobj_ctabs. ls_appobj_ctabs-trxservername = ls_trxserv-trx_server_id. ls_appobj_ctabs-appobjtype = ls_aotype-aot_type. ls_appobj_ctabs-appobjid = ls_likp_new-vbeln. APPEND ls_appobj_ctabs TO lt_appobj_ctabs. * update the impacted deliveries' shipment composition and tracking id table=> CLEAR: ls_control. ls_control-appsys = lv_appsys. ls_control-appobjtype = ls_aotype-aot_type. ls_control-appobjid = ls_likp_new-vbeln. ls_control-paramname = 'YN_DLV_NO'. ls_control-value = ls_likp_new-vbeln. APPEND ls_control TO lt_control. ls_control-paramname = 'ACTUAL_BUSINESS_TIMEZONE'. ls_control-value = lv_tzone. APPEND ls_control TO lt_control. ls_control-paramname = 'ACTUAL_BUSINESS_DATETIME'. CONCATENATE '0' sy-datum sy-uzeit INTO ls_control-value. APPEND ls_control TO lt_control. CLEAR: lv_count. LOOP AT lt_vbfa_new INTO ls_vbfa_new WHERE vbelv = ls_likp_new-vbeln. lv_count = lv_count + 1. ls_control-paramname = 'YN_SHP_LINE_COUNT'. ls_control-paramindex = lv_count. ls_control-value = lv_count. SHIFT ls_control-value LEFT DELETING LEADING space. APPEND ls_control TO lt_control. ls_control-paramname = 'YN_SHP_NO'. ls_control-paramindex = lv_count. ls_control-value = ls_vbfa_new-vbeln. APPEND ls_control TO lt_control. CLEAR: lv_fstop, lv_lstop. LOOP AT lt_dlv_watching_stops INTO ls_dlv_watching_stop WHERE vbeln = ls_vbfa_new-vbelv AND stopid(10) = ls_vbfa_new-vbeln. IF lv_fstop IS INITIAL. lv_fstop = ls_dlv_watching_stop-stopid. ENDIF. lv_lstop = ls_dlv_watching_stop-stopid. ENDLOOP. ls_control-paramname = 'YN_SHP_FIRST_STOP'. ls_control-paramindex = lv_count. ls_control-value = lv_fstop. APPEND ls_control TO lt_control. ls_control-paramname = 'YN_SHP_LAST_STOP'. ls_control-paramindex = lv_count. ls_control-value = lv_lstop. APPEND ls_control TO lt_control. ENDLOOP. IF sy-subrc NE 0. ls_control-paramname = 'YN_SHP_LINE_COUNT'. ls_control-paramindex = '1'. ls_control-value = ''. APPEND ls_control TO lt_control. ENDIF. CLEAR: ls_tracking_id. ls_tracking_id-appsys = lv_appsys. ls_tracking_id-appobjtype = ls_aotype-aot_type. ls_tracking_id-appobjid = ls_likp_new-vbeln. ls_tracking_id-trxcod = 'OUTBOUND_DELIVERY'. ls_tracking_id-trxid = ls_likp_new-vbeln. CONCATENATE '0' sy-datum sy-uzeit INTO ls_tracking_id-start_date. ls_tracking_id-end_date = '099991231000000'. ls_tracking_id-timzon = lv_tzone. APPEND ls_tracking_id TO lt_tracking_id. CLEAR ls_tracking_id-start_date. CLEAR ls_tracking_id-end_date. CLEAR ls_tracking_id-timzon. LOOP AT lt_vttp_delta INTO ls_vttp_delta WHERE vbeln = ls_likp_new-vbeln. CLEAR ls_tracking_id-action. ls_tracking_id-trxcod = 'SHIPMENT_ORDER'. ls_tracking_id-trxid = ls_vttp_delta-tknum. IF ls_vttp_delta-updkz = 'D'. ls_tracking_id-action = 'D'. ENDIF. APPEND ls_tracking_id TO lt_tracking_id. ENDLOOP. * update the impacted deliveries' shipment composition and tracking id table=< * update the impacted deliveries' planned event table=> CLEAR ls_expeventdata. ls_expeventdata-appsys = lv_appsys. ls_expeventdata-appobjtype = ls_aotype-aot_type. ls_expeventdata-language = sy-langu. ls_expeventdata-appobjid = ls_likp_new-vbeln. ls_expeventdata-evt_exp_tzone = lv_tzone. CLEAR ls_eerel. SELECT SINGLE * INTO ls_eerel FROM zgtt_sof_ee_rel WHERE appobjid = ls_expeventdata-appobjid. IF ls_eerel-z_wbstk = 'X'. ls_expeventdata-milestone = 'GOODS_ISSUE'. IF ls_likp_new-wadat IS INITIAL. CLEAR ls_expeventdata-evt_exp_datetime. ELSE. CONCATENATE '0' ls_likp_new-wadat ls_likp_new-wauhr INTO ls_expeventdata-evt_exp_datetime. ENDIF. ls_expeventdata-loctype = 'ShippingPoint'. ls_expeventdata-locid1 = ls_likp_new-vstel. ls_expeventdata-locid2 = ''. APPEND ls_expeventdata TO lt_exp_events. ENDIF. ls_expeventdata-milestone = 'DEPARTURE'. LOOP AT lt_dlv_watching_stops INTO ls_dlv_watching_stop WHERE vbeln = ls_likp_new-vbeln AND loccat = 'S'. READ TABLE lt_stops INTO ls_stop WITH KEY stopid = ls_dlv_watching_stop-stopid loccat = ls_dlv_watching_stop-loccat. ls_expeventdata-locid2 = ls_stop-stopid. ls_expeventdata-loctype = ls_stop-loctype. ls_expeventdata-locid1 = ls_stop-locid. ls_expeventdata-evt_exp_datetime = ls_stop-pln_evt_datetime. ls_expeventdata-evt_exp_tzone = ls_stop-pln_evt_timezone. APPEND ls_expeventdata TO lt_exp_events. ENDLOOP. ls_expeventdata-milestone = 'ARRIV_DEST'. LOOP AT lt_dlv_watching_stops INTO ls_dlv_watching_stop WHERE vbeln = ls_likp_new-vbeln AND loccat = 'D'. READ TABLE lt_stops INTO ls_stop WITH KEY stopid = ls_dlv_watching_stop-stopid loccat = ls_dlv_watching_stop-loccat. ls_expeventdata-locid2 = ls_stop-stopid. ls_expeventdata-loctype = ls_stop-loctype. ls_expeventdata-locid1 = ls_stop-locid. ls_expeventdata-evt_exp_datetime = ls_stop-pln_evt_datetime. ls_expeventdata-evt_exp_tzone = ls_stop-pln_evt_timezone. APPEND ls_expeventdata TO lt_exp_events. ENDLOOP. ls_expeventdata-milestone = 'POD'. LOOP AT lt_dlv_watching_stops INTO ls_dlv_watching_stop WHERE vbeln = ls_likp_new-vbeln AND loccat = 'D'. READ TABLE lt_stops INTO ls_stop WITH KEY stopid = ls_dlv_watching_stop-stopid loccat = ls_dlv_watching_stop-loccat. CLEAR: lv_locid. SELECT SINGLE kunnr INTO lv_locid FROM likp WHERE vbeln = ls_likp_new-vbeln. IF lv_locid EQ ls_stop-locid AND ls_eerel-z_pdstk = 'X'. ls_expeventdata-locid2 = ls_stop-stopid. ls_expeventdata-loctype = ls_stop-loctype. ls_expeventdata-locid1 = ls_stop-locid. ls_expeventdata-evt_exp_datetime = ls_stop-pln_evt_datetime. ls_expeventdata-evt_exp_tzone = ls_stop-pln_evt_timezone. APPEND ls_expeventdata TO lt_exp_events. ENDIF. ENDLOOP. READ TABLE lt_exp_events WITH KEY appobjid = ls_likp_new-vbeln TRANSPORTING NO FIELDS. IF sy-subrc NE 0. ls_expeventdata-evt_exp_datetime = '000000000000000'. ls_expeventdata-milestone = ''. ls_expeventdata-evt_exp_tzone = ''. ls_expeventdata-loctype = ''. ls_expeventdata-locid1 = ''. ls_expeventdata-locid2 = ''. APPEND ls_expeventdata TO lt_exp_events. ENDIF. * update the impacted deliveries' planned event table=< ENDLOOP. IF lt_control IS NOT INITIAL. CALL METHOD zcl_gtt_sof_upd_xtp_references=>send_idoc_ehpost01 EXPORTING it_control = lt_control it_tracking_id = lt_tracking_id it_exp_event = lt_exp_events is_trxserv = ls_trxserv iv_appsys = lv_appsys it_appobj_ctabs = lt_appobj_ctabs. ENDIF. ENDLOOP. * update the impacted delivery items' planned event table=> CLEAR lt_lips. IF lt_likp_new IS NOT INITIAL. SELECT * INTO TABLE lt_lips FROM lips FOR ALL ENTRIES IN lt_likp_new WHERE vbeln = lt_likp_new-vbeln. ENDIF. LOOP AT lt_aotype_item INTO ls_aotype. SELECT SINGLE trxservername INTO lv_trxserver_id FROM /saptrx/aotypes WHERE trk_obj_type EQ ls_aotype-obj_type AND aotype EQ ls_aotype-aot_type. SELECT SINGLE trx_server_id trx_server INTO ( ls_trxserv-trx_server_id, ls_trxserv-trx_server ) FROM /saptrx/trxserv WHERE trx_server_id = lv_trxserver_id. CLEAR: lt_appobj_ctabs, lt_control, lt_tracking_id, lt_exp_events. LOOP AT lt_lips INTO ls_lips. CLEAR: ls_appobj_ctabs. ls_appobj_ctabs-trxservername = ls_trxserv-trx_server_id. ls_appobj_ctabs-appobjtype = ls_aotype-aot_type. CONCATENATE ls_lips-vbeln ls_lips-posnr INTO ls_appobj_ctabs-appobjid. APPEND ls_appobj_ctabs TO lt_appobj_ctabs. CLEAR: ls_control. ls_control-appsys = lv_appsys. ls_control-appobjtype = ls_aotype-aot_type. CONCATENATE ls_lips-vbeln ls_lips-posnr INTO ls_control-appobjid. ls_control-paramname = 'YN_DLV_NO'. ls_control-value = ls_lips-vbeln. APPEND ls_control TO lt_control. ls_control-paramname = 'YN_DLV_ITEM_NO'. ls_control-value = ls_lips-posnr. APPEND ls_control TO lt_control. ls_control-paramname = 'ACTUAL_BUSINESS_TIMEZONE'. ls_control-value = lv_tzone. APPEND ls_control TO lt_control. ls_control-paramname = 'ACTUAL_BUSINESS_DATETIME'. CONCATENATE '0' sy-datum sy-uzeit INTO ls_control-value. APPEND ls_control TO lt_control. CLEAR: ls_tracking_id. ls_tracking_id-appsys = lv_appsys. ls_tracking_id-appobjtype = ls_aotype-aot_type. CONCATENATE ls_lips-vbeln ls_lips-posnr INTO ls_tracking_id-appobjid. ls_tracking_id-trxcod = 'OUTBOUND_DELIVERY_IT'. CONCATENATE ls_lips-vbeln ls_lips-posnr INTO ls_tracking_id-trxid. CONCATENATE '0' sy-datum sy-uzeit INTO ls_tracking_id-start_date. ls_tracking_id-end_date = '099991231000000'. ls_tracking_id-timzon = lv_tzone. APPEND ls_tracking_id TO lt_tracking_id. CLEAR ls_expeventdata. ls_expeventdata-appsys = lv_appsys. ls_expeventdata-appobjtype = ls_aotype-aot_type. ls_expeventdata-language = sy-langu. CONCATENATE ls_lips-vbeln ls_lips-posnr INTO ls_expeventdata-appobjid. ls_expeventdata-evt_exp_tzone = lv_tzone. SELECT SINGLE * INTO ls_likp_tmp FROM likp WHERE vbeln = ls_lips-vbeln. CLEAR ls_eerel. SELECT SINGLE * INTO ls_eerel FROM zgtt_sof_ee_rel WHERE appobjid = ls_expeventdata-appobjid. IF ls_eerel-z_kostk = 'X'. ls_expeventdata-milestone = 'PICKING'. IF ls_likp_tmp-kodat IS INITIAL. CLEAR ls_expeventdata-evt_exp_datetime. ELSE. CONCATENATE '0' ls_likp_tmp-kodat ls_likp_tmp-kouhr INTO ls_expeventdata-evt_exp_datetime. ENDIF. ls_expeventdata-loctype = 'ShippingPoint'. ls_expeventdata-locid1 = ls_likp_tmp-vstel. ls_expeventdata-locid2 = ''. APPEND ls_expeventdata TO lt_exp_events. ENDIF. IF ls_eerel-z_pkstk = 'X'. CLEAR ls_expeventdata-evt_exp_datetime. ls_expeventdata-milestone = 'PACKING'. ls_expeventdata-loctype = 'ShippingPoint'. ls_expeventdata-locid1 = ls_likp_tmp-vstel. ls_expeventdata-locid2 = ''. APPEND ls_expeventdata TO lt_exp_events. ENDIF. IF ls_eerel-z_wbstk = 'X'. ls_expeventdata-milestone = 'GOODS_ISSUE'. IF ls_likp_tmp-wadat IS INITIAL. CLEAR ls_expeventdata-evt_exp_datetime. ELSE. CONCATENATE '0' ls_likp_tmp-wadat ls_likp_tmp-wauhr INTO ls_expeventdata-evt_exp_datetime. ENDIF. ls_expeventdata-loctype = 'ShippingPoint'. ls_expeventdata-locid1 = ls_likp_tmp-vstel. ls_expeventdata-locid2 = ''. APPEND ls_expeventdata TO lt_exp_events. ENDIF. IF ls_eerel-z_pdstk = 'X'. CLEAR ls_expeventdata-evt_exp_datetime. ls_expeventdata-milestone = 'POD'. ls_expeventdata-loctype = 'Customer'. ls_expeventdata-locid1 = ls_likp_tmp-kunnr. ls_expeventdata-locid2 = ''. APPEND ls_expeventdata TO lt_exp_events. ENDIF. ls_expeventdata-milestone = 'DEPARTURE'. LOOP AT lt_dlv_watching_stops INTO ls_dlv_watching_stop WHERE vbeln = ls_lips-vbeln AND loccat = 'S'. READ TABLE lt_stops INTO ls_stop WITH KEY stopid = ls_dlv_watching_stop-stopid loccat = ls_dlv_watching_stop-loccat. ls_expeventdata-locid2 = ls_stop-stopid. ls_expeventdata-loctype = ls_stop-loctype. ls_expeventdata-locid1 = ls_stop-locid. ls_expeventdata-evt_exp_datetime = ls_stop-pln_evt_datetime. ls_expeventdata-evt_exp_tzone = ls_stop-pln_evt_timezone. APPEND ls_expeventdata TO lt_exp_events. ENDLOOP. ls_expeventdata-milestone = 'ARRIV_DEST'. LOOP AT lt_dlv_watching_stops INTO ls_dlv_watching_stop WHERE vbeln = ls_lips-vbeln AND loccat = 'D'. READ TABLE lt_stops INTO ls_stop WITH KEY stopid = ls_dlv_watching_stop-stopid loccat = ls_dlv_watching_stop-loccat. ls_expeventdata-locid2 = ls_stop-stopid. ls_expeventdata-loctype = ls_stop-loctype. ls_expeventdata-locid1 = ls_stop-locid. ls_expeventdata-evt_exp_datetime = ls_stop-pln_evt_datetime. ls_expeventdata-evt_exp_tzone = ls_stop-pln_evt_timezone. APPEND ls_expeventdata TO lt_exp_events. ENDLOOP. ls_expeventdata-milestone = 'POD'. LOOP AT lt_dlv_watching_stops INTO ls_dlv_watching_stop WHERE vbeln = ls_lips-vbeln AND loccat = 'D'. READ TABLE lt_stops INTO ls_stop WITH KEY stopid = ls_dlv_watching_stop-stopid loccat = ls_dlv_watching_stop-loccat. CLEAR: lv_locid. SELECT SINGLE kunnr INTO lv_locid FROM likp WHERE vbeln = ls_lips-vbeln. IF lv_locid EQ ls_stop-locid AND ls_eerel-z_pdstk = 'X'. ls_expeventdata-locid2 = ls_stop-stopid. ls_expeventdata-loctype = ls_stop-loctype. ls_expeventdata-locid1 = ls_stop-locid. ls_expeventdata-evt_exp_datetime = ls_stop-pln_evt_datetime. ls_expeventdata-evt_exp_tzone = ls_stop-pln_evt_timezone. APPEND ls_expeventdata TO lt_exp_events. ENDIF. ENDLOOP. CONCATENATE ls_lips-vbeln ls_lips-posnr INTO lv_appobjid. READ TABLE lt_exp_events WITH KEY appobjid = lv_appobjid TRANSPORTING NO FIELDS. IF sy-subrc NE 0. ls_expeventdata-evt_exp_datetime = '000000000000000'. ls_expeventdata-milestone = ''. ls_expeventdata-evt_exp_tzone = ''. ls_expeventdata-loctype = ''. ls_expeventdata-locid1 = ''. ls_expeventdata-locid2 = ''. APPEND ls_expeventdata TO lt_exp_events. ENDIF. ENDLOOP. IF lt_control IS NOT INITIAL. CALL METHOD zcl_gtt_sof_upd_xtp_references=>send_idoc_ehpost01 EXPORTING it_control = lt_control it_tracking_id = lt_tracking_id it_exp_event = lt_exp_events is_trxserv = ls_trxserv iv_appsys = lv_appsys it_appobj_ctabs = lt_appobj_ctabs. ENDIF. ENDLOOP. * update the impacted delivery items' planned event table=< ENDLOOP. ENDMETHOD. method IF_EX_BADI_LE_SHIPMENT~IN_UPDATE. endmethod. ENDCLASS. ",8745,False,1793.1138961136685,median "class ZCL_ZEWM_ROBCO_DPC definition public inheriting from /IWBEP/CL_MGW_PUSH_ABS_DATA abstract create public . public section. interfaces /IWBEP/IF_SB_DPC_COMM_SERVICES . interfaces /IWBEP/IF_SB_GEN_DPC_INJECTION . methods /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET redefinition . methods /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY redefinition . methods /IWBEP/IF_MGW_APPL_SRV_RUNTIME~UPDATE_ENTITY redefinition . methods /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_ENTITY redefinition . methods /IWBEP/IF_MGW_APPL_SRV_RUNTIME~DELETE_ENTITY redefinition . protected section. data mo_injection type ref to /IWBEP/IF_SB_GEN_DPC_INJECTION . methods WAREHOUSEORDERSE_UPDATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_U optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSEORDER raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEORDERSE_GET_ENTITYSET importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_FILTER_SELECT_OPTIONS type /IWBEP/T_MGW_SELECT_OPTION !IS_PAGING type /IWBEP/S_MGW_PAGING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IT_ORDER type /IWBEP/T_MGW_SORTING_ORDER !IV_FILTER_STRING type STRING !IV_SEARCH_STRING type STRING !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITYSET optional exporting !ET_ENTITYSET type ZCL_ZEWM_ROBCO_MPC=>TT_WAREHOUSEORDER !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_CONTEXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEORDERSE_GET_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_REQUEST_OBJECT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSEORDER !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_ENTITY_CNTXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEORDERSE_DELETE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_D optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEORDERSE_CREATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_C optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSEORDER raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSENUMBERS_UPDATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_U optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSENUMBER raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSENUMBERS_GET_ENTITYSET importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_FILTER_SELECT_OPTIONS type /IWBEP/T_MGW_SELECT_OPTION !IS_PAGING type /IWBEP/S_MGW_PAGING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IT_ORDER type /IWBEP/T_MGW_SORTING_ORDER !IV_FILTER_STRING type STRING !IV_SEARCH_STRING type STRING !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITYSET optional exporting !ET_ENTITYSET type ZCL_ZEWM_ROBCO_MPC=>TT_WAREHOUSENUMBER !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_CONTEXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSENUMBERS_GET_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_REQUEST_OBJECT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSENUMBER !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_ENTITY_CNTXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSENUMBERS_DELETE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_D optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSENUMBERS_CREATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_C optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSENUMBER raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEDESCRIP_UPDATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_U optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSEDESCRIPTION raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEDESCRIP_GET_ENTITYSET importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_FILTER_SELECT_OPTIONS type /IWBEP/T_MGW_SELECT_OPTION !IS_PAGING type /IWBEP/S_MGW_PAGING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IT_ORDER type /IWBEP/T_MGW_SORTING_ORDER !IV_FILTER_STRING type STRING !IV_SEARCH_STRING type STRING !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITYSET optional exporting !ET_ENTITYSET type ZCL_ZEWM_ROBCO_MPC=>TT_WAREHOUSEDESCRIPTION !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_CONTEXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEDESCRIP_GET_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_REQUEST_OBJECT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSEDESCRIPTION !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_ENTITY_CNTXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEDESCRIP_DELETE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_D optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods WAREHOUSEDESCRIP_CREATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_C optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_WAREHOUSEDESCRIPTION raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods STORAGEBINSET_UPDATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_U optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_STORAGEBIN raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods STORAGEBINSET_GET_ENTITYSET importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_FILTER_SELECT_OPTIONS type /IWBEP/T_MGW_SELECT_OPTION !IS_PAGING type /IWBEP/S_MGW_PAGING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IT_ORDER type /IWBEP/T_MGW_SORTING_ORDER !IV_FILTER_STRING type STRING !IV_SEARCH_STRING type STRING !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITYSET optional exporting !ET_ENTITYSET type ZCL_ZEWM_ROBCO_MPC=>TT_STORAGEBIN !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_CONTEXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods STORAGEBINSET_GET_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_REQUEST_OBJECT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_STORAGEBIN !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_ENTITY_CNTXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods STORAGEBINSET_DELETE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_D optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods STORAGEBINSET_CREATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_C optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_STORAGEBIN raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods ROBOTSET_UPDATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_U optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_ROBOT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods ROBOTSET_GET_ENTITYSET importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_FILTER_SELECT_OPTIONS type /IWBEP/T_MGW_SELECT_OPTION !IS_PAGING type /IWBEP/S_MGW_PAGING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IT_ORDER type /IWBEP/T_MGW_SORTING_ORDER !IV_FILTER_STRING type STRING !IV_SEARCH_STRING type STRING !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITYSET optional exporting !ET_ENTITYSET type ZCL_ZEWM_ROBCO_MPC=>TT_ROBOT !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_CONTEXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods ROBOTSET_GET_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_REQUEST_OBJECT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_ROBOT !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_ENTITY_CNTXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods ROBOTSET_DELETE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_D optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods ROBOTSET_CREATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_C optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_ROBOT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods OPENWAREHOUSETAS_UPDATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_U optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_OPENWAREHOUSETASK raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods OPENWAREHOUSETAS_GET_ENTITYSET importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_FILTER_SELECT_OPTIONS type /IWBEP/T_MGW_SELECT_OPTION !IS_PAGING type /IWBEP/S_MGW_PAGING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IT_ORDER type /IWBEP/T_MGW_SORTING_ORDER !IV_FILTER_STRING type STRING !IV_SEARCH_STRING type STRING !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITYSET optional exporting !ET_ENTITYSET type ZCL_ZEWM_ROBCO_MPC=>TT_OPENWAREHOUSETASK !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_CONTEXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods OPENWAREHOUSETAS_GET_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_REQUEST_OBJECT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_OPENWAREHOUSETASK !ES_RESPONSE_CONTEXT type /IWBEP/IF_MGW_APPL_SRV_RUNTIME=>TY_S_MGW_RESPONSE_ENTITY_CNTXT raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods OPENWAREHOUSETAS_DELETE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_D optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods OPENWAREHOUSETAS_CREATE_ENTITY importing !IV_ENTITY_NAME type STRING !IV_ENTITY_SET_NAME type STRING !IV_SOURCE_NAME type STRING !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR !IO_TECH_REQUEST_CONTEXT type ref to /IWBEP/IF_MGW_REQ_ENTITY_C optional !IT_NAVIGATION_PATH type /IWBEP/T_MGW_NAVIGATION_PATH !IO_DATA_PROVIDER type ref to /IWBEP/IF_MGW_ENTRY_PROVIDER optional exporting !ER_ENTITY type ZCL_ZEWM_ROBCO_MPC=>TS_OPENWAREHOUSETASK raising /IWBEP/CX_MGW_BUSI_EXCEPTION /IWBEP/CX_MGW_TECH_EXCEPTION . methods CHECK_SUBSCRIPTION_AUTHORITY redefinition . private section. ENDCLASS. CLASS ZCL_ZEWM_ROBCO_DPC IMPLEMENTATION. method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_ENTITY. *&----------------------------------------------------------------------------------------------* *& Include /IWBEP/DPC_TEMP_CRT_ENTITY_BASE *&* This class has been generated on 16.04.2019 08:53:09 in client 100 *&* *&* WARNING--> NEVER MODIFY THIS CLASS <--WARNING *&* If you want to change the DPC implementation, use the *&* generated methods inside the DPC provider subclass - ZCL_ZEWM_ROBCO_DPC_EXT *&-----------------------------------------------------------------------------------------------* DATA openwarehousetas_create_entity TYPE zcl_zewm_robco_mpc=>ts_openwarehousetask. DATA warehouseorderse_create_entity TYPE zcl_zewm_robco_mpc=>ts_warehouseorder. DATA robotset_create_entity TYPE zcl_zewm_robco_mpc=>ts_robot. DATA storagebinset_create_entity TYPE zcl_zewm_robco_mpc=>ts_storagebin. DATA warehousenumbers_create_entity TYPE zcl_zewm_robco_mpc=>ts_warehousenumber. DATA warehousedescrip_create_entity TYPE zcl_zewm_robco_mpc=>ts_warehousedescription. DATA lv_entityset_name TYPE string. lv_entityset_name = io_tech_request_context->get_entity_set_name( ). CASE lv_entityset_name. *-------------------------------------------------------------------------* * EntitySet - OpenWarehouseTaskSet *-------------------------------------------------------------------------* WHEN 'OpenWarehouseTaskSet'. * Call the entity set generated method openwarehousetas_create_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = openwarehousetas_create_entity ). * Send specific entity data to the caller interfaces copy_data_to_ref( EXPORTING is_data = openwarehousetas_create_entity CHANGING cr_data = er_entity ). *-------------------------------------------------------------------------* * EntitySet - WarehouseOrderSet *-------------------------------------------------------------------------* WHEN 'WarehouseOrderSet'. * Call the entity set generated method warehouseorderse_create_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehouseorderse_create_entity ). * Send specific entity data to the caller interfaces copy_data_to_ref( EXPORTING is_data = warehouseorderse_create_entity CHANGING cr_data = er_entity ). *-------------------------------------------------------------------------* * EntitySet - RobotSet *-------------------------------------------------------------------------* WHEN 'RobotSet'. * Call the entity set generated method robotset_create_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = robotset_create_entity ). * Send specific entity data to the caller interfaces copy_data_to_ref( EXPORTING is_data = robotset_create_entity CHANGING cr_data = er_entity ). *-------------------------------------------------------------------------* * EntitySet - StorageBinSet *-------------------------------------------------------------------------* WHEN 'StorageBinSet'. * Call the entity set generated method storagebinset_create_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = storagebinset_create_entity ). * Send specific entity data to the caller interfaces copy_data_to_ref( EXPORTING is_data = storagebinset_create_entity CHANGING cr_data = er_entity ). *-------------------------------------------------------------------------* * EntitySet - WarehouseNumberSet *-------------------------------------------------------------------------* WHEN 'WarehouseNumberSet'. * Call the entity set generated method warehousenumbers_create_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehousenumbers_create_entity ). * Send specific entity data to the caller interfaces copy_data_to_ref( EXPORTING is_data = warehousenumbers_create_entity CHANGING cr_data = er_entity ). *-------------------------------------------------------------------------* * EntitySet - WarehouseDescriptionSet *-------------------------------------------------------------------------* WHEN 'WarehouseDescriptionSet'. * Call the entity set generated method warehousedescrip_create_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehousedescrip_create_entity ). * Send specific entity data to the caller interfaces copy_data_to_ref( EXPORTING is_data = warehousedescrip_create_entity CHANGING cr_data = er_entity ). when others. super->/iwbep/if_mgw_appl_srv_runtime~create_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path IMPORTING er_entity = er_entity ). ENDCASE. endmethod. method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~DELETE_ENTITY. *&----------------------------------------------------------------------------------------------* *& Include /IWBEP/DPC_TEMP_DEL_ENTITY_BASE *&* This class has been generated on 16.04.2019 08:53:09 in client 100 *&* *&* WARNING--> NEVER MODIFY THIS CLASS <--WARNING *&* If you want to change the DPC implementation, use the *&* generated methods inside the DPC provider subclass - ZCL_ZEWM_ROBCO_DPC_EXT *&-----------------------------------------------------------------------------------------------* DATA lv_entityset_name TYPE string. lv_entityset_name = io_tech_request_context->get_entity_set_name( ). CASE lv_entityset_name. *-------------------------------------------------------------------------* * EntitySet - OpenWarehouseTaskSet *-------------------------------------------------------------------------* when 'OpenWarehouseTaskSet'. * Call the entity set generated method openwarehousetas_delete_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context ). *-------------------------------------------------------------------------* * EntitySet - RobotSet *-------------------------------------------------------------------------* when 'RobotSet'. * Call the entity set generated method robotset_delete_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context ). *-------------------------------------------------------------------------* * EntitySet - StorageBinSet *-------------------------------------------------------------------------* when 'StorageBinSet'. * Call the entity set generated method storagebinset_delete_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context ). *-------------------------------------------------------------------------* * EntitySet - WarehouseDescriptionSet *-------------------------------------------------------------------------* when 'WarehouseDescriptionSet'. * Call the entity set generated method warehousedescrip_delete_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context ). *-------------------------------------------------------------------------* * EntitySet - WarehouseNumberSet *-------------------------------------------------------------------------* when 'WarehouseNumberSet'. * Call the entity set generated method warehousenumbers_delete_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context ). *-------------------------------------------------------------------------* * EntitySet - WarehouseOrderSet *-------------------------------------------------------------------------* when 'WarehouseOrderSet'. * Call the entity set generated method warehouseorderse_delete_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context ). when others. super->/iwbep/if_mgw_appl_srv_runtime~delete_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path ). ENDCASE. endmethod. method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY. *&-----------------------------------------------------------------------------------------------* *& Include /IWBEP/DPC_TEMP_GETENTITY_BASE *&* This class has been generated on 16.04.2019 08:53:09 in client 100 *&* *&* WARNING--> NEVER MODIFY THIS CLASS <--WARNING *&* If you want to change the DPC implementation, use the *&* generated methods inside the DPC provider subclass - ZCL_ZEWM_ROBCO_DPC_EXT *&-----------------------------------------------------------------------------------------------* DATA warehousedescrip_get_entity TYPE zcl_zewm_robco_mpc=>ts_warehousedescription. DATA storagebinset_get_entity TYPE zcl_zewm_robco_mpc=>ts_storagebin. DATA warehousenumbers_get_entity TYPE zcl_zewm_robco_mpc=>ts_warehousenumber. DATA robotset_get_entity TYPE zcl_zewm_robco_mpc=>ts_robot. DATA openwarehousetas_get_entity TYPE zcl_zewm_robco_mpc=>ts_openwarehousetask. DATA warehouseorderse_get_entity TYPE zcl_zewm_robco_mpc=>ts_warehouseorder. DATA lv_entityset_name TYPE string. DATA lr_entity TYPE REF TO data. ""#EC NEEDED lv_entityset_name = io_tech_request_context->get_entity_set_name( ). CASE lv_entityset_name. *-------------------------------------------------------------------------* * EntitySet - WarehouseDescriptionSet *-------------------------------------------------------------------------* WHEN 'WarehouseDescriptionSet'. * Call the entity set generated method warehousedescrip_get_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehousedescrip_get_entity es_response_context = es_response_context ). IF warehousedescrip_get_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehousedescrip_get_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - StorageBinSet *-------------------------------------------------------------------------* WHEN 'StorageBinSet'. * Call the entity set generated method storagebinset_get_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = storagebinset_get_entity es_response_context = es_response_context ). IF storagebinset_get_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = storagebinset_get_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - WarehouseNumberSet *-------------------------------------------------------------------------* WHEN 'WarehouseNumberSet'. * Call the entity set generated method warehousenumbers_get_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehousenumbers_get_entity es_response_context = es_response_context ). IF warehousenumbers_get_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehousenumbers_get_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - RobotSet *-------------------------------------------------------------------------* WHEN 'RobotSet'. * Call the entity set generated method robotset_get_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = robotset_get_entity es_response_context = es_response_context ). IF robotset_get_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = robotset_get_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - OpenWarehouseTaskSet *-------------------------------------------------------------------------* WHEN 'OpenWarehouseTaskSet'. * Call the entity set generated method openwarehousetas_get_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = openwarehousetas_get_entity es_response_context = es_response_context ). IF openwarehousetas_get_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = openwarehousetas_get_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - WarehouseOrderSet *-------------------------------------------------------------------------* WHEN 'WarehouseOrderSet'. * Call the entity set generated method warehouseorderse_get_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehouseorderse_get_entity es_response_context = es_response_context ). IF warehouseorderse_get_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehouseorderse_get_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. WHEN OTHERS. super->/iwbep/if_mgw_appl_srv_runtime~get_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_key_tab = it_key_tab it_navigation_path = it_navigation_path IMPORTING er_entity = er_entity ). ENDCASE. endmethod. method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET. *&----------------------------------------------------------------------------------------------* *& Include /IWBEP/DPC_TMP_ENTITYSET_BASE *&* This class has been generated on 16.04.2019 08:53:09 in client 100 *&* *&* WARNING--> NEVER MODIFY THIS CLASS <--WARNING *&* If you want to change the DPC implementation, use the *&* generated methods inside the DPC provider subclass - ZCL_ZEWM_ROBCO_DPC_EXT *&-----------------------------------------------------------------------------------------------* DATA warehousedescrip_get_entityset TYPE zcl_zewm_robco_mpc=>tt_warehousedescription. DATA storagebinset_get_entityset TYPE zcl_zewm_robco_mpc=>tt_storagebin. DATA warehousenumbers_get_entityset TYPE zcl_zewm_robco_mpc=>tt_warehousenumber. DATA robotset_get_entityset TYPE zcl_zewm_robco_mpc=>tt_robot. DATA openwarehousetas_get_entityset TYPE zcl_zewm_robco_mpc=>tt_openwarehousetask. DATA warehouseorderse_get_entityset TYPE zcl_zewm_robco_mpc=>tt_warehouseorder. DATA lv_entityset_name TYPE string. lv_entityset_name = io_tech_request_context->get_entity_set_name( ). CASE lv_entityset_name. *-------------------------------------------------------------------------* * EntitySet - WarehouseDescriptionSet *-------------------------------------------------------------------------* WHEN 'WarehouseDescriptionSet'. * Call the entity set generated method warehousedescrip_get_entityset( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_filter_select_options = it_filter_select_options it_order = it_order is_paging = is_paging it_navigation_path = it_navigation_path it_key_tab = it_key_tab iv_filter_string = iv_filter_string iv_search_string = iv_search_string io_tech_request_context = io_tech_request_context IMPORTING et_entityset = warehousedescrip_get_entityset es_response_context = es_response_context ). * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehousedescrip_get_entityset CHANGING cr_data = er_entityset ). *-------------------------------------------------------------------------* * EntitySet - StorageBinSet *-------------------------------------------------------------------------* WHEN 'StorageBinSet'. * Call the entity set generated method storagebinset_get_entityset( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_filter_select_options = it_filter_select_options it_order = it_order is_paging = is_paging it_navigation_path = it_navigation_path it_key_tab = it_key_tab iv_filter_string = iv_filter_string iv_search_string = iv_search_string io_tech_request_context = io_tech_request_context IMPORTING et_entityset = storagebinset_get_entityset es_response_context = es_response_context ). * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = storagebinset_get_entityset CHANGING cr_data = er_entityset ). *-------------------------------------------------------------------------* * EntitySet - WarehouseNumberSet *-------------------------------------------------------------------------* WHEN 'WarehouseNumberSet'. * Call the entity set generated method warehousenumbers_get_entityset( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_filter_select_options = it_filter_select_options it_order = it_order is_paging = is_paging it_navigation_path = it_navigation_path it_key_tab = it_key_tab iv_filter_string = iv_filter_string iv_search_string = iv_search_string io_tech_request_context = io_tech_request_context IMPORTING et_entityset = warehousenumbers_get_entityset es_response_context = es_response_context ). * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehousenumbers_get_entityset CHANGING cr_data = er_entityset ). *-------------------------------------------------------------------------* * EntitySet - RobotSet *-------------------------------------------------------------------------* WHEN 'RobotSet'. * Call the entity set generated method robotset_get_entityset( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_filter_select_options = it_filter_select_options it_order = it_order is_paging = is_paging it_navigation_path = it_navigation_path it_key_tab = it_key_tab iv_filter_string = iv_filter_string iv_search_string = iv_search_string io_tech_request_context = io_tech_request_context IMPORTING et_entityset = robotset_get_entityset es_response_context = es_response_context ). * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = robotset_get_entityset CHANGING cr_data = er_entityset ). *-------------------------------------------------------------------------* * EntitySet - OpenWarehouseTaskSet *-------------------------------------------------------------------------* WHEN 'OpenWarehouseTaskSet'. * Call the entity set generated method openwarehousetas_get_entityset( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_filter_select_options = it_filter_select_options it_order = it_order is_paging = is_paging it_navigation_path = it_navigation_path it_key_tab = it_key_tab iv_filter_string = iv_filter_string iv_search_string = iv_search_string io_tech_request_context = io_tech_request_context IMPORTING et_entityset = openwarehousetas_get_entityset es_response_context = es_response_context ). * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = openwarehousetas_get_entityset CHANGING cr_data = er_entityset ). *-------------------------------------------------------------------------* * EntitySet - WarehouseOrderSet *-------------------------------------------------------------------------* WHEN 'WarehouseOrderSet'. * Call the entity set generated method warehouseorderse_get_entityset( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_filter_select_options = it_filter_select_options it_order = it_order is_paging = is_paging it_navigation_path = it_navigation_path it_key_tab = it_key_tab iv_filter_string = iv_filter_string iv_search_string = iv_search_string io_tech_request_context = io_tech_request_context IMPORTING et_entityset = warehouseorderse_get_entityset es_response_context = es_response_context ). * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehouseorderse_get_entityset CHANGING cr_data = er_entityset ). WHEN OTHERS. super->/iwbep/if_mgw_appl_srv_runtime~get_entityset( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name it_filter_select_options = it_filter_select_options it_order = it_order is_paging = is_paging it_navigation_path = it_navigation_path it_key_tab = it_key_tab iv_filter_string = iv_filter_string iv_search_string = iv_search_string io_tech_request_context = io_tech_request_context IMPORTING er_entityset = er_entityset ). ENDCASE. endmethod. method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~UPDATE_ENTITY. *&----------------------------------------------------------------------------------------------* *& Include /IWBEP/DPC_TEMP_UPD_ENTITY_BASE *&* This class has been generated on 16.04.2019 08:53:09 in client 100 *&* *&* WARNING--> NEVER MODIFY THIS CLASS <--WARNING *&* If you want to change the DPC implementation, use the *&* generated methods inside the DPC provider subclass - ZCL_ZEWM_ROBCO_DPC_EXT *&-----------------------------------------------------------------------------------------------* DATA warehousedescrip_update_entity TYPE zcl_zewm_robco_mpc=>ts_warehousedescription. DATA warehousenumbers_update_entity TYPE zcl_zewm_robco_mpc=>ts_warehousenumber. DATA storagebinset_update_entity TYPE zcl_zewm_robco_mpc=>ts_storagebin. DATA robotset_update_entity TYPE zcl_zewm_robco_mpc=>ts_robot. DATA warehouseorderse_update_entity TYPE zcl_zewm_robco_mpc=>ts_warehouseorder. DATA openwarehousetas_update_entity TYPE zcl_zewm_robco_mpc=>ts_openwarehousetask. DATA lv_entityset_name TYPE string. DATA lr_entity TYPE REF TO data. ""#EC NEEDED lv_entityset_name = io_tech_request_context->get_entity_set_name( ). CASE lv_entityset_name. *-------------------------------------------------------------------------* * EntitySet - WarehouseDescriptionSet *-------------------------------------------------------------------------* WHEN 'WarehouseDescriptionSet'. * Call the entity set generated method warehousedescrip_update_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehousedescrip_update_entity ). IF warehousedescrip_update_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehousedescrip_update_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - WarehouseNumberSet *-------------------------------------------------------------------------* WHEN 'WarehouseNumberSet'. * Call the entity set generated method warehousenumbers_update_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehousenumbers_update_entity ). IF warehousenumbers_update_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehousenumbers_update_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - StorageBinSet *-------------------------------------------------------------------------* WHEN 'StorageBinSet'. * Call the entity set generated method storagebinset_update_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = storagebinset_update_entity ). IF storagebinset_update_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = storagebinset_update_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - RobotSet *-------------------------------------------------------------------------* WHEN 'RobotSet'. * Call the entity set generated method robotset_update_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = robotset_update_entity ). IF robotset_update_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = robotset_update_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - WarehouseOrderSet *-------------------------------------------------------------------------* WHEN 'WarehouseOrderSet'. * Call the entity set generated method warehouseorderse_update_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = warehouseorderse_update_entity ). IF warehouseorderse_update_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = warehouseorderse_update_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. *-------------------------------------------------------------------------* * EntitySet - OpenWarehouseTaskSet *-------------------------------------------------------------------------* WHEN 'OpenWarehouseTaskSet'. * Call the entity set generated method openwarehousetas_update_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path io_tech_request_context = io_tech_request_context IMPORTING er_entity = openwarehousetas_update_entity ). IF openwarehousetas_update_entity IS NOT INITIAL. * Send specific entity data to the caller interface copy_data_to_ref( EXPORTING is_data = openwarehousetas_update_entity CHANGING cr_data = er_entity ). ELSE. * In case of initial values - unbind the entity reference er_entity = lr_entity. ENDIF. WHEN OTHERS. super->/iwbep/if_mgw_appl_srv_runtime~update_entity( EXPORTING iv_entity_name = iv_entity_name iv_entity_set_name = iv_entity_set_name iv_source_name = iv_source_name io_data_provider = io_data_provider it_key_tab = it_key_tab it_navigation_path = it_navigation_path IMPORTING er_entity = er_entity ). ENDCASE. endmethod. method /IWBEP/IF_SB_DPC_COMM_SERVICES~COMMIT_WORK. * Call RFC commit work functionality DATA lt_message TYPE bapiret2. ""#EC NEEDED DATA lv_message_text TYPE BAPI_MSG. DATA lo_logger TYPE REF TO /iwbep/cl_cos_logger. DATA lv_subrc TYPE syst-subrc. lo_logger = /iwbep/if_mgw_conv_srv_runtime~get_logger( ). IF iv_rfc_dest IS INITIAL OR iv_rfc_dest EQ 'NONE'. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = abap_true IMPORTING return = lt_message. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION iv_rfc_dest EXPORTING wait = abap_true IMPORTING return = lt_message EXCEPTIONS communication_failure = 1000 MESSAGE lv_message_text system_failure = 1001 MESSAGE lv_message_text OTHERS = 1002. IF sy-subrc <> 0. lv_subrc = sy-subrc. /iwbep/cl_sb_gen_dpc_rt_util=>rfc_exception_handling( EXPORTING iv_subrc = lv_subrc iv_exp_message_text = lv_message_text io_logger = lo_logger ). ENDIF. ENDIF. endmethod. method /IWBEP/IF_SB_DPC_COMM_SERVICES~GET_GENERATION_STRATEGY. * Get generation strategy rv_generation_strategy = '1'. endmethod. method /IWBEP/IF_SB_DPC_COMM_SERVICES~LOG_MESSAGE. * Log message in the application log DATA lo_logger TYPE REF TO /iwbep/cl_cos_logger. DATA lv_text TYPE /iwbep/sup_msg_longtext. MESSAGE ID iv_msg_id TYPE iv_msg_type NUMBER iv_msg_number WITH iv_msg_v1 iv_msg_v2 iv_msg_v3 iv_msg_v4 INTO lv_text. lo_logger = mo_context->get_logger( ). lo_logger->log_message( EXPORTING iv_msg_type = iv_msg_type iv_msg_id = iv_msg_id iv_msg_number = iv_msg_number iv_msg_text = lv_text iv_msg_v1 = iv_msg_v1 iv_msg_v2 = iv_msg_v2 iv_msg_v3 = iv_msg_v3 iv_msg_v4 = iv_msg_v4 iv_agent = 'DPC' ). endmethod. method /IWBEP/IF_SB_DPC_COMM_SERVICES~RFC_EXCEPTION_HANDLING. * RFC call exception handling DATA lo_logger TYPE REF TO /iwbep/cl_cos_logger. lo_logger = /iwbep/if_mgw_conv_srv_runtime~get_logger( ). /iwbep/cl_sb_gen_dpc_rt_util=>rfc_exception_handling( EXPORTING iv_subrc = iv_subrc iv_exp_message_text = iv_exp_message_text io_logger = lo_logger ). endmethod. method /IWBEP/IF_SB_DPC_COMM_SERVICES~RFC_SAVE_LOG. DATA lo_logger TYPE REF TO /iwbep/cl_cos_logger. DATA lo_message_container TYPE REF TO /iwbep/if_message_container. lo_logger = /iwbep/if_mgw_conv_srv_runtime~get_logger( ). lo_message_container = /iwbep/if_mgw_conv_srv_runtime~get_message_container( ). "" Save the RFC call log in the application log /iwbep/cl_sb_gen_dpc_rt_util=>rfc_save_log( EXPORTING is_return = is_return iv_entity_type = iv_entity_type it_return = it_return it_key_tab = it_key_tab io_logger = lo_logger io_message_container = lo_message_container ). endmethod. method /IWBEP/IF_SB_DPC_COMM_SERVICES~SET_INJECTION. * Unit test injection IF io_unit IS BOUND. mo_injection = io_unit. ELSE. mo_injection = me. ENDIF. endmethod. method CHECK_SUBSCRIPTION_AUTHORITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'CHECK_SUBSCRIPTION_AUTHORITY'. endmethod. method OPENWAREHOUSETAS_CREATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'OPENWAREHOUSETAS_CREATE_ENTITY'. endmethod. method OPENWAREHOUSETAS_DELETE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'OPENWAREHOUSETAS_DELETE_ENTITY'. endmethod. method OPENWAREHOUSETAS_GET_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'OPENWAREHOUSETAS_GET_ENTITY'. endmethod. method OPENWAREHOUSETAS_GET_ENTITYSET. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'OPENWAREHOUSETAS_GET_ENTITYSET'. endmethod. method OPENWAREHOUSETAS_UPDATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'OPENWAREHOUSETAS_UPDATE_ENTITY'. endmethod. method ROBOTSET_CREATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'ROBOTSET_CREATE_ENTITY'. endmethod. method ROBOTSET_DELETE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'ROBOTSET_DELETE_ENTITY'. endmethod. method ROBOTSET_GET_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'ROBOTSET_GET_ENTITY'. endmethod. method ROBOTSET_GET_ENTITYSET. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'ROBOTSET_GET_ENTITYSET'. endmethod. method ROBOTSET_UPDATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'ROBOTSET_UPDATE_ENTITY'. endmethod. method STORAGEBINSET_CREATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'STORAGEBINSET_CREATE_ENTITY'. endmethod. method STORAGEBINSET_DELETE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'STORAGEBINSET_DELETE_ENTITY'. endmethod. method STORAGEBINSET_GET_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'STORAGEBINSET_GET_ENTITY'. endmethod. method STORAGEBINSET_GET_ENTITYSET. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'STORAGEBINSET_GET_ENTITYSET'. endmethod. method STORAGEBINSET_UPDATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'STORAGEBINSET_UPDATE_ENTITY'. endmethod. method WAREHOUSEDESCRIP_CREATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEDESCRIP_CREATE_ENTITY'. endmethod. method WAREHOUSEDESCRIP_DELETE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEDESCRIP_DELETE_ENTITY'. endmethod. method WAREHOUSEDESCRIP_GET_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEDESCRIP_GET_ENTITY'. endmethod. method WAREHOUSEDESCRIP_GET_ENTITYSET. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEDESCRIP_GET_ENTITYSET'. endmethod. method WAREHOUSEDESCRIP_UPDATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEDESCRIP_UPDATE_ENTITY'. endmethod. method WAREHOUSENUMBERS_CREATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSENUMBERS_CREATE_ENTITY'. endmethod. method WAREHOUSENUMBERS_DELETE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSENUMBERS_DELETE_ENTITY'. endmethod. method WAREHOUSENUMBERS_GET_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSENUMBERS_GET_ENTITY'. endmethod. method WAREHOUSENUMBERS_GET_ENTITYSET. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSENUMBERS_GET_ENTITYSET'. endmethod. method WAREHOUSENUMBERS_UPDATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSENUMBERS_UPDATE_ENTITY'. endmethod. method WAREHOUSEORDERSE_CREATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEORDERSE_CREATE_ENTITY'. endmethod. method WAREHOUSEORDERSE_DELETE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEORDERSE_DELETE_ENTITY'. endmethod. method WAREHOUSEORDERSE_GET_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEORDERSE_GET_ENTITY'. endmethod. method WAREHOUSEORDERSE_GET_ENTITYSET. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEORDERSE_GET_ENTITYSET'. endmethod. method WAREHOUSEORDERSE_UPDATE_ENTITY. RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc EXPORTING textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented method = 'WAREHOUSEORDERSE_UPDATE_ENTITY'. endmethod. ENDCLASS. ",16361,True,3263.395939125082,median "CLASS zcl_abapgit_object_tabl DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. ALIASES mo_files FOR zif_abapgit_object~mo_files. PROTECTED SECTION. TYPES: BEGIN OF ty_segment_definition, segmentheader TYPE edisegmhd, segmentdefinition TYPE edisegmdef, segmentstructures TYPE STANDARD TABLE OF edisegstru WITH DEFAULT KEY, END OF ty_segment_definition. TYPES: ty_segment_definitions TYPE STANDARD TABLE OF ty_segment_definition WITH DEFAULT KEY. TYPES: BEGIN OF ty_tabl_extras, tddat TYPE tddat, END OF ty_tabl_extras. ""! get additional data like table authorization group ""! @parameter iv_tabname | name of the table METHODS read_extras IMPORTING iv_tabname TYPE ddobjname RETURNING VALUE(rs_tabl_extras) TYPE ty_tabl_extras. ""! Update additional data ""! @parameter iv_tabname | name of the table ""! @parameter is_tabl_extras | additional table data METHODS update_extras IMPORTING iv_tabname TYPE ddobjname is_tabl_extras TYPE ty_tabl_extras. ""! Delete additional data ""! @parameter iv_tabname | name of the table METHODS delete_extras IMPORTING iv_tabname TYPE ddobjname. ""! Serialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @raising zcx_abapgit_exception | Exceptions METHODS serialize_idoc_segment IMPORTING io_xml TYPE REF TO zcl_abapgit_xml_output RAISING zcx_abapgit_exception. ""! Deserialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @parameter iv_package | Target package ""! @parameter rv_deserialized | It's a segment and was desserialized ""! @raising zcx_abapgit_exception | Exceptions METHODS deserialize_idoc_segment IMPORTING io_xml TYPE REF TO zcl_abapgit_xml_input iv_package TYPE devclass RETURNING VALUE(rv_deserialized) TYPE abap_bool RAISING zcx_abapgit_exception. ""! Delete the IDoc Segment type if exists ""! @parameter rv_deleted | It's a segment and was deleted ""! @raising zcx_abapgit_exception | Exceptions METHODS delete_idoc_segment RETURNING VALUE(rv_deleted) TYPE abap_bool RAISING zcx_abapgit_exception. PRIVATE SECTION. TYPES: ty_dd03p_tt TYPE STANDARD TABLE OF dd03p . TYPES: BEGIN OF ty_dd02_texts, ddlanguage TYPE dd02t-ddlanguage, ddtext TYPE dd02t-ddtext, END OF ty_dd02_texts, tt_dd02_texts TYPE STANDARD TABLE OF ty_dd02_texts. CONSTANTS c_longtext_id_tabl TYPE dokil-id VALUE 'TB' ##NO_TEXT. CONSTANTS: BEGIN OF c_s_dataname, segment_definition TYPE string VALUE 'SEGMENT_DEFINITION', tabl_extras TYPE string VALUE 'TABL_EXTRAS', END OF c_s_dataname. METHODS clear_dd03p_fields CHANGING !ct_dd03p TYPE ty_dd03p_tt . ""! Check if structure is an IDoc segment ""! @parameter rv_is_idoc_segment | It's an IDoc segment or not METHODS is_idoc_segment RETURNING VALUE(rv_is_idoc_segment) TYPE abap_bool. METHODS clear_dd03p_fields_common CHANGING !cs_dd03p TYPE dd03p . METHODS clear_dd03p_fields_dataelement CHANGING !cs_dd03p TYPE dd03p . METHODS: serialize_texts IMPORTING io_xml TYPE REF TO zcl_abapgit_xml_output RAISING zcx_abapgit_exception, deserialize_texts IMPORTING io_xml TYPE REF TO zcl_abapgit_xml_input is_dd02v TYPE dd02v RAISING zcx_abapgit_exception. ENDCLASS. CLASS ZCL_ABAPGIT_OBJECT_TABL IMPLEMENTATION. METHOD clear_dd03p_fields. CONSTANTS lc_comptype_dataelement TYPE comptype VALUE 'E' ##NO_TEXT. DATA: lv_masklen TYPE c LENGTH 4. FIELD-SYMBOLS: TYPE dd03p. * remove nested structures DELETE ct_dd03p WHERE depth <> '00'. * remove fields from .INCLUDEs DELETE ct_dd03p WHERE adminfield <> '0'. LOOP AT ct_dd03p ASSIGNING WHERE NOT rollname IS INITIAL. clear_dd03p_fields_common( CHANGING cs_dd03p = ). lv_masklen = -masklen. IF lv_masklen = '' OR NOT lv_masklen CO '0123456789'. * make sure the field contains valid data, or the XML will dump CLEAR -masklen. ENDIF. IF -comptype = lc_comptype_dataelement. clear_dd03p_fields_dataelement( CHANGING cs_dd03p = ). ENDIF. IF -shlporigin = 'D'. * search help from domain CLEAR: -shlpfield, -shlpname. ENDIF. * XML output assumes correct field content IF -routputlen = ' '. CLEAR -routputlen. ENDIF. ENDLOOP. ENDMETHOD. METHOD clear_dd03p_fields_common. CLEAR: cs_dd03p-ddlanguage, cs_dd03p-dtelmaster, cs_dd03p-logflag, cs_dd03p-ddtext, cs_dd03p-reservedte, cs_dd03p-reptext, cs_dd03p-scrtext_s, cs_dd03p-scrtext_m, cs_dd03p-scrtext_l. ENDMETHOD. METHOD clear_dd03p_fields_dataelement. * type specified via data element CLEAR: cs_dd03p-domname, cs_dd03p-inttype, cs_dd03p-intlen, cs_dd03p-mask, cs_dd03p-memoryid, cs_dd03p-headlen, cs_dd03p-scrlen1, cs_dd03p-scrlen2, cs_dd03p-scrlen3, cs_dd03p-datatype, cs_dd03p-leng, cs_dd03p-outputlen, cs_dd03p-deffdname, cs_dd03p-convexit, cs_dd03p-entitytab, cs_dd03p-dommaster, cs_dd03p-domname3l, cs_dd03p-decimals, cs_dd03p-lowercase, cs_dd03p-signflag. ENDMETHOD. METHOD delete_extras. DELETE FROM tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD delete_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. IF is_idoc_segment( ) = abap_false. rv_deleted = abap_false. RETURN. ""previous XML version or no IDoc segment ENDIF. rv_deleted = abap_true. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_DELETE' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD deserialize_idoc_segment. DATA lv_result LIKE sy-subrc. DATA lt_segment_definitions TYPE ty_segment_definitions. DATA lv_package TYPE devclass. DATA lv_uname TYPE sy-uname. FIELD-SYMBOLS TYPE ty_segment_definition. rv_deserialized = abap_false. TRY. io_xml->read( EXPORTING iv_name = c_s_dataname-segment_definition CHANGING cg_data = lt_segment_definitions ). CATCH zcx_abapgit_exception. RETURN. ""previous XML version or no IDoc segment ENDTRY. IF lines( lt_segment_definitions ) = 0. RETURN. ""no IDoc segment ENDIF. rv_deserialized = abap_true. lv_package = iv_package. LOOP AT lt_segment_definitions ASSIGNING . -segmentheader-presp = -segmentheader-pwork = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = -segmentheader-segtyp IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. CALL FUNCTION 'SEGMENT_CREATE' IMPORTING segmentdefinition = -segmentdefinition TABLES segmentstructure = -segmentstructures CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. ELSE. CALL FUNCTION 'SEGMENT_MODIFY' CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. CALL FUNCTION 'SEGMENTDEFINITION_MODIFY' TABLES segmentstructure = -segmentstructures CHANGING segmentdefinition = -segmentdefinition EXCEPTIONS OTHERS = 1. ENDIF. ENDIF. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDLOOP. lv_uname = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_test_modus = abap_false wi_tadir_pgmid = 'R3TR' wi_tadir_object = ms_item-obj_type wi_tadir_obj_name = ms_item-obj_name wi_tadir_author = lv_uname wi_tadir_devclass = iv_package wi_tadir_masterlang = mv_language iv_set_edtflag = abap_true iv_delflag = abap_false EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from TR_TADIR_INTERFACE' ). ENDIF. ENDMETHOD. METHOD deserialize_texts. DATA: lv_name TYPE ddobjname, ls_dd02v_tmp TYPE dd02v, lt_i18n_langs TYPE TABLE OF langu, lt_dd02_texts TYPE tt_dd02_texts. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. lv_name = ms_item-obj_name. io_xml->read( EXPORTING iv_name = 'I18N_LANGS' CHANGING cg_data = lt_i18n_langs ). io_xml->read( EXPORTING iv_name = 'DD02_TEXTS' CHANGING cg_data = lt_dd02_texts ). SORT lt_i18n_langs. SORT lt_dd02_texts BY ddlanguage. "" Optimization LOOP AT lt_i18n_langs ASSIGNING . "" Table description ls_dd02v_tmp = is_dd02v. READ TABLE lt_dd02_texts ASSIGNING WITH KEY ddlanguage = . IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |DD02_TEXTS cannot find lang { } in XML| ). ENDIF. MOVE-CORRESPONDING TO ls_dd02v_tmp. CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v_tmp EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |error from DDIF_TABL_PUT @TEXTS, { sy-subrc }| ). ENDIF. ENDLOOP. ENDMETHOD. METHOD is_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. lv_segment_type = ms_item-obj_name. SELECT SINGLE segtyp FROM edisegment INTO lv_segment_type WHERE segtyp = lv_segment_type. rv_is_idoc_segment = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD read_extras. SELECT SINGLE * FROM tddat INTO rs_tabl_extras-tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD serialize_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. DATA lv_devclass TYPE devclass. DATA lt_segmentdefinitions TYPE STANDARD TABLE OF edisegmdef. DATA ls_segment_definition TYPE ty_segment_definition. DATA lt_segment_definitions TYPE ty_segment_definitions. FIELD-SYMBOLS: TYPE edisegmdef. IF is_idoc_segment( ) = abap_false. RETURN. ENDIF. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result TABLES segmentdefinition = lt_segmentdefinitions EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. LOOP AT lt_segmentdefinitions ASSIGNING . CLEAR ls_segment_definition. CALL FUNCTION 'SEGMENTDEFINITION_READ' EXPORTING segmenttyp = -segtyp IMPORTING result = lv_result devclass = lv_devclass segmentheader = ls_segment_definition-segmentheader segmentdefinition = ls_segment_definition-segmentdefinition TABLES segmentstructure = ls_segment_definition-segmentstructures CHANGING version = -version EXCEPTIONS no_authority = 1 segment_not_existing = 2 OTHERS = 3. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentdefinition ). zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentheader ). APPEND ls_segment_definition TO lt_segment_definitions. ENDLOOP. io_xml->add( iv_name = c_s_dataname-segment_definition ig_data = lt_segment_definitions ). ENDMETHOD. METHOD serialize_texts. DATA: lv_name TYPE ddobjname, lv_index TYPE i, ls_dd02v TYPE dd02v, lt_dd02_texts TYPE tt_dd02_texts, lt_i18n_langs TYPE TABLE OF langu. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. IF io_xml->i18n_params( )-serialize_master_lang_only = abap_true. RETURN. ENDIF. lv_name = ms_item-obj_name. "" Collect additional languages, skip master lang - it was serialized already SELECT DISTINCT ddlanguage AS langu INTO TABLE lt_i18n_langs FROM dd02v WHERE tabname = lv_name AND ddlanguage <> mv_language. ""#EC CI_SUBRC LOOP AT lt_i18n_langs ASSIGNING . lv_index = sy-tabix. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = IMPORTING dd02v_wa = ls_dd02v EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0 OR ls_dd02v-ddlanguage IS INITIAL. DELETE lt_i18n_langs INDEX lv_index. "" Don't save this lang CONTINUE. ENDIF. APPEND INITIAL LINE TO lt_dd02_texts ASSIGNING . MOVE-CORRESPONDING ls_dd02v TO . ENDLOOP. SORT lt_i18n_langs ASCENDING. SORT lt_dd02_texts BY ddlanguage ASCENDING. IF lines( lt_i18n_langs ) > 0. io_xml->add( iv_name = 'I18N_LANGS' ig_data = lt_i18n_langs ). io_xml->add( iv_name = 'DD02_TEXTS' ig_data = lt_dd02_texts ). ENDIF. ENDMETHOD. METHOD update_extras. IF is_tabl_extras-tddat IS INITIAL. delete_extras( iv_tabname = iv_tabname ). ELSE. MODIFY tddat FROM is_tabl_extras-tddat. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~changed_by. TYPES: BEGIN OF ty_data, as4user TYPE as4user, as4date TYPE as4date, as4time TYPE as4time, END OF ty_data. DATA: lt_data TYPE STANDARD TABLE OF ty_data WITH DEFAULT KEY, ls_data LIKE LINE OF lt_data. SELECT as4user as4date as4time FROM dd02l INTO TABLE lt_data WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd09l WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd12l WHERE sqltab = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SORT lt_data BY as4date DESCENDING as4time DESCENDING. READ TABLE lt_data INDEX 1 INTO ls_data. IF sy-subrc = 0. rv_user = ls_data-as4user. ELSE. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lv_objname TYPE rsedd0-ddobjname, lv_tabclass TYPE dd02l-tabclass, lv_no_ask TYPE abap_bool, lv_subrc TYPE sy-subrc, lr_data TYPE REF TO data. FIELD-SYMBOLS: TYPE any. IF zif_abapgit_object~exists( ) = abap_false. "" Proxies e.g. delete on its own, nothing todo here then. RETURN. ENDIF. lv_objname = ms_item-obj_name. IF delete_idoc_segment( ) = abap_false. lv_no_ask = abap_true. SELECT SINGLE tabclass FROM dd02l INTO lv_tabclass WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. IF sy-subrc = 0 AND lv_tabclass = 'TRANSP'. "" Avoid dump in dynamic SELECT in case the table does not exist on database CALL FUNCTION 'DB_EXISTS_TABLE' EXPORTING tabname = lv_objname IMPORTING subrc = lv_subrc. IF lv_subrc = 0. "" it cannot delete table with data without asking CREATE DATA lr_data TYPE (lv_objname). ASSIGN lr_data->* TO . SELECT SINGLE * FROM (lv_objname) INTO . IF sy-subrc = 0. lv_no_ask = abap_false. ENDIF. ENDIF. ENDIF. delete_ddic( iv_objtype = 'T' iv_no_ask = lv_no_ask ). delete_longtexts( c_longtext_id_tabl ). delete_extras( iv_tabname = lv_objname ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lv_name TYPE ddobjname, lv_tname TYPE trobj_name, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE TABLE OF dd03p, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, ls_dd17v LIKE LINE OF lt_dd17v, lt_secondary LIKE lt_dd17v, lt_dd35v TYPE TABLE OF dd35v, lt_dd36m TYPE dd36mttyp, ls_dd12v LIKE LINE OF lt_dd12v, lv_refs TYPE abap_bool, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: TYPE dd03p. IF deserialize_idoc_segment( io_xml = io_xml iv_package = iv_package ) = abap_false. io_xml->read( EXPORTING iv_name = 'DD02V' CHANGING cg_data = ls_dd02v ). io_xml->read( EXPORTING iv_name = 'DD09L' CHANGING cg_data = ls_dd09l ). io_xml->read( EXPORTING iv_name = 'DD03P_TABLE' CHANGING cg_data = lt_dd03p ). "" DDIC Step: Replace REF TO class/interface with generic reference to avoid cyclic dependency LOOP AT lt_dd03p ASSIGNING WHERE datatype = 'REF'. IF iv_step = zif_abapgit_object=>gc_step_id-ddic. -rollname = 'OBJECT'. ELSE. lv_refs = abap_true. ENDIF. ENDLOOP. io_xml->read( EXPORTING iv_name = 'DD05M_TABLE' CHANGING cg_data = lt_dd05m ). io_xml->read( EXPORTING iv_name = 'DD08V_TABLE' CHANGING cg_data = lt_dd08v ). io_xml->read( EXPORTING iv_name = 'DD12V' CHANGING cg_data = lt_dd12v ). io_xml->read( EXPORTING iv_name = 'DD17V' CHANGING cg_data = lt_dd17v ). io_xml->read( EXPORTING iv_name = 'DD35V_TALE' CHANGING cg_data = lt_dd35v ). io_xml->read( EXPORTING iv_name = 'DD36M' CHANGING cg_data = lt_dd36m ). "" DDIC Step: Remove referenced to search helps IF iv_step = zif_abapgit_object=>gc_step_id-ddic. CLEAR: lt_dd35v, lt_dd36m. ENDIF. IF iv_step = zif_abapgit_object=>gc_step_id-late AND lv_refs = abap_false AND lines( lt_dd35v ) = 0. RETURN. "" already active ENDIF. corr_insert( iv_package = iv_package ig_object_class = 'DICT' ). lv_name = ms_item-obj_name. "" type conversion CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_TABL_PUT' ). ENDIF. zcl_abapgit_objects_activation=>add_item( ms_item ). * handle indexes LOOP AT lt_dd12v INTO ls_dd12v. * todo, call corr_insert? CLEAR lt_secondary. LOOP AT lt_dd17v INTO ls_dd17v WHERE sqltab = ls_dd12v-sqltab AND indexname = ls_dd12v-indexname. APPEND ls_dd17v TO lt_secondary. ENDLOOP. CALL FUNCTION 'DDIF_INDX_PUT' EXPORTING name = ls_dd12v-sqltab id = ls_dd12v-indexname dd12v_wa = ls_dd12v TABLES dd17v_tab = lt_secondary EXCEPTIONS indx_not_found = 1 name_inconsistent = 2 indx_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_INDX_PUT' ). ENDIF. CALL FUNCTION 'DD_DD_TO_E071' EXPORTING type = 'INDX' name = ls_dd12v-sqltab id = ls_dd12v-indexname IMPORTING obj_name = lv_tname. zcl_abapgit_objects_activation=>add( iv_type = 'INDX' iv_name = lv_tname ). ENDLOOP. deserialize_texts( io_xml = io_xml is_dd02v = ls_dd02v ). deserialize_longtexts( io_xml ). io_xml->read( EXPORTING iv_name = c_s_dataname-tabl_extras CHANGING cg_data = ls_extras ). update_extras( iv_tabname = lv_name is_tabl_extras = ls_extras ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_tabname TYPE dd02l-tabname. lv_tabname = ms_item-obj_name. CALL FUNCTION 'DD_GET_NAMETAB_HEADER' EXPORTING tabname = lv_tabname EXCEPTIONS not_found = 1 OTHERS = 2. rv_bool = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. DATA: lo_local_version_output TYPE REF TO zcl_abapgit_xml_output, lo_local_version_input TYPE REF TO zcl_abapgit_xml_input. CREATE OBJECT lo_local_version_output. me->zif_abapgit_object~serialize( lo_local_version_output ). CREATE OBJECT lo_local_version_input EXPORTING iv_xml = lo_local_version_output->render( ). CREATE OBJECT ri_comparator TYPE zcl_abapgit_object_tabl_compar EXPORTING io_local = lo_local_version_input. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-ddic TO rt_steps. APPEND zif_abapgit_object=>gc_step_id-late TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). rs_metadata-ddic = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'ESDICT' iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. jump_se11( iv_radio = 'RSRD1-DDTYPE' iv_field = 'RSRD1-DDTYPE_VAL' ). ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lv_name TYPE ddobjname, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE ty_dd03p_tt, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, lt_dd35v TYPE TABLE OF dd35v, lv_index LIKE sy-index, lt_dd36m TYPE dd36mttyp, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: LIKE LINE OF lt_dd12v, LIKE LINE OF lt_dd05m, LIKE LINE OF lt_dd36m, TYPE any. lv_name = ms_item-obj_name. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = mv_language IMPORTING dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd12v_tab = lt_dd12v dd17v_tab = lt_dd17v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_TABL_GET' ). ENDIF. IF ls_dd02v IS INITIAL. RETURN. "" object does not exits ENDIF. CLEAR: ls_dd02v-as4user, ls_dd02v-as4date, ls_dd02v-as4time. * reset numeric field, so XML does not crash IF ls_dd02v-prozpuff = ''. CLEAR ls_dd02v-prozpuff. ENDIF. IF ls_dd02v-datmin = ''. CLEAR ls_dd02v-datmin. ENDIF. IF ls_dd02v-datmax = ''. CLEAR ls_dd02v-datmax. ENDIF. IF ls_dd02v-datavg = ''. CLEAR ls_dd02v-datavg. ENDIF. CLEAR: ls_dd09l-as4user, ls_dd09l-as4date, ls_dd09l-as4time. ASSIGN COMPONENT 'ROWORCOLST' OF STRUCTURE ls_dd09l TO . IF sy-subrc = 0 AND = 'C'. CLEAR . ""To avoid diff errors. This field doesn't exists in all releases ENDIF. LOOP AT lt_dd12v ASSIGNING . CLEAR: -as4user, -as4date, -as4time. ENDLOOP. clear_dd03p_fields( CHANGING ct_dd03p = lt_dd03p ). * remove foreign keys inherited from .INCLUDEs DELETE lt_dd08v WHERE noinherit = 'N'. LOOP AT lt_dd05m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd08v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd05m INDEX lv_index. ENDIF. ENDLOOP. * remove inherited search helps DELETE lt_dd35v WHERE shlpinher = abap_true. LOOP AT lt_dd36m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd35v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd36m INDEX lv_index. ENDIF. ENDLOOP. io_xml->add( iv_name = 'DD02V' ig_data = ls_dd02v ). IF NOT ls_dd09l IS INITIAL. io_xml->add( iv_name = 'DD09L' ig_data = ls_dd09l ). ENDIF. io_xml->add( iv_name = 'DD03P_TABLE' ig_data = lt_dd03p ). io_xml->add( iv_name = 'DD05M_TABLE' ig_data = lt_dd05m ). io_xml->add( iv_name = 'DD08V_TABLE' ig_data = lt_dd08v ). io_xml->add( iv_name = 'DD12V' ig_data = lt_dd12v ). io_xml->add( iv_name = 'DD17V' ig_data = lt_dd17v ). io_xml->add( iv_name = 'DD35V_TALE' ig_data = lt_dd35v ). io_xml->add( iv_name = 'DD36M' ig_data = lt_dd36m ). serialize_texts( io_xml ). serialize_longtexts( io_xml = io_xml iv_longtext_id = c_longtext_id_tabl ). serialize_idoc_segment( io_xml ). ls_extras = read_extras( iv_tabname = lv_name ). io_xml->add( iv_name = c_s_dataname-tabl_extras ig_data = ls_extras ). ENDMETHOD. ENDCLASS. ",8145,False,1730.7593116120095,median "CLASS zcl_abapgit_gui_router DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_gui_event_handler. PROTECTED SECTION. PRIVATE SECTION. TYPES: BEGIN OF ty_event_data, action TYPE string, prev_page TYPE string, getdata TYPE string, postdata TYPE cnht_post_data_tab, END OF ty_event_data . METHODS general_page_routing IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. METHODS abapgit_services_actions IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. METHODS db_actions IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. CLASS-METHODS file_download IMPORTING !iv_package TYPE devclass !iv_xstr TYPE xstring RAISING zcx_abapgit_exception . METHODS git_services IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. METHODS remote_origin_manipulations IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. METHODS sap_gui_actions IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. METHODS zip_services IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. METHODS repository_services IMPORTING !is_event_data TYPE ty_event_data EXPORTING !ei_page TYPE REF TO zif_abapgit_gui_renderable !ev_state TYPE i RAISING zcx_abapgit_exception. METHODS get_page_diff IMPORTING !iv_getdata TYPE clike RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_branch_overview IMPORTING !iv_getdata TYPE clike RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_stage IMPORTING !iv_getdata TYPE clike RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_background IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . CLASS-METHODS jump_display_transport IMPORTING !iv_getdata TYPE clike RAISING zcx_abapgit_exception. ENDCLASS. CLASS zcl_abapgit_gui_router IMPLEMENTATION. METHOD abapgit_services_actions. DATA: li_main_page TYPE REF TO zcl_abapgit_gui_page_main. CASE is_event_data-action. "" ABAPGIT services actions WHEN zif_abapgit_definitions=>c_action-abapgit_home. CREATE OBJECT li_main_page. ei_page = li_main_page. ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-abapgit_install. "" Install abapGit zcl_abapgit_services_abapgit=>install_abapgit( ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD db_actions. CASE is_event_data-action. "" DB actions WHEN zif_abapgit_definitions=>c_action-db_edit. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_db_edit EXPORTING is_key = zcl_abapgit_html_action_utils=>dbkey_decode( is_event_data-getdata ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. IF is_event_data-prev_page = 'PAGE_DB_DIS'. ev_state = zcl_abapgit_gui=>c_event_state-new_page_replacing. ENDIF. WHEN zif_abapgit_definitions=>c_action-db_display. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_db_dis EXPORTING is_key = zcl_abapgit_html_action_utils=>dbkey_decode( is_event_data-getdata ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. ENDCASE. ENDMETHOD. METHOD file_download. DATA: lv_path TYPE string, lv_default TYPE string, li_fe_serv TYPE REF TO zif_abapgit_frontend_services, lv_package TYPE devclass. lv_package = iv_package. TRANSLATE lv_package USING '/#'. CONCATENATE lv_package '_' sy-datlo '_' sy-timlo INTO lv_default. li_fe_serv = zcl_abapgit_ui_factory=>get_frontend_services( ). lv_path = li_fe_serv->show_file_save_dialog( iv_title = 'Export ZIP' iv_extension = 'zip' iv_default_filename = lv_default ). li_fe_serv->file_download( iv_path = lv_path iv_xstr = iv_xstr ). ENDMETHOD. METHOD general_page_routing. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_last_repo_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = is_event_data-getdata. "" TODO refactor CASE is_event_data-action. "" General PAGE routing WHEN zcl_abapgit_gui=>c_action-go_home. IF zcl_abapgit_persist_settings=>get_instance( )->read( )->get_show_default_repo( ) = abap_true. lv_last_repo_key = zcl_abapgit_persistence_user=>get_instance( )->get_repo_show( ). CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_view_repo EXPORTING iv_key = lv_last_repo_key. ev_state = zcl_abapgit_gui=>c_event_state-new_page. ELSE. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_main. ev_state = zcl_abapgit_gui=>c_event_state-new_page. ENDIF. WHEN zif_abapgit_definitions=>c_action-go_repo_overview. "" Go Repository overview CREATE OBJECT ei_page TYPE zcl_abapgit_gui_repo_over. ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_db. "" Go DB util page CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_db. ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_debuginfo. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_debuginfo. ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_settings. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_settings. ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_background_run. "" Go background run page CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_bkg_run. ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_background. "" Go Background page ei_page = get_page_background( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_diff. "" Go Diff page ei_page = get_page_diff( is_event_data-getdata ). ev_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. WHEN zif_abapgit_definitions=>c_action-go_stage. "" Go Staging page ei_page = get_page_stage( is_event_data-getdata ). IF is_event_data-prev_page = 'PAGE_DIFF'. ev_state = zcl_abapgit_gui=>c_event_state-new_page. ELSE. ev_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. ENDIF. WHEN zif_abapgit_definitions=>c_action-go_branch_overview. "" Go repo branch overview ei_page = get_page_branch_overview( is_event_data-getdata ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_tutorial. "" Go to tutorial CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_tutorial. ev_state = zcl_abapgit_gui=>c_event_state-new_page. ENDCASE. ENDMETHOD. METHOD get_page_background. CREATE OBJECT ri_page TYPE zcl_abapgit_gui_page_bkg EXPORTING iv_key = iv_key. ENDMETHOD. METHOD get_page_branch_overview. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lo_page TYPE REF TO zcl_abapgit_gui_page_boverview, lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = iv_getdata. lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). CREATE OBJECT lo_page EXPORTING io_repo = lo_repo. ri_page = lo_page. ENDMETHOD. METHOD get_page_diff. DATA: ls_file TYPE zif_abapgit_definitions=>ty_file, ls_object TYPE zif_abapgit_definitions=>ty_item, lo_page TYPE REF TO zcl_abapgit_gui_page_diff, lv_key TYPE zif_abapgit_persistence=>ty_repo-key. zcl_abapgit_html_action_utils=>file_obj_decode( EXPORTING iv_string = iv_getdata IMPORTING ev_key = lv_key eg_file = ls_file eg_object = ls_object ). CREATE OBJECT lo_page EXPORTING iv_key = lv_key is_file = ls_file is_object = ls_object. ri_page = lo_page. ENDMETHOD. METHOD get_page_stage. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_seed TYPE string, lo_stage_page TYPE REF TO zcl_abapgit_gui_page_stage, lo_code_inspector_page TYPE REF TO zcl_abapgit_gui_page_code_insp. FIND FIRST OCCURRENCE OF '=' IN iv_getdata. IF sy-subrc <> 0. "" Not found ? -> just repo key in params lv_key = iv_getdata. ELSE. zcl_abapgit_html_action_utils=>stage_decode( EXPORTING iv_getdata = iv_getdata IMPORTING ev_key = lv_key ev_seed = lv_seed ). ENDIF. lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). IF lo_repo->get_local_settings( )-code_inspector_check_variant IS NOT INITIAL. CREATE OBJECT lo_code_inspector_page EXPORTING io_repo = lo_repo. ri_page = lo_code_inspector_page. ELSE. "" force refresh on stage, to make sure the latest local and remote files are used lo_repo->refresh( ). CREATE OBJECT lo_stage_page EXPORTING io_repo = lo_repo iv_seed = lv_seed. ri_page = lo_stage_page. ENDIF. ENDMETHOD. METHOD git_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = is_event_data-getdata. "" TODO refactor CASE is_event_data-action. "" GIT actions WHEN zif_abapgit_definitions=>c_action-git_pull. "" GIT Pull zcl_abapgit_services_git=>pull( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_reset. "" GIT Reset zcl_abapgit_services_git=>reset( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_create. "" GIT Create new branch zcl_abapgit_services_git=>create_branch( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_delete. "" GIT Delete remote branch zcl_abapgit_services_git=>delete_branch( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_switch. "" GIT Switch branch zcl_abapgit_services_git=>switch_branch( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-go_tag_overview. "" GIT Tag overview zcl_abapgit_services_git=>tag_overview( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_create. "" GIT Tag create CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_tag EXPORTING io_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-git_tag_delete. "" GIT Tag create zcl_abapgit_services_git=>delete_tag( lv_key ). zcl_abapgit_services_repo=>refresh( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_switch. "" GIT Switch Tag zcl_abapgit_services_git=>switch_tag( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD jump_display_transport. DATA: lv_transport TYPE trkorr, lv_transport_adt_uri TYPE string, lv_adt_link TYPE string, lv_adt_jump_enabled TYPE abap_bool. lv_transport = iv_getdata. lv_adt_jump_enabled = zcl_abapgit_persist_settings=>get_instance( )->read( )->get_adt_jump_enabled( ). IF lv_adt_jump_enabled = abap_true. TRY. CALL METHOD ('CL_CTS_ADT_TM_URI_BUILDER')=>('CREATE_ADT_URI') EXPORTING trnumber = lv_transport RECEIVING result = lv_transport_adt_uri. lv_adt_link = |adt://{ sy-sysid }{ lv_transport_adt_uri }|. cl_gui_frontend_services=>execute( EXPORTING document = lv_adt_link EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'ADT Jump Error' ). ENDIF. CATCH cx_root. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = lv_transport. ENDTRY. ELSE. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = lv_transport. ENDIF. ENDMETHOD. METHOD remote_origin_manipulations. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = is_event_data-getdata. "" TODO refactor CASE is_event_data-action. "" Remote ORIGIN manipulations WHEN zif_abapgit_definitions=>c_action-repo_remote_attach. "" Remote attach zcl_abapgit_services_repo=>remote_attach( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_remote_detach. "" Remote detach zcl_abapgit_services_repo=>remote_detach( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_remote_change. "" Remote change zcl_abapgit_services_repo=>remote_change( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD repository_services. DATA: lv_url TYPE string, lv_key TYPE zif_abapgit_persistence=>ty_repo-key, li_log TYPE REF TO zif_abapgit_log. lv_key = is_event_data-getdata. "" TODO refactor lv_url = is_event_data-getdata. "" TODO refactor CASE is_event_data-action. "" REPOSITORY services actions WHEN zif_abapgit_definitions=>c_action-repo_newoffline. "" New offline repo zcl_abapgit_services_repo=>new_offline( ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req. zcl_abapgit_transport=>add_all_objects_to_trans_req( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_refresh. "" Repo refresh zcl_abapgit_services_repo=>refresh( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_syntax_check. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_syntax EXPORTING io_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_code_inspector. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_code_insp EXPORTING io_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_purge. "" Repo remove & purge all objects zcl_abapgit_services_repo=>purge( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_remove. "" Repo remove zcl_abapgit_services_repo=>remove( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_newonline. zcl_abapgit_services_repo=>new_online( lv_url ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_refresh_checksums. "" Rebuild local checksums zcl_abapgit_services_repo=>refresh_local_checksums( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_toggle_fav. "" Toggle repo as favorite zcl_abapgit_services_repo=>toggle_favorite( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_transport_to_branch. zcl_abapgit_services_repo=>transport_to_branch( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_settings. CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_repo_sett EXPORTING io_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_log. li_log = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key )->get_log( ). zcl_abapgit_log_viewer=>show_log( ii_log = li_log iv_header_text = li_log->get_title( ) ). ev_state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD sap_gui_actions. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item. CASE is_event_data-action. "" SAP GUI actions WHEN zif_abapgit_definitions=>c_action-jump. "" Open object editor zcl_abapgit_html_action_utils=>jump_decode( EXPORTING iv_string = is_event_data-getdata IMPORTING ev_obj_type = ls_item-obj_type ev_obj_name = ls_item-obj_name ). zcl_abapgit_objects=>jump( ls_item ). ev_state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-jump_transport. jump_display_transport( is_event_data-getdata ). ev_state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. DATA: ls_event_data TYPE ty_event_data. ls_event_data-action = iv_action. ls_event_data-getdata = iv_getdata. ls_event_data-postdata = it_postdata. general_page_routing( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). repository_services( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). git_services( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). zip_services( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). db_actions( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). abapgit_services_actions( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). remote_origin_manipulations( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). sap_gui_actions( EXPORTING is_event_data = ls_event_data IMPORTING ei_page = ei_page ev_state = ev_state ). IF ev_state IS INITIAL. ev_state = zcl_abapgit_gui=>c_event_state-not_handled. ENDIF. ENDMETHOD. METHOD zip_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_repo TYPE REF TO zcl_abapgit_repo, lv_package TYPE devclass, lv_path TYPE string, lv_xstr TYPE xstring. lv_key = is_event_data-getdata. "" TODO refactor CASE is_event_data-action. "" ZIP services actions WHEN zif_abapgit_definitions=>c_action-zip_import. "" Import repo from ZIP lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). lv_path = zcl_abapgit_ui_factory=>get_frontend_services( )->show_file_open_dialog( iv_title = 'Import ZIP' iv_extension = 'zip' iv_default_filename = '*.zip' ). lv_xstr = zcl_abapgit_ui_factory=>get_frontend_services( )->file_upload( lv_path ). lo_repo->set_files_remote( zcl_abapgit_zip=>load( lv_xstr ) ). zcl_abapgit_services_repo=>refresh( lv_key ). ev_state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-zip_export. "" Export repo as ZIP lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). lv_xstr = zcl_abapgit_zip=>export( lo_repo ). file_download( iv_package = lo_repo->get_package( ) iv_xstr = lv_xstr ). ev_state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_package. "" Export package as ZIP zcl_abapgit_zip=>export_package( IMPORTING ev_xstr = lv_xstr ev_package = lv_package ). file_download( iv_package = lv_package iv_xstr = lv_xstr ). ev_state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_transport. "" Export transports as ZIP zcl_abapgit_transport_mass=>run( ). ev_state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_object. "" Export object as ZIP zcl_abapgit_zip=>export_object( ). ev_state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. ENDCLASS. ",5976,False,1474.0837768452393,median "class /HEC1/CL_CONFIG_ACT_DEL_HELPER definition public final create public . public section. interfaces /HEC1/IF_BOPF_ACT_DEL_HELPER . protected section. private section. class-methods DELETE_ADDITIONAL_SERVICE importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_SOLUTION type /BOBF/T_FRW_KEY changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_APP_SERVER_INSTANCE importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_TIER type /HEC1/T_ACT_UPDATE_TIER changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_APP_SERV_PERF_CAT importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_APP_SERV_PC type /HEC1/T_ACT_UPDATE_APP_SERV_PC !ET_ACT_PARAM_APP_NODE type /BOBF/T_FRW_KEY changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_APP_STORAGE_AMOUNT importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_APP_STORAGE type /BOBF/T_FRW_KEY !ET_ACT_PARAM_APP_STORAGE_QTY type /HEC1/T_ACT_UPDATE_APP_STRGQTY !ET_ACT_PARAM_APP_SERV_PC type /HEC1/T_ACT_UPDATE_APP_SERV_PC changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_APP_STORAGE_BACKUP importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_APP_STORAGE type /BOBF/T_FRW_KEY !ET_ACT_PARAM_APP_BACKUP type /HEC1/T_ACT_UPDATE_APP_BACKUP changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_CONNECTIVITY importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_DATACENTER importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_DB_SERVER_INSTANCE importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_TIER type /HEC1/T_ACT_UPDATE_TIER changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_DB_SERV_PERF_CAT importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_DB_SERV_PC type /HEC1/T_ACT_UPDATE_DB_SERV_PC !ET_ACT_PARAM_DB_NODE type /BOBF/T_FRW_KEY changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_DB_STORAGE_AMOUNT importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_DB_STORAGE_QTY type /HEC1/T_ACT_UPDATE_DB_STRG_QTY !ET_ACT_PARAM_DB_STORAGE type /BOBF/T_FRW_KEY !ET_ACT_PARAM_DB_SERV_PC type /HEC1/T_ACT_UPDATE_DB_SERV_PC changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_DB_STORAGE_BACKUP importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_DB_STORAGE type /BOBF/T_FRW_KEY !ET_ACT_PARAM_DB_BACKUP type /HEC1/T_ACT_UPDATE_APP_BACKUP changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_INSTANCE_DB importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_TIER type /HEC1/T_ACT_UPDATE_TIER changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_NETWORK_SEGMENT importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_PHASE importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_PHASE type /HEC1/T_ACT_UPDATE_PHASE changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_SOLUTION importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods DELETE_TIER importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY !IS_PARAMETERS type /HEC1/S_ACT_DELETE_NODE exporting !ET_ACT_PARAM_SOLUTION type /BOBF/T_FRW_KEY changing !CT_MODIFICATION type /BOBF/T_FRW_MODIFICATION . class-methods GET_CONTACT_NODES importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY returning value(RT_CONTACT_REFERENCE) type /HEC1/T_DATA_CONTACT_REF_CT . class-methods GET_MULTITENANCY_NODES importing !IO_READ type ref to /BOBF/IF_FRW_READ !IT_ROOT_KEY type /BOBF/T_FRW_KEY exporting !ET_SOLUTION type /HEC1/T_DATA_SOLUTION_CT !ET_TIER type /HEC1/T_DATA_TIER_CT !ET_DB_SERVER_INSTANCE type /HEC1/T_DATA_DB_SERVER_INST_CT !ET_INSTANCE_DB type /HEC1/T_DATA_DB_INST_CT . ENDCLASS. CLASS /HEC1/CL_CONFIG_ACT_DEL_HELPER IMPLEMENTATION. METHOD /hec1/if_bopf_act_del_helper~delete_helper. DATA: lt_modification TYPE /bobf/t_frw_modification, lt_root TYPE /hec1/t_config_root_ct, lr_act_param_phase TYPE REF TO data, lr_act_param_tier TYPE REF TO data, lr_act_param_db_serv_pc TYPE REF TO data, lr_act_param_db_storage_qty TYPE REF TO data, lr_act_param_db_backup TYPE REF TO data, lr_act_param_app_serv_pc TYPE REF TO data, lr_act_param_app_storage_qty TYPE REF TO data, lr_act_param_app_backup TYPE REF TO data. FIELD-SYMBOLS: TYPE /hec1/s_act_delete_node. "" *************************************************************************** "" Process "" 1) check for generated phases and add those to the delete table "" 2) get data specific to the node "" 3) run specific node logic "" *************************************************************************** ASSIGN is_parameters->* TO . DATA(lv_node) = /hec1/cl_config_utilities=>get_node_key_by_object_type( iv_object_type = -node ). "" Check for generated phases. Those phases need to be deleted with the objects "" Those objects are added to the modification table lt_modification = /hec1/cl_config_helper=>delete_generated_phases( iv_node_key = is_ctx-node_key it_key = it_key io_read = io_read it_param_child_list = VALUE #( ( CORRESPONDING #( ) ) ) ). io_read->get_root_key( EXPORTING iv_node = is_ctx-node_key it_key = it_key IMPORTING et_target_key = DATA(lt_root_key) ). CASE lv_node. WHEN /hec1/if_configuration_c=>sc_node-phase. delete_phase( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_phase = DATA(lt_act_param_phase) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-datacenter. delete_datacenter( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-network_segment. delete_network_segment( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-connectivity. delete_connectivity( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-add_service. delete_additional_service( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_solution = DATA(lt_act_param_solution) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-solution. delete_solution( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-tier. delete_tier( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_solution = lt_act_param_solution CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-db_server_instance. delete_db_server_instance( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_tier = DATA(lt_act_param_tier) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-instance_db. delete_instance_db( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_tier = lt_act_param_tier CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-db_server_perform_cat. delete_db_serv_perf_cat( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_db_node = DATA(lt_act_param_db_node) et_act_param_db_serv_pc = DATA(lt_act_param_db_serv_pc) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-db_storage_amount. delete_db_storage_amount( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_db_serv_pc = lt_act_param_db_serv_pc et_act_param_db_storage_qty = DATA(lt_act_param_db_storage_qty) et_act_param_db_storage = DATA(lt_act_param_db_storage) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-db_storage_backup. delete_db_storage_backup( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_db_storage = lt_act_param_db_storage et_act_param_db_backup = DATA(lt_act_param_db_backup) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-app_server_instance. delete_app_server_instance( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_tier = lt_act_param_tier CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-app_server_perform_cat. delete_app_serv_perf_cat( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_app_node = DATA(lt_act_param_app_node) et_act_param_app_serv_pc = DATA(lt_act_param_app_serv_pc) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-app_storage_amount. delete_app_storage_amount( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_app_serv_pc = lt_act_param_app_serv_pc et_act_param_app_storage_qty = DATA(lt_act_param_app_storage_qty) et_act_param_app_storage = DATA(lt_act_param_app_storage) CHANGING ct_modification = lt_modification ). WHEN /hec1/if_configuration_c=>sc_node-app_storage_backup. delete_app_storage_backup( EXPORTING io_read = io_read it_root_key = lt_root_key is_parameters = IMPORTING et_act_param_app_storage = lt_act_param_app_storage et_act_param_app_backup = DATA(lt_act_param_app_backup) CHANGING ct_modification = lt_modification ). WHEN OTHERS. "" check if the selected node exists and if it can be deleted. io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = -key ) ) iv_fill_data = abap_false IMPORTING et_failed_key = DATA(lt_failed_key) ). IF lt_failed_key IS INITIAL. INSERT VALUE #( node = lv_node change_mode = /bobf/if_frw_c=>sc_modify_delete key = -key ) INTO TABLE lt_modification. ENDIF. ENDCASE. ""----------------------------------- "" Set Follow-Up to GENERAL - Phase ""----------------------------------- IF lt_act_param_phase IS NOT INITIAL. lr_act_param_phase = NEW /hec1/t_act_update_phase( lt_act_param_phase ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-phase ) it_key = CORRESPONDING #( lt_act_param_phase ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_phase ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_phase ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - Solution ""----------------------------------- IF lt_act_param_solution IS NOT INITIAL. /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-solution ) it_key = lt_act_param_solution iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_solution ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - Tier ""----------------------------------- IF lt_act_param_tier IS NOT INITIAL. lr_act_param_tier = NEW /hec1/t_act_update_tier( lt_act_param_tier ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-tier ) it_key = VALUE #( FOR param_tier IN lt_act_param_tier ( key = param_tier-key ) ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_tier ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_tier ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - DB Node ""----------------------------------- IF lt_act_param_db_node IS NOT INITIAL. /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-db_node ) it_key = lt_act_param_db_node iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_db_node ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - DB Serv PC ""----------------------------------- IF lt_act_param_db_serv_pc IS NOT INITIAL. lr_act_param_db_serv_pc = NEW /hec1/t_act_update_db_serv_pc( lt_act_param_db_serv_pc ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-db_server_perform_cat ) it_key = VALUE #( FOR db_spc IN lt_act_param_db_serv_pc ( key = db_spc-key ) ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_db_server_perf_cat ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_db_serv_pc ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - DB Storage Qty ""----------------------------------- IF lt_act_param_db_storage_qty IS NOT INITIAL. lr_act_param_db_storage_qty = NEW /hec1/t_act_update_db_strg_qty( lt_act_param_db_storage_qty ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-db_storage_amount ) it_key = VALUE #( FOR db_strg_qty IN lt_act_param_db_storage_qty ( key = db_strg_qty-key ) ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_db_storage_amount ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_db_storage_qty ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - DB Storage ""----------------------------------- IF lt_act_param_db_storage IS NOT INITIAL. /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-db_storage ) it_key = lt_act_param_db_storage iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_db_storage ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - DB Storage Backup ""----------------------------------- IF lt_act_param_db_backup IS NOT INITIAL. lr_act_param_db_backup = NEW /hec1/t_act_update_db_backup( lt_act_param_db_backup ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-db_storage_backup ) it_key = VALUE #( FOR db_backup IN lt_act_param_db_backup ( key = db_backup-key ) ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_db_storage_backup ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_db_backup ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - App Node ""----------------------------------- IF lt_act_param_app_node IS NOT INITIAL. /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-app_node ) it_key = lt_act_param_app_node iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_app_node ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - App Serv PC ""----------------------------------- IF lt_act_param_app_serv_pc IS NOT INITIAL. lr_act_param_app_serv_pc = NEW /hec1/t_act_update_app_serv_pc( lt_act_param_app_serv_pc ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-app_server_perform_cat ) it_key = VALUE #( FOR app_spc IN lt_act_param_app_serv_pc ( key = app_spc-key ) ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_app_server_perf_cat ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_app_serv_pc ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - App Storage Qty ""----------------------------------- IF lt_act_param_app_storage_qty IS NOT INITIAL. lr_act_param_app_storage_qty = NEW /hec1/t_act_update_app_strgqty( lt_act_param_app_storage_qty ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-app_storage_amount ) it_key = VALUE #( FOR app_strg_qty IN lt_act_param_app_storage_qty ( key = app_strg_qty-key ) ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_app_storage_amount ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_app_storage_qty ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - App Storage ""----------------------------------- IF lt_act_param_app_storage IS NOT INITIAL. /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-app_storage ) it_key = lt_act_param_app_storage iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_app_storage ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ). ENDIF. ""----------------------------------- "" Set Follow-Up to GENERAL - App Storage Backup ""----------------------------------- IF lt_act_param_app_backup IS NOT INITIAL. lr_act_param_app_backup = NEW /hec1/t_act_update_app_backup( lt_act_param_app_backup ). /hec1/cl_config_det_general=>/hec1/if_config_det_general~set_act_node_keys( is_ctx = VALUE #( BASE CORRESPONDING #( is_ctx ) node_key = /hec1/if_configuration_c=>sc_node-app_storage_backup ) it_key = VALUE #( FOR app_backup IN lt_act_param_app_backup ( key = app_backup-key ) ) iv_action = /hec1/cl_config_det_general=>/hec1/if_config_det_general~get_act_key( /hec1/if_config_constant=>gc_act_method-update_app_storage_backup ) iv_act_exectime = /bobf/if_conf_c=>sc_time_after_validation ir_act_param = lr_act_param_app_backup ). ENDIF. ""----------------------------------- "" Execute Modification ( = Delete) ""----------------------------------- IF lt_modification IS NOT INITIAL. io_modify->do_modify( lt_modification ). io_modify->end_modify( EXPORTING iv_process_immediately = abap_true IMPORTING eo_message = DATA(lo_message) eo_change = DATA(lo_change) ). ENDIF. "" ************************************************************************************************************************************************** "" Attention!!!!!! "" This is only a temporary solution, because this is "" a mix between UI logic and BOPF logic. Normally no "" UI logic has to be set into a BOPF object. But at "" the moment there is the problem, that the Application "" is not running with FBI, therefore we can't control "" the tree about the FBI feeder class "" Switch to FBI, this part can be deleted LOOP AT lt_modification INTO DATA(ls_modification). IF ls_modification-node = /hec1/if_configuration_c=>sc_node-phase. /hec1/cl_bopf_config_ui_tree_h=>get_instance( )->/hec1/if_bopf_config_ui_tree_h~delete( iv_tree_type = /hec1/if_config_constants=>gc_tree_type-phasing iv_node_key = ls_modification-key ). ELSE. /hec1/cl_bopf_config_ui_tree_h=>get_instance( )->/hec1/if_bopf_config_ui_tree_h~delete( iv_node_key = ls_modification-key ). ENDIF. ENDLOOP. CLEAR: , lt_modification, lt_root. ENDMETHOD. METHOD delete_additional_service. DATA: lt_solution TYPE /hec1/t_data_solution_ct, lt_tier TYPE /hec1/t_data_tier_ct, lt_add_service TYPE /hec1/t_data_add_services_ct, lt_tier_add_service TYPE /hec1/t_data_tier_add_serv_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-add_service. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_add_service ). "" Get Tier Services io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-root it_key = it_root_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-root-solution IMPORTING et_data = lt_solution et_target_key = DATA(lt_solution_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-solution it_key = lt_solution_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-solution-tier IMPORTING et_data = lt_tier et_target_key = DATA(lt_tier_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-tier it_key = lt_tier_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-tier-tier_add_service IMPORTING et_target_key = DATA(lt_tier_service_key) et_data = lt_tier_add_service ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_add_service) = lt_add_service[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-add_service change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_add_service-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Add corresponding tier services to delete list LOOP AT lt_tier_add_service INTO DATA(ls_tier_add_service) WHERE hec_tas_service_ref_guid = ls_add_service-hec_node_service. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-tier_add_service change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_tier_add_service-key ) INTO TABLE ct_modification. ENDLOOP. ENDMETHOD. METHOD delete_app_server_instance. DATA: lt_app_serv_inst TYPE /hec1/t_data_app_serv_inst_ct, lt_db_storage TYPE /hec1/t_data_db_storage_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-app_server_instance. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_app_serv_inst ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_app_serv_inst) = lt_app_serv_inst[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-app_server_instance change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_app_serv_inst-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Add Parent Node to Update List INSERT VALUE #( key = ls_app_serv_inst-parent_key do_update_qty = abap_true ) INTO TABLE et_act_param_tier. ENDMETHOD. METHOD delete_app_serv_perf_cat. DATA: lt_app_serv_pc TYPE /hec1/t_data_app_serv_pc_ct, lt_app_serv_pc_all TYPE /hec1/t_data_app_serv_pc_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-app_server_perform_cat. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_app_serv_pc ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_association = /hec1/if_configuration_c=>sc_association-app_server_perform_cat-to_parent IMPORTING et_target_key = DATA(lt_app_node_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-app_node it_key = lt_app_node_key iv_association = /hec1/if_configuration_c=>sc_association-app_node-app_server_perform_cat iv_fill_data = abap_true IMPORTING et_data = lt_app_serv_pc_all ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_app_serv_pc) = lt_app_serv_pc[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-app_server_perform_cat change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_app_serv_pc-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Add Parent Node to Update List INSERT VALUE #( key = ls_app_serv_pc-parent_key ) INTO TABLE et_act_param_app_node. "" the Phasing needs to be adjusted for the predecessor and ALL successors "" modify predecessor TRY. DATA(ls_app_serv_pc_pred) = lt_app_serv_pc_all[ key = ls_app_serv_pc-hec_predecessor_guid ]. INSERT VALUE #( key = ls_app_serv_pc_pred-key parent_key = ls_app_serv_pc_pred-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_app_serv_pc. CATCH cx_sy_itab_line_not_found. ENDTRY. DATA(ls_app_serv_pc_succ) = ls_app_serv_pc. "" modify successors TRY. DO. ls_app_serv_pc_succ = lt_app_serv_pc_all[ key = ls_app_serv_pc_succ-hec_successor_guid ]. INSERT VALUE #( key = ls_app_serv_pc_succ-key parent_key = ls_app_serv_pc_succ-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_app_serv_pc. ENDDO. CATCH cx_sy_itab_line_not_found. ENDTRY. ENDMETHOD. METHOD delete_app_storage_amount. DATA: lt_app_storage_qty TYPE /hec1/t_data_app_storageqty_ct, lt_app_storage_qty_all TYPE /hec1/t_data_app_storageqty_ct, lt_app_serv_pc TYPE /hec1/t_data_app_serv_pc_ct, lt_app_serv_pc_all TYPE /hec1/t_data_app_serv_pc_ct, lt_app_storage TYPE /hec1/t_data_app_storage_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-app_storage_amount. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_app_storage_qty ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-app_storage_amount-to_parent IMPORTING et_target_key = DATA(lt_app_serv_pc_key) et_data = lt_app_serv_pc ). "" Get all storage amounts io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-app_server_perform_cat it_key = lt_app_serv_pc_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-app_server_perform_cat-app_storage_amount IMPORTING et_data = lt_app_storage_qty_all ). "" Get server io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-app_server_perform_cat it_key = lt_app_serv_pc_key iv_association = /hec1/if_configuration_c=>sc_association-app_server_perform_cat-app_server IMPORTING et_target_key = DATA(lt_app_server_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-app_server it_key = lt_app_server_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-app_server-app_storage IMPORTING et_data = lt_app_storage ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_app_storage_qty) = lt_app_storage_qty[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-app_storage_amount change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_app_storage_qty-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Get corresponding storage node LOOP AT lt_app_storage INTO DATA(ls_app_storage). "" add to general parameters IF ls_app_storage-hec_storage_qty_ref_guid = ls_app_storage_qty-hec_node_app_storage_qty. ""Add Storage to delete table INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-app_storage change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_app_storage-key ) INTO TABLE ct_modification. ELSE. INSERT VALUE #( key = ls_app_storage-key ) INTO TABLE et_act_param_app_storage. ENDIF. ENDLOOP. "" Add Parent Node to Update List TRY. DATA(ls_app_serv_pc) = lt_app_serv_pc[ key = ls_app_storage_qty-parent_key ]. INSERT VALUE #( key = ls_app_serv_pc-key parent_key = ls_app_serv_pc-parent_key do_update_storage_qty = abap_true ) INTO TABLE et_act_param_app_serv_pc. CATCH cx_sy_itab_line_not_found. ENDTRY. "" the Phasing needs to be adjusted for the predecessor and ALL successors "" modify predecessor TRY. DATA(ls_app_storage_qty_pred) = lt_app_storage_qty_all[ key = ls_app_storage_qty-hec_predecessor_guid ]. INSERT VALUE #( key = ls_app_storage_qty_pred-key parent_key = ls_app_storage_qty_pred-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_app_storage_qty. CATCH cx_sy_itab_line_not_found. ENDTRY. DATA(ls_app_storage_qty_succ) = ls_app_storage_qty. "" modify successors TRY. DO. ls_app_storage_qty_succ = lt_app_storage_qty_all[ key = ls_app_storage_qty_succ-hec_successor_guid ]. INSERT VALUE #( key = ls_app_storage_qty_succ-key parent_key = ls_app_storage_qty_succ-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_app_storage_qty. ENDDO. CATCH cx_sy_itab_line_not_found. ENDTRY. ENDMETHOD. METHOD delete_app_storage_backup. DATA: lt_app_backup TYPE /hec1/t_data_app_backup_ct, lt_app_backup_all TYPE /hec1/t_data_app_backup_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-app_storage_backup. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_app_backup ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_association = /hec1/if_configuration_c=>sc_association-app_storage_backup-to_parent IMPORTING et_target_key = DATA(lt_app_storage_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-app_storage it_key = lt_app_storage_key iv_association = /hec1/if_configuration_c=>sc_association-app_storage-app_storage_backup iv_fill_data = abap_true IMPORTING et_data = lt_app_backup_all ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_app_backup) = lt_app_backup[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-app_storage_backup change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_app_backup-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Add Parent Node to Update List INSERT VALUE #( key = ls_app_backup-parent_key ) INTO TABLE et_act_param_app_storage. "" the Phasing needs to be adjusted for the predecessor and ALL successors "" modify predecessor TRY. DATA(ls_app_backup_pred) = lt_app_backup_all[ key = ls_app_backup-hec_predecessor_guid ]. INSERT VALUE #( key = ls_app_backup_pred-key parent_key = ls_app_backup_pred-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_app_backup. CATCH cx_sy_itab_line_not_found. ENDTRY. DATA(ls_app_backup_succ) = ls_app_backup. "" modify successors TRY. DO. ls_app_backup_succ = lt_app_backup_all[ key = ls_app_backup_succ-hec_successor_guid ]. INSERT VALUE #( key = ls_app_backup_succ-key parent_key = ls_app_backup_succ-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_app_backup. ENDDO. CATCH cx_sy_itab_line_not_found. ENDTRY. ENDMETHOD. METHOD delete_connectivity. DATA: lt_connectivity TYPE /hec1/t_data_connectivity_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-connectivity. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_connectivity ). "" Get Contacts DATA(lt_contact_reference) = get_contact_nodes( io_read = io_read it_root_key = it_root_key ). "" Run Delete Logic LOOP AT VALUE /bobf/t_frw_key( FOR conn IN lt_connectivity FOR cont_ref IN lt_contact_reference WHERE ( hec_contact_ref_node_key = conn-hec_node_connectivity ) ( key = cont_ref-key ) ) INTO DATA(ls_key). INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-contact_reference change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_key-key ) INTO TABLE ct_modification. ENDLOOP. "" add the current selection to delete io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_false IMPORTING et_failed_key = DATA(lt_failed_key) ). IF lt_failed_key IS INITIAL. INSERT VALUE #( node = lv_node change_mode = /bobf/if_frw_c=>sc_modify_delete key = is_parameters-key ) INTO TABLE ct_modification. ENDIF. ENDMETHOD. METHOD delete_datacenter. DATA: lt_datacenter TYPE /hec1/t_data_datacenter_ct, lt_inf_baseline TYPE /hec1/t_data_if_baseline_ct, lt_network_segment TYPE /hec1/t_data_network_segm_ct, lt_connectivity TYPE /hec1/t_data_connectivity_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-datacenter. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_datacenter ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_association = /hec1/if_configuration_c=>sc_association-datacenter-infrastructure_baseline IMPORTING et_target_key = DATA(lt_if_baseline_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-infrastructure_baseline it_key = lt_if_baseline_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-infrastructure_baseline-network_segment IMPORTING et_data = lt_network_segment ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-datacenter-connectivity IMPORTING et_data = lt_connectivity ). "" Get Contacts DATA(lt_contact_reference) = get_contact_nodes( io_read = io_read it_root_key = it_root_key ). "" Run Delete Logic LOOP AT VALUE /bobf/t_frw_key( FOR conn IN lt_connectivity FOR cont_ref IN lt_contact_reference WHERE ( hec_contact_ref_node_key = conn-hec_node_connectivity ) ( key = cont_ref-key ) ) INTO DATA(ls_key). INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-contact_reference change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_key-key ) INTO TABLE ct_modification. ENDLOOP. LOOP AT VALUE /bobf/t_frw_key( FOR nw_segm IN lt_network_segment FOR cont_ref IN lt_contact_reference WHERE ( hec_contact_ref_node_key = nw_segm-hec_node_network_segment ) ( key = cont_ref-key ) ) INTO ls_key. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-contact_reference change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_key-key ) INTO TABLE ct_modification. ENDLOOP. "" add the current selection to delete io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_false IMPORTING et_failed_key = DATA(lt_failed_key) ). IF lt_failed_key IS INITIAL. INSERT VALUE #( node = lv_node change_mode = /bobf/if_frw_c=>sc_modify_delete key = is_parameters-key ) INTO TABLE ct_modification. ENDIF. CLEAR: lt_datacenter, lt_contact_reference, lt_connectivity, lt_inf_baseline, lt_network_segment. ENDMETHOD. METHOD delete_db_server_instance. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-db_server_instance. "" Get Data "" Get Multitenancy nodes get_multitenancy_nodes( EXPORTING io_read = io_read it_root_key = it_root_key IMPORTING et_solution = DATA(lt_solution_all) et_tier = DATA(lt_tier_all) et_db_server_instance = DATA(lt_db_serv_inst_all) et_instance_db = DATA(lt_inst_db_all) ). "" Get Contacts DATA(lt_contact_reference) = get_contact_nodes( io_read = io_read it_root_key = it_root_key ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_db_serv_inst) = lt_db_serv_inst_all[ key = is_parameters-key ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-db_server_instance change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_db_serv_inst-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Add Parent Node to Update List INSERT VALUE #( key = ls_db_serv_inst-parent_key do_update_qty = abap_true ) INTO TABLE et_act_param_tier. "" TODO: Multitenancy ENDMETHOD. METHOD delete_db_serv_perf_cat. DATA: lt_db_serv_pc TYPE /hec1/t_data_db_serv_pc_ct, lt_db_serv_pc_all TYPE /hec1/t_data_db_serv_pc_ct, lt_db_node TYPE /hec1/t_data_db_node_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-db_server_perform_cat. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_db_serv_pc ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_association = /hec1/if_configuration_c=>sc_association-db_server_perform_cat-to_parent IMPORTING et_target_key = DATA(lt_db_node_key) et_data = lt_db_node ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-db_node it_key = lt_db_node_key iv_association = /hec1/if_configuration_c=>sc_association-db_node-db_server_perform_cat iv_fill_data = abap_true IMPORTING et_data = lt_db_serv_pc_all ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_db_serv_pc) = lt_db_serv_pc[ key = is_parameters-key ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-db_server_perform_cat change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_db_serv_pc-key ) INTO TABLE ct_modification. "" Add Parent Node to Update List INSERT VALUE #( key = ls_db_serv_pc-parent_key ) INTO TABLE et_act_param_db_node. "" ******************************** "" Adjust Phasing "" ******************************** "" the Phasing needs to be cleared for the predecessor and ALL successors "" modify predecessor TRY. DATA(ls_db_serv_pc_pred) = lt_db_serv_pc_all[ key = ls_db_serv_pc-hec_predecessor_guid ]. INSERT VALUE #( key = ls_db_serv_pc_pred-key parent_key = ls_db_serv_pc_pred-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_db_serv_pc. CATCH cx_sy_itab_line_not_found. ENDTRY. DATA(ls_db_serv_pc_succ) = ls_db_serv_pc. "" modify successors TRY. DO. ls_db_serv_pc_succ = lt_db_serv_pc_all[ key = ls_db_serv_pc_succ-hec_successor_guid ]. INSERT VALUE #( key = ls_db_serv_pc_succ-key parent_key = ls_db_serv_pc_succ-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_db_serv_pc. ENDDO. CATCH cx_sy_itab_line_not_found. ENDTRY. CATCH cx_sy_itab_line_not_found. ENDTRY. ENDMETHOD. METHOD delete_db_storage_amount. DATA: lt_db_serv_pc TYPE /hec1/t_data_db_serv_pc_ct, lt_db_serv_pc_all TYPE /hec1/t_data_db_serv_pc_ct, lt_db_storage_qty TYPE /hec1/t_data_db_storage_qty_ct, lt_db_storage_qty_all TYPE /hec1/t_data_db_storage_qty_ct, lt_db_storage TYPE /hec1/t_data_db_storage_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-db_storage_amount. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_db_storage_qty ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-db_storage_amount-to_parent IMPORTING et_target_key = DATA(lt_db_serv_pc_key) et_data = lt_db_serv_pc ). "" Get all storage amounts io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-db_server_perform_cat it_key = lt_db_serv_pc_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-db_server_perform_cat-db_storage_amount IMPORTING et_data = lt_db_storage_qty_all ). "" Get Server io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-db_server_perform_cat it_key = lt_db_serv_pc_key iv_association = /hec1/if_configuration_c=>sc_association-db_server_perform_cat-db_server IMPORTING et_target_key = DATA(lt_db_server_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-db_server it_key = lt_db_server_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-db_server-db_storage IMPORTING et_data = lt_db_storage ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_db_storage_qty) = lt_db_storage_qty[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-db_storage_amount change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_db_storage_qty-key ) INTO TABLE ct_modification. "" Get corresponding storage node LOOP AT lt_db_storage INTO DATA(ls_db_storage). "" add to general parameters IF ls_db_storage-hec_storage_qty_ref_guid = ls_db_storage_qty-hec_node_db_storage_qty. ""Add Storage to delete table INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-app_storage change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_db_storage-key ) INTO TABLE ct_modification. ELSE. INSERT VALUE #( key = ls_db_storage-key ) INTO TABLE et_act_param_db_storage. ENDIF. ENDLOOP. "" Add Parent Node to Update List TRY. DATA(ls_db_serv_pc) = lt_db_serv_pc[ key = ls_db_storage_qty-parent_key ]. INSERT VALUE #( key = ls_db_serv_pc-key parent_key = ls_db_serv_pc-parent_key do_update_storage_qty = abap_true ) INTO TABLE et_act_param_db_serv_pc. CATCH cx_sy_itab_line_not_found. ENDTRY. "" the Phasing needs to be adjusted for the predecessor and ALL successors "" modify predecessor TRY. DATA(ls_db_storage_qty_pred) = lt_db_storage_qty_all[ key = ls_db_storage_qty-hec_predecessor_guid ]. INSERT VALUE #( key = ls_db_storage_qty_pred-key parent_key = ls_db_storage_qty_pred-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_db_storage_qty. CATCH cx_sy_itab_line_not_found. ENDTRY. DATA(ls_db_storage_qty_succ) = ls_db_storage_qty. "" modify successors TRY. DO. ls_db_storage_qty_succ = lt_db_storage_qty_all[ key = ls_db_storage_qty_succ-hec_successor_guid ]. INSERT VALUE #( key = ls_db_storage_qty_succ-key parent_key = ls_db_storage_qty_succ-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_db_storage_qty. ENDDO. CATCH cx_sy_itab_line_not_found. ENDTRY. CATCH cx_sy_itab_line_not_found. ENDTRY. ENDMETHOD. METHOD delete_db_storage_backup. DATA: lt_db_backup TYPE /hec1/t_data_db_backup_ct, lt_db_backup_all TYPE /hec1/t_data_db_backup_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-db_storage_backup. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_db_backup ). io_read->retrieve_by_association( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_association = /hec1/if_configuration_c=>sc_association-db_storage_backup-to_parent IMPORTING et_target_key = DATA(lt_db_storage_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-db_storage it_key = lt_db_storage_key iv_association = /hec1/if_configuration_c=>sc_association-db_storage-db_storage_backup iv_fill_data = abap_true IMPORTING et_data = lt_db_backup_all ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_db_backup) = lt_db_backup[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-db_storage_backup change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_db_backup-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Add Parent Node to Update List INSERT VALUE #( key = ls_db_backup-parent_key ) INTO TABLE et_act_param_db_storage. "" the Phasing needs to be adjusted for the predecessor and ALL successors "" modify predecessor TRY. DATA(ls_db_backup_pred) = lt_db_backup_all[ key = ls_db_backup-hec_predecessor_guid ]. INSERT VALUE #( key = ls_db_backup_pred-key parent_key = ls_db_backup_pred-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_db_backup. CATCH cx_sy_itab_line_not_found. ENDTRY. DATA(ls_db_backup_succ) = ls_db_backup. "" modify successors TRY. DO. ls_db_backup_succ = lt_db_backup_all[ key = ls_db_backup_succ-hec_successor_guid ]. INSERT VALUE #( key = ls_db_backup_succ-key parent_key = ls_db_backup_succ-parent_key do_clear_phasing = abap_true ) INTO TABLE et_act_param_db_backup. ENDDO. CATCH cx_sy_itab_line_not_found. ENDTRY. ENDMETHOD. METHOD delete_instance_db. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-instance_db. "" Get Data "" Get Multitenancy nodes get_multitenancy_nodes( EXPORTING io_read = io_read it_root_key = it_root_key IMPORTING et_solution = DATA(lt_solution_all) et_tier = DATA(lt_tier_all) et_db_server_instance = DATA(lt_db_serv_inst_all) et_instance_db = DATA(lt_inst_db_all) ). "" Get Contacts DATA(lt_contact_reference) = get_contact_nodes( io_read = io_read it_root_key = it_root_key ). "" Run Delete Logic "" Add Node to Delete List TRY. DATA(ls_instance_db) = lt_inst_db_all[ 1 ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-instance_db change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_instance_db-key ) INTO TABLE ct_modification. CATCH cx_sy_itab_line_not_found. ENDTRY. "" TODO Multitenancy ENDMETHOD. METHOD delete_network_segment. DATA: lt_network_segment TYPE /hec1/t_data_network_segm_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-network_segment. "" Get Data io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) IMPORTING et_data = lt_network_segment ). "" Get Contacts DATA(lt_contact_reference) = get_contact_nodes( io_read = io_read it_root_key = it_root_key ). "" Run Delete Logic LOOP AT VALUE /bobf/t_frw_key( FOR nw_segm IN lt_network_segment FOR cont_ref IN lt_contact_reference WHERE ( hec_contact_ref_node_key = nw_segm-hec_node_network_segment ) ( key = cont_ref-key ) ) INTO DATA(ls_key). INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-contact_reference change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_key-key ) INTO TABLE ct_modification. ENDLOOP. "" add the current selection to delete io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_false IMPORTING et_failed_key = DATA(lt_failed_key) ). IF lt_failed_key IS INITIAL. INSERT VALUE #( node = lv_node change_mode = /bobf/if_frw_c=>sc_modify_delete key = is_parameters-key ) INTO TABLE ct_modification. ENDIF. ENDMETHOD. METHOD delete_phase. DATA: lt_phase TYPE /hec1/t_data_phase_ct. io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-root it_key = it_root_key iv_association = /hec1/if_configuration_c=>sc_association-root-phase iv_fill_data = abap_true IMPORTING et_data = lt_phase ). TRY. DATA(ls_phase) = lt_phase[ key = is_parameters-key ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-phase change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_phase-key ) INTO TABLE ct_modification. IF ls_phase-hec_phase_predecessor_guid IS NOT INITIAL. "" Add Predecessor Phase to Update List INSERT VALUE #( key = lt_phase[ key = ls_phase-hec_phase_predecessor_guid ]-key do_clear_phasing = abap_true ) INTO TABLE et_act_param_phase. ENDIF. IF ls_phase-hec_phase_successor_guid IS NOT INITIAL. DO. ls_phase = lt_phase[ key = ls_phase-hec_phase_successor_guid ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-phase change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_phase-key ) INTO TABLE ct_modification. ENDDO. ENDIF. CATCH cx_sy_itab_line_not_found. ENDTRY. CLEAR: lt_phase, ls_phase. ENDMETHOD. METHOD delete_solution. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-solution. "" Get Data "" Get Multitenancy nodes get_multitenancy_nodes( EXPORTING io_read = io_read it_root_key = it_root_key IMPORTING et_solution = DATA(lt_solution_all) et_tier = DATA(lt_tier_all) et_db_server_instance = DATA(lt_db_serv_inst_all) et_instance_db = DATA(lt_inst_db_all) ). "" Get Contacts DATA(lt_contact_reference) = get_contact_nodes( io_read = io_read it_root_key = it_root_key ). "" Run Delete Logic "" add tier-contacts to delete list "" Tier-Contacts are not located under the tier, but only contain a reference to the tier!! LOOP AT VALUE /bobf/t_frw_key( FOR tier IN lt_tier_all WHERE ( parent_key = is_parameters-key ) FOR cont_ref IN lt_contact_reference WHERE ( hec_contact_ref_node_key = tier-hec_node_tier ) ( key = cont_ref-key ) ) INTO DATA(ls_key). INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-contact_reference change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_key-key ) INTO TABLE ct_modification. ENDLOOP. "" add the current selection to delete io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_false IMPORTING et_failed_key = DATA(lt_failed_key) ). IF lt_failed_key IS INITIAL. INSERT VALUE #( node = lv_node change_mode = /bobf/if_frw_c=>sc_modify_delete key = is_parameters-key ) INTO TABLE ct_modification. ENDIF. ENDMETHOD. METHOD delete_tier. DATA: lt_connectivity TYPE /hec1/t_data_connectivity_ct. DATA(lv_node) = /hec1/if_configuration_c=>sc_node-tier. "" Get Data "" Get Multitenancy nodes get_multitenancy_nodes( EXPORTING io_read = io_read it_root_key = it_root_key IMPORTING et_solution = DATA(lt_solution_all) et_tier = DATA(lt_tier_all) et_db_server_instance = DATA(lt_db_serv_inst_all) et_instance_db = DATA(lt_inst_db_all) ). "" Get Contacts DATA(lt_contact_reference) = get_contact_nodes( io_read = io_read it_root_key = it_root_key ). "" Run Delete Logic "" add tier-contacts to delete list "" Tier-Contacts are not located under the tier, but only contain a reference to the tier!! LOOP AT VALUE /bobf/t_frw_key( FOR tier IN lt_tier_all WHERE ( key = is_parameters-key ) FOR cont_ref IN lt_contact_reference WHERE ( hec_contact_ref_node_key = tier-hec_node_tier ) ( key = cont_ref-key ) ) INTO DATA(ls_key). INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-contact_reference change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_key-key ) INTO TABLE ct_modification. ENDLOOP. "" Get node that needs to be deleted TRY. DATA(ls_tier) = lt_tier_all[ key = is_parameters-key ]. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-tier change_mode = /bobf/if_frw_c=>sc_modify_delete key = ls_tier-key ) INTO TABLE ct_modification. "" 1. Delete Related Tier IF ls_tier-hec_related_stack_guid IS NOT INITIAL. io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-solution it_key = VALUE #( ( key = ls_tier-parent_key ) ) iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-solution-tier IMPORTING et_data = lt_tier_all ). LOOP AT lt_tier_all ASSIGNING FIELD-SYMBOL() WHERE hec_related_stack_guid = ls_tier-hec_related_stack_guid. INSERT VALUE #( node = /hec1/if_configuration_c=>sc_node-tier change_mode = /bobf/if_frw_c=>sc_modify_delete key = -key ) INTO TABLE ct_modification. ENDLOOP. ENDIF. ""related stack guid not initial. CATCH cx_sy_itab_line_not_found. ENDTRY. "" Add Parent Node to Update List INSERT VALUE #( key = ls_tier-parent_key ) INTO TABLE et_act_param_solution. "" add the current selection to delete io_read->retrieve( EXPORTING iv_node = lv_node it_key = VALUE #( ( key = is_parameters-key ) ) iv_fill_data = abap_false IMPORTING et_failed_key = data(lt_failed_key) ). IF lt_failed_key IS INITIAL. INSERT VALUE #( node = lv_node change_mode = /bobf/if_frw_c=>sc_modify_delete key = is_parameters-key ) INTO TABLE ct_modification. ENDIF. ENDMETHOD. METHOD get_contact_nodes. io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-root it_key = it_root_key iv_association = /hec1/if_configuration_c=>sc_association-root-contact IMPORTING et_target_key = DATA(lt_contact_key) ). io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-contact it_key = lt_contact_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-contact-contact_reference IMPORTING et_data = rt_contact_reference ). ENDMETHOD. METHOD get_multitenancy_nodes. ""all solutions (needed for multitenancy) io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-root it_key = it_root_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-root-solution IMPORTING et_data = et_solution et_target_key = DATA(lt_solution_key) ). ""all tiers io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-solution it_key = lt_solution_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-solution-tier IMPORTING et_data = et_tier et_target_key = DATA(lt_tier_key) ). ""all DB Server Instance io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-tier it_key = lt_tier_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-tier-db_server_instance IMPORTING et_data = et_db_server_instance et_target_key = DATA(lt_db_si_key) ). ""all Instance DBs io_read->retrieve_by_association( EXPORTING iv_node = /hec1/if_configuration_c=>sc_node-db_server_instance it_key = lt_db_si_key iv_fill_data = abap_true iv_association = /hec1/if_configuration_c=>sc_association-db_server_instance-instance_db IMPORTING et_data = et_instance_db ). ENDMETHOD. ENDCLASS. ",16260,True,3341.170703236657,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 zif_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 sy-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. METHODS get_program_title IMPORTING !it_tpool TYPE textpool_table RETURNING VALUE(rv_title) TYPE repti . METHODS insert_program IMPORTING !is_progdir TYPE ty_progdir !it_source TYPE abaptxt255_tab !iv_title TYPE repti !iv_package TYPE devclass RAISING zcx_abapgit_exception . METHODS update_program IMPORTING !is_progdir TYPE ty_progdir !it_source TYPE abaptxt255_tab !iv_title TYPE repti RAISING zcx_abapgit_exception . METHODS update_progdir IMPORTING !is_progdir TYPE ty_progdir RAISING zcx_abapgit_exception . METHODS insert_tpool IMPORTING !is_progdir TYPE ty_progdir !it_tpool TYPE textpool_table RAISING zcx_abapgit_exception . 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/abapGit/abapGit/issues/562 zcx_abapgit_exception=>raise_t100( ). ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'CUAD' iv_name = iv_program_name ). ENDMETHOD. METHOD deserialize_dynpros. CONSTANTS lc_rpyty_force_off TYPE c LENGTH 1 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_progname TYPE reposrc-progname, lv_title TYPE rglif-title. 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 <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. lv_title = get_program_title( it_tpool ). "" Check if program already exists SELECT SINGLE progname FROM reposrc INTO lv_progname WHERE progname = is_progdir-name AND r3state = 'A'. IF sy-subrc = 0. update_program( is_progdir = is_progdir it_source = it_source iv_title = lv_title ). ELSE. insert_program( is_progdir = is_progdir it_source = it_source iv_title = lv_title iv_package = iv_package ). ENDIF. insert_tpool( is_progdir = is_progdir it_tpool = it_tpool ). update_progdir( is_progdir ). zcl_abapgit_objects_activation=>add( iv_type = 'REPS' iv_name = is_progdir-name ). ENDMETHOD. METHOD deserialize_textpool. DATA lv_language TYPE sy-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 main 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 ""main 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 main 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 main language needs to be activated zcl_abapgit_objects_activation=>add( iv_type = 'REPT' iv_name = iv_program iv_delete = lv_delete ). ENDIF. ENDMETHOD. METHOD get_program_title. DATA ls_tpool LIKE LINE OF it_tpool. FIELD-SYMBOLS TYPE any. 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. rv_title = ls_tpool-entry. ENDIF. ENDMETHOD. METHOD insert_program. CALL FUNCTION 'RPY_PROGRAM_INSERT' EXPORTING development_class = iv_package program_name = is_progdir-name program_type = is_progdir-subc title_string = iv_title save_inactive = 'I' suppress_dialog = abap_true TABLES source_extended = it_source EXCEPTIONS already_exists = 1 cancelled = 2 name_not_allowed = 3 permission_error = 4 OTHERS = 5. IF sy-subrc = 3. "" For cases that standard function does not handle (like FUGR), "" we save active and inactive version of source with the given PROGRAM TYPE. "" Without the active version, the code will not be visible in case of activation errors. INSERT REPORT is_progdir-name FROM it_source STATE 'A' PROGRAM TYPE is_progdir-subc. 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 .. PROGRAM TYPE' ). ENDIF. ELSEIF sy-subrc > 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD insert_tpool. 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. 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_t100( ). 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_t100( ). 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_t100( ). 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. IF -from_dict = abap_true AND -modific <> 'F'. CLEAR -text. 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, li_xml TYPE REF TO zif_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_t100( ). ENDIF. zcl_abapgit_language=>restore_login_language( ). ls_progdir = read_progdir( lv_program_name ). IF io_xml IS BOUND. li_xml = io_xml. ELSE. CREATE OBJECT li_xml TYPE zcl_abapgit_xml_output. ENDIF. li_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 ). li_xml->add( iv_name = 'DYNPROS' ig_data = lt_dynpros ). ls_cua = serialize_cua( lv_program_name ). IF NOT ls_cua IS INITIAL. li_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. li_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 ii_xml = li_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. METHOD update_progdir. DATA ls_progdir_new TYPE progdir. 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( 'Error reading program directory' ). ENDIF. 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. ls_progdir_new-clas = is_progdir-clas. 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( 'Error updating program directory' ). ENDIF. "" function UPDATE_PROGDIR does not update VARCL, so we do it here 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 <> ls_progdir_new-varcl. UPDATE progdir SET varcl = is_progdir-varcl WHERE name = ls_progdir_new-name AND state = ls_progdir_new-state. ""#EC CI_SUBRC ENDIF. ENDMETHOD. METHOD update_program. zcl_abapgit_language=>set_current_language( mv_language ). CALL FUNCTION 'RPY_PROGRAM_UPDATE' EXPORTING program_name = is_progdir-name title_string = iv_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_t100( ). ENDIF. ENDIF. zcl_abapgit_language=>restore_login_language( ). ENDMETHOD. ENDCLASS. ",8439,False,1668.9504235271147,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: condense_flow EXPORTING et_spaces TYPE ty_spaces_tt CHANGING ct_flow TYPE swydyflow, 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 zcl_abapgit_objects_program=>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 condense_flow. DATA: lv_spaces LIKE LINE OF et_spaces. FIELD-SYMBOLS: LIKE LINE OF ct_flow. CLEAR et_spaces. LOOP AT ct_flow ASSIGNING . lv_spaces = 0. WHILE NOT -line IS INITIAL AND -line(1) = space. lv_spaces = lv_spaces + 1. -line = -line+1. ENDWHILE. APPEND lv_spaces TO et_spaces. 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. 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' ). 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. 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 iv_program ""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 zcl_abapgit_objects_program=>ty_dynpro_tt, lv_object TYPE seqg3-garg. FIELD-SYMBOLS: TYPE zcl_abapgit_objects_program=>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. condense_flow( IMPORTING et_spaces = -spaces CHANGING ct_flow = lt_flow_logic ). -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_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. ",8185,False,1671.0986351943075,median "TYPES: BEGIN OF t_input, row TYPE string, END OF t_input. * Input declaration DATA: lv_input TYPE TABLE OF t_input, wa_input LIKE LINE OF lv_input. * Assign with the puzzle input. lv_input = VALUE #( ( row = '33' ) ( row = '18' ) ( row = '22' ) ( row = '44' ) ( row = '49' ) ( row = '15' ) ( row = '12' ) ( row = '38' ) ( row = '41' ) ( row = '46' ) ( row = '3' ) ( row = '42' ) ( row = '37' ) ( row = '19' ) ( row = '13' ) ( row = '7' ) ( row = '21' ) ( row = '29' ) ( row = '34' ) ( row = '40' ) ( row = '39' ) ( row = '35' ) ( row = '27' ) ( row = '25' ) ( row = '48' ) ( row = '87' ) ( row = '10' ) ( row = '16' ) ( row = '17' ) ( row = '45' ) ( row = '18' ) ( row = '30' ) ( row = '20' ) ( row = '22' ) ( row = '23' ) ( row = '73' ) ( row = '24' ) ( row = '26' ) ( row = '28' ) ( row = '53' ) ( row = '31' ) ( row = '37' ) ( row = '51' ) ( row = '32' ) ( row = '33' ) ( row = '34' ) ( row = '36' ) ( row = '35' ) ( row = '54' ) ( row = '27' ) ( row = '38' ) ( row = '39' ) ( row = '40' ) ( row = '74' ) ( row = '70' ) ( row = '41' ) ( row = '93' ) ( row = '144' ) ( row = '45' ) ( row = '63' ) ( row = '87' ) ( row = '66' ) ( row = '65' ) ( row = '55' ) ( row = '58' ) ( row = '62' ) ( row = '72' ) ( row = '105' ) ( row = '59' ) ( row = '76' ) ( row = '61' ) ( row = '67' ) ( row = '68' ) ( row = '77' ) ( row = '106' ) ( row = '78' ) ( row = '79' ) ( row = '183' ) ( row = '86' ) ( row = '117' ) ( row = '96' ) ( row = '100' ) ( row = '108' ) ( row = '104' ) ( row = '123' ) ( row = '113' ) ( row = '114' ) ( row = '116' ) ( row = '129' ) ( row = '119' ) ( row = '178' ) ( row = '120' ) ( row = '196' ) ( row = '126' ) ( row = '177' ) ( row = '184' ) ( row = '135' ) ( row = '182' ) ( row = '192' ) ( row = '201' ) ( row = '174' ) ( row = '360' ) ( row = '186' ) ( row = '190' ) ( row = '210' ) ( row = '248' ) ( row = '214' ) ( row = '282' ) ( row = '217' ) ( row = '227' ) ( row = '229' ) ( row = '304' ) ( row = '235' ) ( row = '370' ) ( row = '308' ) ( row = '261' ) ( row = '302' ) ( row = '300' ) ( row = '542' ) ( row = '376' ) ( row = '309' ) ( row = '317' ) ( row = '356' ) ( row = '364' ) ( row = '375' ) ( row = '407' ) ( row = '396' ) ( row = '400' ) ( row = '404' ) ( row = '585' ) ( row = '599' ) ( row = '514' ) ( row = '444' ) ( row = '907' ) ( row = '456' ) ( row = '633' ) ( row = '687' ) ( row = '496' ) ( row = '665' ) ( row = '561' ) ( row = '563' ) ( row = '832' ) ( row = '1056' ) ( row = '626' ) ( row = '673' ) ( row = '681' ) ( row = '720' ) ( row = '731' ) ( row = '840' ) ( row = '819' ) ( row = '796' ) ( row = '800' ) ( row = '1033' ) ( row = '1117' ) ( row = '900' ) ( row = '958' ) ( row = '940' ) ( row = '952' ) ( row = '1017' ) ( row = '1019' ) ( row = '1748' ) ( row = '1177' ) ( row = '1422' ) ( row = '1124' ) ( row = '1578' ) ( row = '1189' ) ( row = '1299' ) ( row = '1678' ) ( row = '1307' ) ( row = '1354' ) ( row = '2702' ) ( row = '2476' ) ( row = '1689' ) ( row = '3775' ) ( row = '1740' ) ( row = '2813' ) ( row = '2706' ) ( row = '1977' ) ( row = '1898' ) ( row = '1840' ) ( row = '2630' ) ( row = '2864' ) ( row = '1971' ) ( row = '2439' ) ( row = '2143' ) ( row = '2932' ) ( row = '2301' ) ( row = '2313' ) ( row = '2423' ) ( row = '2488' ) ( row = '2496' ) ( row = '3194' ) ( row = '2661' ) ( row = '2996' ) ( row = '3043' ) ( row = '4416' ) ( row = '3429' ) ( row = '3529' ) ( row = '3580' ) ( row = '3638' ) ( row = '3738' ) ( row = '3983' ) ( row = '4830' ) ( row = '3811' ) ( row = '4114' ) ( row = '4724' ) ( row = '5782' ) ( row = '4394' ) ( row = '4444' ) ( row = '7143' ) ( row = '6623' ) ( row = '6882' ) ( row = '7267' ) ( row = '5149' ) ( row = '7823' ) ( row = '5855' ) ( row = '5657' ) ( row = '5704' ) ( row = '6425' ) ( row = '7026' ) ( row = '6958' ) ( row = '9666' ) ( row = '7109' ) ( row = '7218' ) ( row = '10249' ) ( row = '8535' ) ( row = '7794' ) ( row = '11512' ) ( row = '14327' ) ( row = '9969' ) ( row = '15906' ) ( row = '8838' ) ( row = '10101' ) ( row = '9593' ) ( row = '12082' ) ( row = '10806' ) ( row = '10853' ) ( row = '13451' ) ( row = '17489' ) ( row = '13073' ) ( row = '11361' ) ( row = '12129' ) ( row = '17210' ) ( row = '13383' ) ( row = '13984' ) ( row = '30562' ) ( row = '16329' ) ( row = '14903' ) ( row = '15753' ) ( row = '19306' ) ( row = '16632' ) ( row = '23920' ) ( row = '26456' ) ( row = '26113' ) ( row = '18431' ) ( row = '27032' ) ( row = '19644' ) ( row = '27882' ) ( row = '20399' ) ( row = '37885' ) ( row = '21659' ) ( row = '27976' ) ( row = '24812' ) ( row = '23490' ) ( row = '24744' ) ( row = '25345' ) ( row = '25512' ) ( row = '42785' ) ( row = '27367' ) ( row = '29737' ) ( row = '30656' ) ( row = '45579' ) ( row = '31535' ) ( row = '32385' ) ( row = '35063' ) ( row = '52788' ) ( row = '38075' ) ( row = '38830' ) ( row = '44544' ) ( row = '40090' ) ( row = '40043' ) ( row = '55249' ) ( row = '57897' ) ( row = '42058' ) ( row = '45149' ) ( row = '52712' ) ( row = '48234' ) ( row = '48302' ) ( row = '72946' ) ( row = '50089' ) ( row = '64342' ) ( row = '52879' ) ( row = '103551' ) ( row = '57104' ) ( row = '72428' ) ( row = '62191' ) ( row = '79837' ) ( row = '63920' ) ( row = '71215' ) ( row = '73138' ) ( row = '80133' ) ( row = '84587' ) ( row = '82148' ) ( row = '156430' ) ( row = '90132' ) ( row = '152323' ) ( row = '113146' ) ( row = '90360' ) ( row = '197733' ) ( row = '100946' ) ( row = '105591' ) ( row = '101113' ) ( row = '98391' ) ( row = '288093' ) ( row = '154280' ) ( row = '109983' ) ( row = '204497' ) ( row = '164424' ) ( row = '152975' ) ( row = '137058' ) ( row = '126111' ) ( row = '191473' ) ( row = '181079' ) ( row = '144353' ) ( row = '153271' ) ( row = '170265' ) ( row = '166735' ) ( row = '183261' ) ( row = '180492' ) ( row = '188523' ) ( row = '236094' ) ( row = '235449' ) ( row = '188751' ) ( row = '202059' ) ( row = '262815' ) ( row = '305610' ) ( row = '199504' ) ( row = '208374' ) ( row = '247041' ) ( row = '312042' ) ( row = '254336' ) ( row = '440591' ) ( row = '353175' ) ( row = '442859' ) ( row = '263169' ) ( row = '270464' ) ( row = '616344' ) ( row = '297624' ) ( row = '311088' ) ( row = '320006' ) ( row = '402829' ) ( row = '377274' ) ( row = '363753' ) ( row = '369015' ) ( row = '501377' ) ( row = '388255' ) ( row = '390810' ) ( row = '397125' ) ( row = '401563' ) ( row = '407878' ) ( row = '446545' ) ( row = '455415' ) ( row = '471543' ) ( row = '732768' ) ( row = '524800' ) ( row = '751679' ) ( row = '1043856' ) ( row = '533633' ) ( row = '626922' ) ( row = '568088' ) ( row = '581552' ) ( row = '608712' ) ( row = '699343' ) ( row = '631094' ) ( row = '697280' ) ( row = '779065' ) ( row = '926958' ) ( row = '921925' ) ( row = '868668' ) ( row = '785380' ) ( row = '969651' ) ( row = '856978' ) ( row = '798688' ) ( row = '809441' ) ( row = '989430' ) ( row = '901960' ) ( row = '1036967' ) ( row = '996343' ) ( row = '1285312' ) ( row = '1133512' ) ( row = '1101721' ) ( row = '1195010' ) ( row = '1115185' ) ( row = '1149640' ) ( row = '1330437' ) ( row = '1911355' ) ( row = '1239806' ) ( row = '1328374' ) ( row = '1912577' ) ( row = '1476345' ) ( row = '3239729' ) ( row = '1654048' ) ( row = '1655666' ) ( row = '1594821' ) ( row = '1584068' ) ( row = '1608129' ) ( row = '1758938' ) ( row = '1700648' ) ( row = '1711401' ) ( row = '2365341' ) ( row = '1898303' ) ( row = '2895658' ) ( row = '2098064' ) ( row = '2216906' ) ( row = '4654596' ) ( row = '3293074' ) ( row = '2769233' ) ( row = '2354991' ) ( row = '3039775' ) ( row = '2834627' ) ( row = '3238116' ) ( row = '3810880' ) ( row = '3132011' ) ( row = '3060413' ) ( row = '3178889' ) ( row = '3284716' ) ( row = '3192197' ) ( row = '3202950' ) ( row = '3295469' ) ( row = '4253294' ) ( row = '3928307' ) ( row = '3412049' ) ( row = '4720332' ) ( row = '4993722' ) ( row = '4867297' ) ( row = '3996367' ) ( row = '4571897' ) ( row = '8152013' ) ( row = '4986139' ) ( row = '5124224' ) ( row = '5189618' ) ( row = '6472462' ) ( row = '5394766' ) ( row = '5874402' ) ( row = '5895040' ) ( row = '7003077' ) ( row = '6192424' ) ( row = '7385305' ) ( row = '8181601' ) ( row = '6476913' ) ( row = '6395147' ) ( row = '6487666' ) ( row = '8716699' ) ( row = '6707518' ) ( row = '7408416' ) ( row = '8398188' ) ( row = '7983946' ) ( row = '8568264' ) ( row = '8863664' ) ( row = '8982506' ) ( row = '9120591' ) ( row = '13184431' ) ( row = '10860541' ) ( row = '10110363' ) ( row = '10313842' ) ( row = '10584384' ) ( row = '11289806' ) ( row = '15470172' ) ( row = '11769442' ) ( row = '12382706' ) ( row = '16579789' ) ( row = '15056088' ) ( row = '12872060' ) ( row = '13896082' ) ( row = '12964579' ) ( row = '13102665' ) ( row = '25185888' ) ( row = '24474237' ) ( row = '14115934' ) ( row = '20633106' ) ( row = '16382134' ) ( row = '16552210' ) ( row = '23098440' ) ( row = '19092869' ) ( row = '18103097' ) ( row = '24209924' ) ( row = '24392471' ) ( row = '27842016' ) ( row = '24254385' ) ( row = '28687481' ) ( row = '24152148' ) ( row = '23059248' ) ( row = '38150467' ) ( row = '24641502' ) ( row = '25347285' ) ( row = '25836639' ) ( row = '42357482' ) ( row = '36023827' ) ( row = '26067244' ) ( row = '27080513' ) ( row = '35645079' ) ( row = '49033973' ) ( row = '30498068' ) ( row = '39463219' ) ( row = '42619454' ) ( row = '32934344' ) ( row = '34655307' ) ( row = '29221323' ) ( row = '37195966' ) ( row = '60665329' ) ( row = '62725592' ) ( row = '47313633' ) ( row = '50901264' ) ( row = '47211396' ) ( row = '82958712' ) ( row = '47700750' ) ( row = '48406533' ) ( row = '49988787' ) ( row = '50708746' ) ( row = '51183924' ) ( row = '51903883' ) ( row = '53147757' ) ( row = '88497192' ) ( row = '77789259' ) ( row = '56301836' ) ( row = '86546343' ) ( row = '67694034' ) ( row = '59719391' ) ( row = '70130310' ) ( row = '81340877' ) ( row = '101892670' ) ( row = '63876630' ) ( row = '66417289' ) ( row = '84407362' ) ( row = '96107283' ) ( row = '94525029' ) ( row = '146096070' ) ( row = '94912146' ) ( row = '95617929' ) ( row = '103087807' ) ( row = '101554290' ) ( row = '180025291' ) ( row = '103136544' ) ( row = '102612629' ) ( row = '110903315' ) ( row = '105051640' ) ( row = '109449593' ) ( row = '116021227' ) ( row = '120178466' ) ( row = '122719125' ) ( row = '178932391' ) ( row = '197661573' ) ( row = '123596021' ) ( row = '167971579' ) ( row = '130293919' ) ( row = '283113098' ) ( row = '199576669' ) ( row = '245349680' ) ( row = '199243827' ) ( row = '189437175' ) ( row = '213515944' ) ( row = '190530075' ) ( row = '196466436' ) ( row = '197172219' ) ( row = '233045614' ) ( row = '390106744' ) ( row = '223315010' ) ( row = '225331754' ) ( row = '207664269' ) ( row = '214501233' ) ( row = '396748888' ) ( row = '225470820' ) ( row = '291567600' ) ( row = '312156300' ) ( row = '478395294' ) ( row = '343809863' ) ( row = '253889940' ) ( row = '298265498' ) ( row = '509328519' ) ( row = '319731094' ) ( row = '472550273' ) ( row = '379967250' ) ( row = '385903611' ) ( row = '386609394' ) ( row = '479221694' ) ( row = '711440908' ) ( row = '545201914' ) ( row = '393638655' ) ( row = '629794502' ) ( row = '422165502' ) ( row = '439972053' ) ( row = '680214542' ) ( row = '461554209' ) ( row = '433135089' ) ( row = '468391173' ) ( row = '1024423608' ) ( row = '479360760' ) ( row = '545457540' ) ( row = '552155438' ) ( row = '854294784' ) ( row = '573621034' ) ( row = '617996592' ) ( row = '678232748' ) ( row = '705634705' ) ( row = '699698344' ) ( row = '938840569' ) ( row = '773605905' ) ( row = '772513005' ) ( row = '780248049' ) ( row = '815804157' ) ( row = '1170152030' ) ( row = '826773744' ) ( row = '855192864' ) ( row = '1418201329' ) ( row = '862137555' ) ( row = '1794033433' ) ( row = '1024818300' ) ( row = '894689298' ) ( row = '1051131681' ) ( row = '1163454132' ) ( row = '1031516198' ) ( row = '1052981794' ) ( row = '1119078574' ) ( row = '1125776472' ) ( row = '1191617626' ) ( row = '1450745753' ) ( row = '1485882754' ) ( row = '1377931092' ) ( row = '1405333049' ) ( row = '1472211349' ) ( row = '2266130803' ) ( row = '1546118910' ) ( row = '1552761054' ) ( row = '2576522225' ) ( row = '1642577901' ) ( row = '1717330419' ) ( row = '1681966608' ) ( row = '1749882162' ) ( row = '2300022347' ) ( row = '1886955855' ) ( row = '2216435926' ) ( row = '1919507598' ) ( row = '2242749307' ) ( row = '2084497992' ) ( row = '2150594772' ) ( row = '2157292670' ) ( row = '2172060368' ) ( row = '2244855046' ) ( row = '2317394098' ) ( row = '2569548718' ) ( row = '2891215803' ) ( row = '2783264141' ) ( row = '2850142441' ) ( row = '2877544398' ) ( row = '3762554836' ) ( row = '3098879964' ) ( row = '4533830024' ) ( row = '3195338955' ) ( row = '4384520339' ) ( row = '5066578367' ) ( row = '3399297027' ) ( row = '3568922463' ) ( row = '3636838017' ) ( row = '8170668041' ) ( row = '6514382415' ) ( row = '4373728596' ) ( row = '4467988870' ) ( row = '4322655140' ) ( row = '6446466861' ) ( row = '4307887442' ) ( row = '5674479944' ) ( row = '4416915414' ) ( row = '7406767406' ) ( row = '5100658239' ) ( row = '5352812859' ) ( row = '5978603096' ) ( row = '7105919281' ) ( row = '6498176991' ) ( row = '8669580702' ) ( row = '6294218919' ) ( row = '6735717981' ) ( row = '11048212439' ) ( row = '8021358356' ) ( row = '6968219490' ) ( row = '11573908151' ) ( row = '7036135044' ) ( row = '7205760480' ) ( row = '7944725459' ) ( row = '9423313379' ) ( row = '8630542582' ) ( row = '8790644010' ) ( row = '17868127070' ) ( row = '8724802856' ) ( row = '9408545681' ) ( row = '9982367386' ) ( row = '10453471098' ) ( row = '9517573653' ) ( row = '11079261335' ) ( row = '12792395910' ) ( row = '18253972919' ) ( row = '12272822015' ) ( row = '13400138200' ) ( row = '13233894972' ) ( row = '13029936900' ) ( row = '13262438409' ) ( row = '14912944949' ) ( row = '14004354534' ) ( row = '27677286298' ) ( row = '17188127866' ) ( row = '20436273244' ) ( row = '14241895524' ) ( row = '21790395668' ) ( row = '20502574714' ) ( row = '17421186592' ) ( row = '19499941039' ) ( row = '17515446866' ) ( row = '25912930722' ) ( row = '23687366070' ) ( row = '18926119334' ) ( row = '20435838484' ) ( row = '25672960215' ) ( row = '24109198235' ) ( row = '44865414164' ) ( row = '25065217925' ) ( row = '25302758915' ) ( row = '25506716987' ) ( row = '26263831872' ) ( row = '30683625001' ) ( row = '27034291434' ) ( row = '27504333933' ) ( row = '28246250058' ) ( row = '31192482400' ) ( row = '48104811593' ) ( row = '36921127631' ) ( row = '33168014858' ) ( row = '31663082116' ) ( row = '42486404517' ) ( row = '34936633458' ) ( row = '43188407081' ) ( row = '50683461724' ) ( row = '36441566200' ) ( row = '43991337259' ) ( row = '81786541795' ) ( row = '39361957818' ) ( row = '44545036719' ) ( row = '49174416160' ) ( row = '49411957150' ) ( row = '61876107401' ) ( row = '50367976840' ) ( row = '53549008973' ) ( row = '51770548859' ) ( row = '53298123306' ) ( row = '54538625367' ) ( row = '55280541492' ) ( row = '59909332174' ) ( row = '84348590608' ) ( row = '87706640225' ) ( row = '64831096974' ) ( row = '82346543840' ) ( row = '71025039934' ) ( row = '66599715574' ) ( row = '71378199658' ) ( row = '126331578514' ) ( row = '75803524018' ) ( row = '121746176498' ) ( row = '93956993869' ) ( row = '115923236377' ) ( row = '89729934658' ) ( row = '83906994537' ) ( row = '93719452879' ) ( row = '143131410029' ) ( row = '99779933990' ) ( row = '102138525699' ) ( row = '136119139467' ) ( row = '125563665301' ) ( row = '106309174226' ) ( row = '107836748673' ) ( row = '109819166859' ) ( row = '115189873666' ) ( row = '126509047748' ) ( row = '185622690877' ) ( row = '147177640814' ) ( row = '131430812548' ) ( row = '287761216576' ) ( row = '137624755508' ) ( row = '192931294088' ) ( row = '165533458676' ) ( row = '159710518555' ) ( row = '177626447416' ) ( row = '201793742542' ) ( row = '173636929195' ) ( row = '183449387537' ) ( row = '183686928527' ) ( row = '186045520236' ) ( row = '193499386869' ) ( row = '206089108216' ) ( row = '217655915532' ) ( row = '208447699925' ) ( row = '407882850758' ) ( row = '423745023748' ) ( row = '232818221974' ) ( row = '239267561221' ) ( row = '300145976943' ) ( row = '241698921414' ) ( row = '314880200085' ) ( row = '269055568056' ) ( row = '330627028351' ) ( row = '291141331103' ) ( row = '353209905424' ) ( row = '343159906092' ) ( row = '392134628452' ) ( row = '325243977231' ) ( row = '351263376611' ) ( row = '363671967652' ) ( row = '357086316732' ) ( row = '416505150501' ) ( row = '367136316064' ) ( row = '399588495085' ) ( row = '394493220161' ) ( row = '745756596772' ) ( row = '414536808141' ) ( row = '426103615457' ) ( row = '441265921899' ) ( row = '472085783195' ) ( row = '584858827506' ) ( row = '474517143388' ) ( row = '592477466645' ) ( row = '709373420246' ) ( row = '510754489470' ) ( row = '783641466565' ) ( row = '560196899159' ) ( row = '841653459452' ) ( row = '616385308334' ) ( row = '694423282703' ) ( row = '719737197392' ) ( row = '676507353842' ) ( row = '886622591336' ) ( row = '720758284384' ) ( row = '724222632796' ) ( row = '1071000574003' ) ( row = '810998370662' ) ( row = '1010962442963' ) ( row = '794081715246' ) ( row = '1208618523387' ) ( row = '1150639342145' ) ( row = '1001462821058' ) ( row = '867369537356' ) ( row = '915783065287' ) ( row = '946602926583' ) ( row = '985271632858' ) ( row = '1034714042547' ) ( row = '1176582207493' ) ( row = '1070951388629' ) ( row = '1127139797804' ) ( row = '1587106734748' ) ( row = '1812461191720' ) ( row = '2502889800035' ) ( row = '1292892662176' ) ( row = '1370930636545' ) ( row = '1396244551234' ) ( row = '1607380875720' ) ( row = '3537603842582' ) ( row = '1444980917180' ) ( row = '1795174021425' ) ( row = '1938370111359' ) ( row = '1661451252602' ) ( row = '1709864780533' ) ( row = '2086974377422' ) ( row = '1950497107834' ) ( row = '1813972463939' ) ( row = '1783152602643' ) ( row = '2105665431176' ) ( row = '1986734453916' ) ( row = '1931874559441' ) ( row = '2019985675405' ) ( row = '3108456766934' ) ( row = '2198091186433' ) ( row = '2788591050406' ) ( row = '2420032459980' ) ( row = '2689137213410' ) ( row = '3769887056559' ) ( row = '4136461297792' ) ( row = '2663823298721' ) ( row = '2767175187779' ) ( row = '3003625426954' ) ( row = '4056162539010' ) ( row = '3106432169782' ) ( row = '3228133519823' ) ( row = '3371316033135' ) ( row = '3733649710477' ) ( row = '4887228399843' ) ( row = '3493017383176' ) ( row = '3597125066582' ) ( row = '5109290858130' ) ( row = '3803138278048' ) ( row = '5917270733233' ) ( row = '4125651106581' ) ( row = '3951860234846' ) ( row = '4129965745874' ) ( row = '4218076861838' ) ( row = '4618123646413' ) ( row = '4861914485154' ) ( row = '5109169673390' ) ( row = '7773114156851' ) ( row = '6156840681897' ) ( row = '6840081880259' ) ( row = '5430998486500' ) ( row = '5667448725675' ) ( row = '6500824898256' ) ( row = '6110057596736' ) ( row = '6721150902999' ) ( row = '10235708703317' ) ( row = '7446210381661' ) ( row = '6968441099717' ) ( row = '7090142449758' ) ( row = '8743774752994' ) ( row = '7296155661224' ) ( row = '7400263344630' ) ( row = '8912307951438' ) ( row = '8665052763202' ) ( row = '8077511341427' ) ( row = '8081825980720' ) ( row = '9079991346992' ) ( row = '15069148633335' ) ( row = '10374917543735' ) ( row = '13510320941366' ) ( row = '9971084158544' ) ( row = '11219227270126' ) ( row = '14917593221686' ) ( row = '12271080366759' ) ( row = '11098447212175' ) ( row = '12168273623931' ) ( row = '11777506322411' ) ( row = '12610882494992' ) ( row = '12831208499735' ) ( row = '13689592002716' ) ( row = '14058583549475' ) ( row = '14264596760941' ) ( row = '14368704444347' ) ( row = '14386298110982' ) ( row = '14696419005854' ) ( row = '23369527578934' ) ( row = '20231471844365' ) ( row = '16159337322147' ) ( row = '24824390085349' ) ( row = '25915646275980' ) ( row = '26997180605974' ) ( row = '25678594565297' ) ( row = '22242164525303' ) ( row = '22802292658279' ) ( row = '22139357782475' ) ( row = '21069531370719' ) ( row = '22317674482301' ) ( row = '22875953534586' ) ( row = '25442090994727' ) ( row = '28961015766795' ) ( row = '25836089871886' ) ( row = '26042103083352' ) ( row = '26300474497708' ) ( row = '40284350720327' ) ( row = '28755002555329' ) ( row = '28323180310416' ) ( row = '35334128131660' ) ( row = '51203180292098' ) ( row = '36525655893457' ) ( row = '45044457183582' ) ( row = '45193628016887' ) ( row = '36390809166512' ) ( row = '42074983598127' ) ( row = '48153764354187' ) ( row = '43311695896022' ) ( row = '49176428032294' ) ( row = '43208889153194' ) ( row = '43387205853020' ) ( row = '43871824028998' ) ( row = '44457032264776' ) ( row = '73989854226073' ) ( row = '47759765477028' ) ( row = '48318044529313' ) ( row = '51278180866613' ) ( row = '54591092427215' ) ( row = '69044979025080' ) ( row = '52342577581060' ) ( row = '54623654808124' ) ( row = '57078182865745' ) ( row = '76082945787444' ) ( row = '92610796618963' ) ( row = '71724937298172' ) ( row = '72916465059969' ) ( row = '78465792764639' ) ( row = '79599698319706' ) ( row = '81584437183399' ) ( row = '79702505062534' ) ( row = '122092893092263' ) ( row = '86596095006214' ) ( row = '86520585049216' ) ( row = '87080713182192' ) ( row = '96799609845836' ) ( row = '87259029882018' ) ( row = '99080687072900' ) ). DATA: lv_checked TYPE abap_bool VALUE abap_false, lv_current_index TYPE i VALUE 0. "" Task 1 LOOP AT lv_input INTO wa_input. IF lines( lv_input ) GE ( sy-tabix + 25 ). lv_checked = abap_false. lv_current_index = sy-tabix + 25. READ TABLE lv_input INTO DATA(wa_cur_result) INDEX lv_current_index. "" Go through the preamble DO 25 TIMES. DATA(lv_cur_index_a) = sy-index. DO 25 TIMES. DATA(lv_cur_index_b) = sy-index. READ TABLE lv_input INTO DATA(lv_number_a) INDEX lv_current_index - lv_cur_index_a. READ TABLE lv_input INTO DATA(lv_number_b) INDEX lv_current_index - lv_cur_index_b. DATA(lv_check_result) = lv_number_a-row + lv_number_b-row. IF lv_check_result EQ wa_cur_result-row. lv_checked = abap_true. EXIT. ENDIF. ENDDO. IF lv_checked EQ abap_true. EXIT. ENDIF. ENDDO. IF lv_checked EQ abap_false. WRITE: 'Task 1 - Found value: ' && wa_cur_result-row. EXIT. ENDIF. ELSE. EXIT. ENDIF. ENDLOOP. "" Task 2 LOOP AT lv_input INTO DATA(wa_input_a). DATA(lv_cur_range) = sy-tabix. LOOP AT lv_input INTO DATA(wa_input_b). DATA(lv_cur_range_sum) = 0. DATA(lv_cur_range_index) = sy-tabix. DO lv_cur_range TIMES. READ TABLE lv_input INTO DATA(lv_cur_num) INDEX ( sy-index + lv_cur_range_index - 1 ). IF sy-index EQ 1. DATA(lv_cur_range_start) = lv_cur_num-row. ENDIF. lv_cur_range_sum = lv_cur_range_sum + lv_cur_num-row. ENDDO. DATA(lv_cur_range_end) = lv_cur_num-row. IF lv_cur_range_sum EQ wa_cur_result-row. EXIT. ENDIF. ENDLOOP. IF lv_cur_range_sum EQ wa_cur_result-row. EXIT. ENDIF. ENDLOOP. DATA(lv_result) = lv_cur_range_start + lv_cur_range_end. WRITE: 'Task 2 - Found range sum: ' && lv_result && ' (' && lv_cur_range_start && '-' && lv_cur_range_start && ')'. ",14613,True,4896.325852618466,median "CLASS ycl_addict_transport_request DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. TYPES as4text_range TYPE RANGE OF e07t-as4text. TYPES as4user_range TYPE RANGE OF e070-as4user. TYPES date_range TYPE RANGE OF dats. TYPES obj_name_range TYPE RANGE OF e071-obj_name . TYPES object_range TYPE RANGE OF e071-object. TYPES pgmid_range TYPE RANGE OF e071-pgmid. TYPES trfunction_range TYPE RANGE OF e070-trfunction. TYPES trstatus_range TYPE RANGE OF e070-trstatus. TYPES request_attribute_list TYPE STANDARD TABLE OF e070a WITH EMPTY KEY. TYPES request_key_list TYPE STANDARD TABLE OF e071k WITH EMPTY KEY. TYPES request_nametab_list TYPE STANDARD TABLE OF e071kf WITH EMPTY KEY. TYPES request_object_list TYPE STANDARD TABLE OF e071 WITH EMPTY KEY. TYPES trkorr_list TYPE STANDARD TABLE OF trkorr WITH KEY table_line. TYPES user_list TYPE STANDARD TABLE OF xubname WITH EMPTY KEY. TYPES: BEGIN OF content_dict, objects TYPE request_object_list, keys TYPE request_key_list, nametabs TYPE request_nametab_list, attributes TYPE request_attribute_list, END OF content_dict. TYPES: BEGIN OF request_type_dict, pgmid TYPE e071-pgmid, object TYPE e071-object, END OF request_type_dict. TYPES: BEGIN OF request_param_dict, trkorr_rng TYPE ytt_addict_trkorr_rng, trfunction_rng TYPE ytt_addict_trfunction_rng, trstatus_rng TYPE trstatus_range, as4user_rng TYPE as4user_range, as4text_rng TYPE as4text_range, as4date_rng TYPE date_range, must_have_subtask TYPE abap_bool, srch_strkorr TYPE abap_bool, ignore_trkorr TYPE abap_bool, END OF request_param_dict. TYPES: BEGIN OF request_and_object_dict, trkorr TYPE e070-trkorr, as4text TYPE e07t-as4text, strkorr TYPE e070-strkorr, pgmid TYPE e071-pgmid, object TYPE e071-object, obj_name TYPE e071-obj_name, END OF request_and_object_dict, request_and_object_list TYPE STANDARD TABLE OF request_and_object_dict WITH EMPTY KEY. TYPES: BEGIN OF request_obj_dict, trkorr TYPE trkorr, obj TYPE REF TO ycl_addict_transport_request, END OF request_obj_dict, request_obj_list TYPE STANDARD TABLE OF request_obj_dict WITH EMPTY KEY. CONSTANTS: BEGIN OF domain, trfunction TYPE domname VALUE 'TRFUNCTION', END OF domain. CONSTANTS: BEGIN OF object, cinc TYPE e071-object VALUE 'CINC', clas TYPE e071-object VALUE 'CLAS', clsd TYPE e071-object VALUE 'CLSD', cpub TYPE e071-object VALUE 'CPUB', cpri TYPE e071-object VALUE 'CPRI', doma TYPE e071-object VALUE 'DOMA', domd TYPE e071-object VALUE 'DOMD', dted TYPE e071-object VALUE 'DTED', dtel TYPE e071-object VALUE 'DTEL', tabd TYPE e071-object VALUE 'TABD', tabl TYPE e071-object VALUE 'TABL', tdat TYPE e071-object VALUE 'TDAT', intf TYPE e071-object VALUE 'INTF', meth TYPE e071-object VALUE 'METH', prog TYPE e071-object VALUE 'PROG', END OF object. CONSTANTS: BEGIN OF pgmid, corr TYPE e071-pgmid VALUE 'CORR', limu TYPE e071-pgmid VALUE 'LIMU', r3tr TYPE e071-pgmid VALUE 'R3TR', END OF pgmid. CONSTANTS: BEGIN OF trfunction, cust TYPE trfunction VALUE 'W', cust_task TYPE trfunction VALUE 'Q', toc TYPE trfunction VALUE 'T', unclass TYPE trfunction VALUE 'X', wb TYPE trfunction VALUE 'K', END OF trfunction. CONSTANTS: BEGIN OF trstatus, modif TYPE trstatus VALUE 'D', modif_prot TYPE trstatus VALUE 'L', END OF trstatus. DATA trkorr TYPE trkorr READ-ONLY . CLASS-METHODS create_new_request IMPORTING !trfunction TYPE trfunction !as4text TYPE as4text OPTIONAL !users TYPE user_list OPTIONAL !target TYPE tr_target OPTIONAL RETURNING VALUE(output) TYPE REF TO ycl_addict_transport_request RAISING ycx_addict_table_content ycx_addict_function_subrc. CLASS-METHODS get_as4text_safe IMPORTING !trkorr TYPE trkorr RETURNING VALUE(output) TYPE as4text . CLASS-METHODS get_empty_open_requests IMPORTING !trkorr_rng TYPE ytt_addict_trfunction_rng RETURNING VALUE(output) TYPE ytt_addict_trkorr_det RAISING ycx_addict_table_content ycx_addict_function_subrc. CLASS-METHODS get_instance IMPORTING !trkorr TYPE trkorr !top TYPE abap_bool DEFAULT abap_false RETURNING VALUE(output) TYPE REF TO ycl_addict_transport_request RAISING ycx_addict_table_content. CLASS-METHODS get_modified_objects IMPORTING !obj TYPE ytt_addict_e071_obj_key RETURNING VALUE(output) TYPE ytt_addict_e071_obj_key. CLASS-METHODS get_open_status_rng RETURNING VALUE(output) TYPE trstatus_range. CLASS-METHODS get_open_requests IMPORTING !as4text_rng TYPE as4text_range OPTIONAL !trfunction_rng TYPE ytt_addict_trfunction_rng OPTIONAL !must_have_subtask TYPE abap_bool OPTIONAL RETURNING VALUE(output) TYPE ytt_addict_trkorr_det. CLASS-METHODS get_request_list IMPORTING !param TYPE request_param_dict RETURNING VALUE(output) TYPE ytt_addict_trkorr_det. CLASS-METHODS get_request_and_objects IMPORTING !tags TYPE ytt_addict_e071_obj_key RETURNING VALUE(output) TYPE request_and_object_list. CLASS-METHODS get_request_objects IMPORTING !trkorr_rng TYPE ytt_addict_trkorr_rng !pgmid_rng TYPE pgmid_range OPTIONAL !read_creation TYPE abap_bool DEFAULT abap_false EXPORTING !list TYPE ycl_addict_dol_model=>dol_list !list_wr TYPE ycl_addict_dol_model=>dol_list_wr. CLASS-METHODS get_requests_containing_obj IMPORTING !obj TYPE ytt_addict_e071_obj_key !top TYPE abap_bool DEFAULT abap_true !holistic_cls TYPE abap_bool DEFAULT abap_false !trfunction_rng TYPE ytt_addict_trfunction_rng OPTIONAL RETURNING VALUE(req) TYPE request_and_object_list. CLASS-METHODS get_source_client_safe IMPORTING !trkorr TYPE trkorr RETURNING VALUE(client) TYPE e070c-client . CLASS-METHODS get_toc_safety_safe IMPORTING !trkorr TYPE trkorr RETURNING VALUE(safe) TYPE abap_bool . CLASS-METHODS get_user_creatable_trf_rng RETURNING VALUE(func) TYPE ytt_addict_trfunction_rng . CLASS-METHODS is_obj_type_class_related IMPORTING !obj_type TYPE request_type_dict RETURNING VALUE(related) TYPE abap_bool . METHODS add_objects IMPORTING !obj TYPE ytt_addict_e071_obj_key !sort_and_compress TYPE abap_bool DEFAULT abap_false RAISING ycx_addict_function_subrc RESUMABLE(ycx_addict_sort_and_compress). METHODS add_objects_from_request IMPORTING !from TYPE trkorr_list !wait TYPE abap_bool DEFAULT abap_false !sort_and_compress TYPE abap_bool DEFAULT abap_false RAISING ycx_addict_function_subrc RESUMABLE(ycx_addict_sort_and_compress) ycx_addict_table_content . METHODS complete_shi_piece_list RAISING ycx_addict_sh_piece_list_comp. METHODS create_subtask IMPORTING !user TYPE user_list. METHODS delete RAISING ycx_addict_function_subrc. METHODS delete_empty_subtasks RAISING ycx_addict_function_subrc ycx_addict_table_content. METHODS delete_object IMPORTING !obj TYPE ysaddict_e071_obj_key RAISING ycx_addict_function_subrc. METHODS get_content RETURNING VALUE(content) TYPE content_dict RAISING ycx_addict_function_subrc ycx_addict_table_content . METHODS get_objects IMPORTING !pgmid_rng TYPE pgmid_range OPTIONAL !object_rng TYPE object_range OPTIONAL !obj_name_rng TYPE obj_name_range OPTIONAL !devclass_rng TYPE ycl_addict_package=>package_range OPTIONAL RETURNING VALUE(objects) TYPE request_object_list RAISING ycx_addict_function_subrc ycx_addict_table_content. METHODS get_header RETURNING VALUE(header) TYPE e070. METHODS get_obj_related_requests IMPORTING !include_self TYPE abap_bool DEFAULT abap_false !top TYPE abap_bool DEFAULT abap_true !obj_name_rng TYPE obj_name_range OPTIONAL !holistic_cls TYPE abap_bool DEFAULT abap_false !trfunction_rng TYPE ytt_addict_trfunction_rng OPTIONAL !devclass_rng TYPE ycl_addict_package=>package_range OPTIONAL RETURNING VALUE(list) TYPE request_and_object_list RAISING ycx_addict_function_subrc ycx_addict_table_content . METHODS get_source_client RETURNING VALUE(client) TYPE e070c-client . METHODS get_subtasks IMPORTING !only_empty TYPE abap_bool DEFAULT abap_false RETURNING VALUE(subtask) TYPE request_obj_list RAISING ycx_addict_function_subrc ycx_addict_table_content. METHODS get_text RETURNING VALUE(as4text) TYPE as4text. METHODS has_locked_object RETURNING VALUE(has) TYPE abap_bool. METHODS has_merge RETURNING VALUE(has) TYPE abap_bool RAISING ycx_addict_data_read. METHODS is_empty RETURNING VALUE(empty) TYPE abap_bool RAISING ycx_addict_function_subrc ycx_addict_table_content. METHODS is_toc_safe RETURNING VALUE(safe) TYPE abap_bool RAISING ycx_addict_class_method. METHODS release IMPORTING !rel_subtasks_too TYPE abap_bool !del_empty_subtasks TYPE abap_bool DEFAULT abap_true !wait_until_released TYPE abap_bool DEFAULT abap_false !max_rel_wait TYPE i OPTIONAL !compl_sh_piece_list TYPE abap_bool DEFAULT abap_true EXPORTING rel_wait_success TYPE abap_bool RAISING ycx_addict_function_subrc ycx_addict_table_content. METHODS sort_and_compress RAISING ycx_addict_sort_and_compress. PROTECTED SECTION. PRIVATE SECTION. TYPES request_object_type_set TYPE HASHED TABLE OF request_type_dict WITH UNIQUE KEY primary_key COMPONENTS pgmid object. TYPES: BEGIN OF clazy_flag_dict, class_related_obj_tags TYPE abap_bool, dev_req_rng TYPE abap_bool, END OF clazy_flag_dict. TYPES: BEGIN OF clazy_val_dict, class_related_obj_tag TYPE request_object_type_set, dev_req_rng TYPE ytt_addict_trkorr_rng, END OF clazy_val_dict. TYPES: BEGIN OF lazy_flag_dict, as4text TYPE abap_bool, content TYPE abap_bool, e070 TYPE abap_bool, empty TYPE abap_bool, source_client TYPE abap_bool, toc_safe TYPE abap_bool, END OF lazy_flag_dict. TYPES: BEGIN OF lazy_val_dict, as4text TYPE as4text, content TYPE content_dict, e070 TYPE e070, empty TYPE abap_bool, source_client TYPE e070c-client, toc_safe TYPE abap_bool, END OF lazy_val_dict. TYPES abap_bool_list TYPE STANDARD TABLE OF abap_bool WITH EMPTY KEY. TYPES obj_name_list TYPE STANDARD TABLE OF e071-obj_name WITH EMPTY KEY. TYPES: BEGIN OF multiton_dict, trkorr TYPE trkorr, top TYPE abap_bool, obj TYPE REF TO ycl_addict_transport_request, END OF multiton_dict, multiton_set TYPE HASHED TABLE OF multiton_dict WITH UNIQUE KEY primary_key COMPONENTS trkorr top. CONSTANTS: BEGIN OF table, e070 TYPE tabname VALUE 'E070', END OF table. CONSTANTS: BEGIN OF tcode, shi_piece_list TYPE sytcode VALUE 'YADDICT001', END OF tcode. CLASS-DATA clazy_flag TYPE clazy_flag_dict. CLASS-DATA clazy_val TYPE clazy_val_dict. CLASS-DATA multitons TYPE multiton_set. DATA lazy_flag TYPE lazy_flag_dict. DATA lazy_val TYPE lazy_val_dict. CLASS-METHODS build_dev_req_rng. CLASS-METHODS release_single IMPORTING !trkorr TYPE trkorr !req TYPE REF TO ycl_addict_transport_request OPTIONAL !wait_until_released TYPE abap_bool DEFAULT abap_false !max_rel_wait TYPE i !compl_sh_piece_list TYPE abap_bool DEFAULT abap_true EXPORTING !rel_wait_success TYPE abap_bool RAISING ycx_addict_function_subrc ycx_addict_table_content. ENDCLASS. CLASS ycl_addict_transport_request IMPLEMENTATION. METHOD add_objects. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Appends the given objects to the transport request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA t071 TYPE STANDARD TABLE OF e071 WITH DEFAULT KEY. "" Add objects """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" CHECK obj IS NOT INITIAL. t071 = CORRESPONDING #( obj ). CALL FUNCTION 'TRINT_APPEND_TO_COMM_ARRAYS' EXPORTING wi_error_table = abap_true wi_trkorr = me->trkorr iv_append_at_order = abap_true TABLES wt_e071 = t071[] EXCEPTIONS key_check_keysyntax_error = 1 ob_check_obj_error = 2 tr_lockmod_failed = 3 tr_lock_enqueue_failed = 4 tr_wrong_order_type = 5 tr_order_update_error = 6 file_access_error = 7 ob_no_systemname = 8 OTHERS = 9 ##FM_SUBRC_OK. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TRINT_APPEND_TO_COMM_ARRAYS' ). "" Sort & Compress """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF sort_and_compress = abap_true. TRY. sort_and_compress( ). CATCH ycx_addict_sort_and_compress INTO DATA(sac). RAISE RESUMABLE EXCEPTION sac. ENDTRY. ENDIF. ENDMETHOD. METHOD add_objects_from_request. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Appends objects of a request to this request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Build a list of requests & tasks """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA(trkorr_from) = from. LOOP AT from ASSIGNING FIELD-SYMBOL(). APPEND LINES OF VALUE trkorr_list( FOR _subtask IN get_instance( trkorr = top = abap_true )->get_subtasks( ) ( _subtask-trkorr ) ) TO trkorr_from. ENDLOOP. SORT trkorr_from BY table_line. DELETE ADJACENT DUPLICATES FROM trkorr_from COMPARING table_line. "" Append """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" LOOP AT trkorr_from ASSIGNING . CALL FUNCTION 'TR_COPY_COMM' EXPORTING wi_dialog = abap_false wi_trkorr_from = wi_trkorr_to = me->trkorr wi_without_documentation = abap_true EXCEPTIONS db_access_error = 1 trkorr_from_not_exist = 2 trkorr_to_is_repair = 3 trkorr_to_locked = 4 trkorr_to_not_exist = 5 trkorr_to_released = 6 user_not_owner = 7 no_authorization = 8 wrong_client = 9 wrong_category = 10 object_not_patchable = 11 OTHERS = 12 ##FM_SUBRC_OK ##NUMBER_OK. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TR_COPY_COMM' ). CHECK wait = abap_true. WAIT UP TO 1 SECONDS. ENDLOOP. "" Sort & Compress """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF sort_and_compress = abap_true. TRY. sort_and_compress( ). CATCH ycx_addict_sort_and_compress INTO DATA(sac). RAISE RESUMABLE EXCEPTION sac. ENDTRY. ENDIF. ENDMETHOD. METHOD build_dev_req_rng. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Builds a range of requests in the development system """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" CHECK ycl_addict_transport_request=>clazy_flag-dev_req_rng IS INITIAL. ycl_addict_transport_request=>clazy_val-dev_req_rng = VALUE #( ( sign = ycl_addict_toolkit=>sign-include option = ycl_addict_toolkit=>option-cp low = |{ sy-sysid }K*| ) ). ycl_addict_transport_request=>clazy_flag-dev_req_rng = abap_true. ENDMETHOD. METHOD complete_shi_piece_list. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Completes the piece list within the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TRY. DATA(bdc) = NEW ycl_addict_bdc( ). bdc->add_scr( prg = 'RS_STREE_OBJECTS_TO_REQ_GET' dyn = '1000' ). bdc->add_fld(: nam = 'BDC_OKCODE' val = '=ONLI' ), nam = 'P_TRKORR' val = CONV #( me->trkorr ) ). bdc->add_scr( prg = 'RS_STREE_OBJECTS_TO_REQ_GET' dyn = '0100' ). bdc->add_fld( nam = 'BDC_OKCODE' val = '=ENTER' ). bdc->add_scr( prg = 'RS_STREE_OBJECTS_TO_REQ_GET' dyn = '1000' ). bdc->add_fld( nam = 'BDC_OKCODE' val = '/EE' ). bdc->submit( tcode = me->tcode-shi_piece_list option = VALUE #( dismode = ycl_addict_bdc=>dismode-none ) validate_msg = abap_true ). CATCH cx_root INTO DATA(diaper). RAISE EXCEPTION TYPE ycx_addict_sh_piece_list_comp EXPORTING previous = diaper trkorr = me->trkorr. ENDTRY. ENDMETHOD. METHOD create_new_request. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Creates a new transport request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA head TYPE trwbo_request_header. DATA final_as4text TYPE as4text. IF users IS SUPPLIED. DATA(user) = VALUE scts_users( FOR _user IN users ( user = _user type = ycl_addict_transport_request=>trfunction-unclass ) ). ENDIF. DATA(auto_prefix) = ycl_addict_toolkit=>get_system_definitions( )-auto_request_prefix. final_as4text = COND #( WHEN as4text IS SUPPLIED THEN as4text ELSE |{ auto_prefix } Request| ). CLEAR head. CALL FUNCTION 'TR_INSERT_REQUEST_WITH_TASKS' EXPORTING iv_type = trfunction iv_text = final_as4text it_users = user iv_target = target IMPORTING es_request_header = head EXCEPTIONS insert_failed = 1 enqueue_failed = 2 OTHERS = 3 ##FM_SUBRC_OK. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TR_INSERT_REQUEST_WITH_TASKS' ). output = get_instance( head-trkorr ). ENDMETHOD. METHOD create_subtask. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Creates a new subtask within the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA msg TYPE STANDARD TABLE OF tr004. DATA tr005 TYPE STANDARD TABLE OF tr005. CLEAR: tr005, msg. tr005 = VALUE #( FOR _user IN user ( as4user = _user ) ). CALL FUNCTION 'TR40_TASK_ADD' EXPORTING iv_trkorr = me->trkorr TABLES tt_userlist = tr005 tt_msg = msg. ENDMETHOD. METHOD delete. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Deletes the transport request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" CALL FUNCTION 'TRINT_DELETE_COMM' EXPORTING wi_dialog = abap_false wi_trkorr = me->trkorr iv_without_any_checks = abap_true iv_without_user_check = abap_true iv_without_ctsproject_check = abap_true EXCEPTIONS file_access_error = 1 order_already_released = 2 order_contains_c_member = 3 order_contains_locked_entries = 4 order_is_refered = 5 repair_order = 6 user_not_owner = 7 delete_was_cancelled = 8 objects_free_but_still_locks = 9 order_lock_failed = 10 wrong_client = 11 project_still_referenced = 12 successors_already_released = 13 OTHERS = 14 ##FM_SUBRC_OK ##NUMBER_OK. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TRINT_DELETE_COMM' ). ENDMETHOD. METHOD delete_empty_subtasks. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Deletes the empty subtasks within the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" LOOP AT get_subtasks( only_empty = abap_true ) ASSIGNING FIELD-SYMBOL(). -obj->delete( ). ENDLOOP. ENDMETHOD. METHOD delete_object. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Deletes an object from within the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA(e071) = CORRESPONDING e071( obj ). e071-trkorr = me->trkorr. DATA(req) = VALUE trwbo_request( ). CALL FUNCTION 'TRINT_DELETE_COMM_OBJECT_KEYS' EXPORTING is_e071_delete = e071 iv_dialog_flag = abap_false CHANGING cs_request = req EXCEPTIONS e_bad_target_request = 1 e_database_access_error = 2 e_empty_lockkey = 3 e_wrong_source_client = 4 n_no_deletion_of_c_objects = 5 n_no_deletion_of_corr_entry = 6 n_object_entry_doesnt_exist = 7 n_request_already_released = 8 n_request_from_other_system = 9 r_user_cancelled = 10 r_user_didnt_confirm = 11 r_foreign_lock = 12 w_bigger_lock_in_same_order = 13 w_duplicate_entry = 14 w_no_authorization = 15 w_user_not_owner = 16 OTHERS = 17 ##FM_SUBRC_OK ##NUMBER_OK. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TRINT_DELETE_COMM_OBJECT_KEYS' ). ENDMETHOD. METHOD get_as4text_safe. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns the request description without generating exception """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TRY. output = get_instance( trkorr )->get_text( ). CATCH cx_root ##no_handler . ENDTRY. ENDMETHOD. METHOD get_content. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns the content of the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF me->lazy_flag-content IS INITIAL. CALL FUNCTION 'TR_READ_COMM' EXPORTING wi_trkorr = me->trkorr wi_dialog = abap_false wi_langu = sy-langu wi_sel_e071 = abap_true wi_sel_e071k = abap_true iv_sel_e071kf = abap_true iv_sel_e070a = abap_true TABLES wt_e071 = me->lazy_val-content-objects wt_e071k = me->lazy_val-content-keys et_e071kf = me->lazy_val-content-nametabs et_e070a = me->lazy_val-content-attributes EXCEPTIONS not_exist_e070 = 1 no_authorization = 2 OTHERS = 3 ##FM_SUBRC_OK. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TR_READ_COMM' ). LOOP AT get_subtasks( ) ASSIGNING FIELD-SYMBOL(). DATA(sub_content) = -obj->get_content( ). APPEND LINES OF: sub_content-objects TO me->lazy_val-content-objects, sub_content-keys TO me->lazy_val-content-keys, sub_content-nametabs TO me->lazy_val-content-nametabs, sub_content-attributes TO me->lazy_val-content-attributes. ENDLOOP. me->lazy_flag-content = abap_true. ENDIF. content = me->lazy_val-content. ENDMETHOD. METHOD get_empty_open_requests. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns empty open requests """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SELECT trkorr FROM e070 AS request WHERE trkorr IN @trkorr_rng AND ( strkorr = @space OR strkorr IS NULL ) AND ( NOT EXISTS ( SELECT trkorr FROM e071 WHERE trkorr = request~trkorr ) ) AND ( NOT EXISTS ( SELECT trkorr FROM e070 AS task WHERE strkorr = request~trkorr AND EXISTS ( SELECT trkorr FROM e071 WHERE trkorr = task~trkorr ) ) ) INTO TABLE @DATA(trkorr). LOOP AT trkorr ASSIGNING FIELD-SYMBOL(). CHECK NOT get_instance( -trkorr )->is_empty( ). DELETE trkorr. CONTINUE. ENDLOOP. IF trkorr IS INITIAL. RETURN. ENDIF. output = get_request_list( VALUE #( trkorr_rng = VALUE #( FOR _trkorr IN trkorr ( option = ycl_addict_toolkit=>option-eq sign = ycl_addict_toolkit=>sign-include low = _trkorr ) ) trstatus_rng = get_open_status_rng( ) srch_strkorr = abap_false ignore_trkorr = abap_false ) ). ENDMETHOD. METHOD get_header. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns request header """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF me->lazy_flag-e070 IS INITIAL. SELECT SINGLE * FROM e070 WHERE trkorr = @me->trkorr INTO CORRESPONDING FIELDS OF @me->lazy_val-e070. me->lazy_flag-e070 = abap_true. ENDIF. header = me->lazy_val-e070. ENDMETHOD. METHOD get_instance. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Factory """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ASSIGN ycl_addict_transport_request=>multitons[ KEY primary_key COMPONENTS trkorr = trkorr top = top ] TO FIELD-SYMBOL(). IF sy-subrc <> 0. DATA(mt) = VALUE multiton_dict( trkorr = trkorr top = top ). SELECT SINGLE trkorr, strkorr FROM e070 WHERE trkorr = @trkorr INTO @DATA(e070). IF sy-subrc <> 0. RAISE EXCEPTION TYPE ycx_addict_table_content EXPORTING textid = ycx_addict_table_content=>no_entry_for_objectid objectid = CONV #( trkorr ) tabname = ycl_addict_transport_request=>table-e070. ENDIF. mt-obj = NEW #( ). mt-obj->trkorr = SWITCH #( top WHEN abap_false THEN e070-trkorr WHEN abap_true THEN COND #( WHEN e070-strkorr IS NOT INITIAL THEN e070-strkorr ELSE e070-trkorr ) ). INSERT mt INTO TABLE ycl_addict_transport_request=>multitons ASSIGNING . ENDIF. output = -obj. ENDMETHOD. METHOD get_modified_objects. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns modified objects within the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA(req) = get_requests_containing_obj( obj = obj top = abap_true holistic_cls = abap_true ). DELETE req WHERE trkorr+0(3) <> sy-sysid. SORT req BY pgmid object obj_name. DELETE ADJACENT DUPLICATES FROM req COMPARING pgmid object obj_name. "" Binary Search LOOP AT obj ASSIGNING FIELD-SYMBOL(). READ TABLE req ASSIGNING FIELD-SYMBOL() WITH KEY pgmid = -pgmid object = -object obj_name = -obj_name BINARY SEARCH. IF sy-subrc = 0. APPEND TO output. CONTINUE. ENDIF. CHECK is_obj_type_class_related( CORRESPONDING #( ) ). LOOP AT req ASSIGNING WHERE obj_name+0(30) = -obj_name+0(30). APPEND CORRESPONDING #( ) TO output. ENDLOOP. CHECK sy-subrc = 0. APPEND TO output. ENDLOOP. ENDMETHOD. METHOD get_objects. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns objects within the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" objects = get_content( )-objects. DELETE objects WHERE NOT ( pgmid IN pgmid_rng AND object IN object_rng AND obj_name IN obj_name_rng ). IF NOT ( devclass_rng IS NOT INITIAL AND object IS NOT INITIAL ). RETURN. ENDIF. DATA(dc) = ycl_addict_package=>get_package_of_objects( CORRESPONDING #( objects ) ). LOOP AT objects ASSIGNING FIELD-SYMBOL(). ASSIGN dc[ KEY primary_key COMPONENTS key = VALUE #( pgmid = -pgmid object = -object obj_name = -obj_name ) ] TO FIELD-SYMBOL(). CHECK sy-subrc = 0 AND -devclass NOT IN devclass_rng. DELETE objects. CONTINUE. ENDLOOP. ENDMETHOD. METHOD get_obj_related_requests. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns requests related to the given objects """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" list = get_requests_containing_obj( obj = CORRESPONDING #( get_objects( obj_name_rng = obj_name_rng devclass_rng = devclass_rng ) ) top = top holistic_cls = holistic_cls trfunction_rng = trfunction_rng ). IF include_self = abap_true. RETURN. ENDIF. TRY. DATA(head) = get_header( ). DELETE list WHERE trkorr = head-trkorr OR trkorr = head-strkorr OR ( strkorr IS NOT INITIAL AND ( strkorr = head-trkorr OR strkorr = head-strkorr ) ). IF head-strkorr IS NOT INITIAL. DATA(shead) = get_instance( head-strkorr )->get_header( ). DELETE list WHERE trkorr = shead-trkorr OR strkorr = shead-trkorr. ENDIF. CATCH cx_root ##no_handler . ENDTRY. ENDMETHOD. METHOD get_open_requests. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns a list of corresponding open requests """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" output = get_request_list( VALUE #( trfunction_rng = COND #( WHEN trfunction_rng IS NOT INITIAL THEN trfunction_rng ELSE get_user_creatable_trf_rng( ) ) trstatus_rng = get_open_status_rng( ) as4text_rng = as4text_rng must_have_subtask = must_have_subtask ) ). ENDMETHOD. METHOD get_open_status_rng. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns a range of open request statuses """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" output = VALUE #( option = ycl_addict_toolkit=>option-eq sign = ycl_addict_toolkit=>sign-include ( low = ycl_addict_transport_request=>trstatus-modif ) ( low = ycl_addict_transport_request=>trstatus-modif_prot ) ). ENDMETHOD. METHOD get_requests_containing_obj. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns a list of requests which contain the provided objects """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA obj_name_rng TYPE RANGE OF e071-obj_name. DATA obj_name_tmp TYPE obj_name_list. CHECK obj IS NOT INITIAL. "" Find requests containing those objects """""""""""""""""""""""""""""""""""""""""""""""" build_dev_req_rng( ). SELECT trkorr, pgmid, object, obj_name FROM e071 FOR ALL ENTRIES IN @obj WHERE trkorr IN @ycl_addict_transport_request=>clazy_val-dev_req_rng AND pgmid = @obj-pgmid AND object = @obj-object AND obj_name = @obj-obj_name INTO TABLE @DATA(e071). "" Do holistic search if requested """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Holistic means: "" "" If the request contains X=>Y, any other request containing "" any other X artifact is also related. "" "" (X: Class, Y: Method, Type, etc.) """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF holistic_cls = abap_true. LOOP AT obj ASSIGNING FIELD-SYMBOL(). CHECK is_obj_type_class_related( CORRESPONDING #( ) ) = abap_true. CLEAR obj_name_tmp. SPLIT -obj_name AT space INTO TABLE obj_name_tmp. APPEND VALUE #( option = ycl_addict_toolkit=>option-cp sign = ycl_addict_toolkit=>sign-include low = |{ COND #( WHEN obj_name_tmp IS INITIAL THEN -obj_name ELSE obj_name_tmp[ 1 ] ) }*| ) TO obj_name_rng. ENDLOOP. SORT obj_name_rng BY option sign low high. DELETE ADJACENT DUPLICATES FROM obj_name_rng COMPARING option sign low high. IF obj_name_rng IS NOT INITIAL. SELECT trkorr, pgmid, object, obj_name FROM e071 WHERE trkorr IN @ycl_addict_transport_request=>clazy_val-dev_req_rng AND ( pgmid = @yif_addict_dol_obj=>pgmid-r3tr OR pgmid = @yif_addict_dol_obj=>pgmid-limu ) AND obj_name IN @obj_name_rng APPENDING CORRESPONDING FIELDS OF TABLE @e071. ""#EC CI_NOFIRST ENDIF. ENDIF. "" Build a list of found requests """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SORT e071 BY trkorr pgmid object obj_name. DELETE ADJACENT DUPLICATES FROM e071 COMPARING trkorr pgmid object obj_name. LOOP AT e071 ASSIGNING FIELD-SYMBOL(). TRY. DATA(found_request) = get_instance( trkorr = -trkorr top = top ). DATA(head) = found_request->get_header( ). APPEND VALUE #( trkorr = head-trkorr as4text = found_request->get_text( ) strkorr = head-strkorr pgmid = -pgmid object = -object obj_name = -obj_name ) TO req. CATCH cx_root ##no_Handler . ENDTRY. ENDLOOP. "" Filter by request type if wanted """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF trfunction_rng IS NOT INITIAL. LOOP AT req ASSIGNING FIELD-SYMBOL(). TRY. CHECK get_instance( trkorr = -trkorr top = abap_true )->get_header( )-trfunction NOT IN trfunction_rng. DELETE req. CONTINUE. CATCH cx_root ##no_handler. ENDTRY. ENDLOOP. ENDIF. ENDMETHOD. METHOD get_request_and_objects. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns corresponding requests with their contents """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" CHECK tags IS NOT INITIAL. SELECT e070~trkorr, e07t~as4text, e070~strkorr, e071~obj_name FROM e071 INNER JOIN e070 ON e070~trkorr = e071~trkorr LEFT JOIN e07t ON e07t~trkorr = e071~trkorr AND e07t~langu = @sy-langu FOR ALL ENTRIES IN @tags WHERE pgmid = @tags-pgmid AND object = @tags-object AND obj_name = @tags-obj_name INTO CORRESPONDING FIELDS OF TABLE @output ##TOO_MANY_ITAB_FIELDS . ENDMETHOD. METHOD get_request_list. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns a list of corresponding requests """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Raw list """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF param-ignore_trkorr = abap_false. SELECT e070~trkorr, e070~trfunction, e070~trstatus, e07t~as4text, e070~as4user, e070~strkorr, e070~as4date, e070~as4time, e070~tarsystem FROM e070 LEFT JOIN e07t ON e07t~trkorr = e070~trkorr WHERE e070~trkorr IN @param-trkorr_rng AND e070~trfunction IN @param-trfunction_rng AND e070~trstatus IN @param-trstatus_rng AND e070~as4date IN @param-as4date_rng AND e070~as4user IN @param-as4user_rng APPENDING CORRESPONDING FIELDS OF TABLE @output ##TOO_MANY_ITAB_FIELDS. ENDIF. IF param-srch_strkorr = abap_true. SELECT e070~trkorr, e070~trfunction, e070~trstatus, e07t~as4text, e070~as4user, e070~strkorr, e070~as4date, e070~as4time, e070~tarsystem FROM e070 LEFT JOIN e07t ON e07t~trkorr = e070~strkorr WHERE e070~strkorr IN @param-trkorr_rng AND e070~trfunction IN @param-trfunction_rng AND e070~trstatus IN @param-trstatus_rng AND e070~as4date IN @param-as4date_rng AND e070~as4user IN @param-as4user_rng APPENDING CORRESPONDING FIELDS OF TABLE @output ##TOO_MANY_ITAB_FIELDS. ENDIF. DELETE output WHERE as4text NOT IN param-as4text_rng. SORT output BY trkorr. DELETE ADJACENT DUPLICATES FROM output COMPARING trkorr. "" Subtask check """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF param-must_have_subtask = abap_true AND output IS NOT INITIAL. SELECT trkorr, strkorr FROM e070 FOR ALL ENTRIES IN @output WHERE strkorr = @output-trkorr AND trstatus IN (@ycl_addict_transport_request=>trstatus-modif, @ycl_addict_transport_request=>trstatus-modif_prot) INTO TABLE @data(task). SORT task BY strkorr. LOOP AT output ASSIGNING FIELD-SYMBOL(). READ TABLE task TRANSPORTING NO FIELDS WITH KEY strkorr = -trkorr BINARY SEARCH. CHECK sy-subrc <> 0. DELETE output. CONTINUE. ENDLOOP. ENDIF. "" Domain texts """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TRY. DATA(domain_trf) = ycl_addict_domain_line=>get_instance( ycl_addict_transport_request=>domain-trfunction ). LOOP AT output ASSIGNING . TRY. -trftxt = domain_trf->domain->get_value_text( CONV #( -trfunction ) ). CATCH cx_root ##no_Handler . ENDTRY. ENDLOOP. CATCH cx_root ##no_Handler. ENDTRY. ENDMETHOD. METHOD get_request_objects. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns objects within the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA trkorr TYPE RANGE OF e070-trkorr. CLEAR: list, list_wr. "" Detect requests """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SELECT @ycl_addict_toolkit=>option-eq AS option, @ycl_addict_toolkit=>sign-include AS sign, trkorr AS low FROM e070 WHERE trkorr IN @trkorr_rng OR strkorr IN @trkorr_rng APPENDING CORRESPONDING FIELDS OF TABLE @trkorr ##TOO_MANY_ITAB_FIELDS. SELECT @ycl_addict_toolkit=>option-eq AS option, @ycl_addict_toolkit=>sign-include AS sign, strkorr AS low FROM e070 WHERE trkorr IN @trkorr_rng OR strkorr IN @trkorr_rng APPENDING CORRESPONDING FIELDS OF TABLE @trkorr ##TOO_MANY_ITAB_FIELDS . SORT trkorr BY low. DELETE ADJACENT DUPLICATES FROM trkorr COMPARING low. IF trkorr IS INITIAL. RETURN. ENDIF. "" Detect objects """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA(active_pgmid_rng) = COND #( WHEN pgmid_rng IS SUPPLIED THEN pgmid_rng ELSE VALUE #( ( option = ycl_addict_toolkit=>option-eq sign = ycl_addict_toolkit=>sign-include low = yif_addict_dol_obj=>pgmid-r3tr ) ) ). SELECT DISTINCT e071~trkorr, e071~pgmid, e071~object, e071~obj_name, e07t~as4text FROM e071 LEFT JOIN e07t ON e07t~trkorr = e071~trkorr AND e07t~langu = @sy-langu WHERE e071~trkorr IN @trkorr AND e071~pgmid IN @active_pgmid_rng ORDER BY e071~pgmid, e071~object, e071~obj_name INTO CORRESPONDING FIELDS OF TABLE @list_wr ##too_many_itab_fields. DELETE ADJACENT DUPLICATES FROM list_wr COMPARING trkorr pgmid object obj_name. "" Correct object names """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" LOOP AT list_wr ASSIGNING FIELD-SYMBOL(). IF is_obj_type_class_related( CORRESPONDING #( ) ). DATA(main_pgmid) = ycl_addict_transport_request=>pgmid-r3tr. DATA(main_object) = ycl_addict_transport_request=>object-clas. DATA(main_obj_name) = CONV yd_addict_dol_obj_name( -obj_name+0(30) ). ELSE. main_pgmid = -pgmid. main_object = -object. main_obj_name = -obj_name. ENDIF. TRY. ycl_addict_dol_model=>get_dol_obj( EXPORTING object = main_object IMPORTING dol = DATA(dol) ). CATCH cx_root. CONTINUE. ENDTRY. IF dol->is_deleted( pgmid = main_pgmid object = main_object obj_name = main_obj_name ). DELETE list_wr. CONTINUE. ENDIF. -object_txt = dol->get_object_txt( pgmid = main_pgmid object = main_object ). -ddtext = dol->get_ddtext( pgmid = main_pgmid object = main_object obj_name = main_obj_name ). ENDLOOP. list = CORRESPONDING #( list_wr ). SORT list BY pgmid object obj_name. DELETE ADJACENT DUPLICATES FROM list COMPARING pgmid object obj_name. "" Created new? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF read_creation = abap_false. RETURN. ENDIF. DATA(e071_tmp) = CORRESPONDING e071tab( list_wr ). IF e071_tmp IS INITIAL. RETURN. ENDIF. SELECT e071~trkorr, e071~object, e071~obj_name, e070~strkorr, e070~as4date, e070~as4time FROM e071 INNER JOIN e070 ON e070~trkorr = e071~trkorr FOR ALL ENTRIES IN @e071_tmp WHERE e071~pgmid = @ycl_addict_transport_request=>pgmid-r3tr AND e071~object = @e071_tmp-object AND e071~obj_name = @e071_tmp-obj_name INTO TABLE @DATA(req_history). SORT req_history BY object obj_name as4date as4time. DELETE ADJACENT DUPLICATES FROM req_history COMPARING object obj_name. LOOP AT list_wr ASSIGNING FIELD-SYMBOL(). ASSIGN req_history[ object = -object obj_name = -obj_name ] TO FIELD-SYMBOL(). -creation = xsdbool( sy-subrc = 0 AND ( -trkorr = -trkorr OR -strkorr = -trkorr ) ). ENDLOOP. ENDMETHOD. METHOD get_source_client. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns the source client of the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF me->lazy_flag-source_client = abap_false. SELECT SINGLE client INTO me->lazy_val-source_client FROM e070c WHERE trkorr = me->trkorr. me->lazy_flag-source_client = abap_true. ENDIF. client = me->lazy_val-source_client. ENDMETHOD. METHOD get_source_client_safe. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns the source client of the request suppressing errors """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TRY. client = ycl_addict_transport_request=>get_instance( trkorr )->get_source_client( ). CATCH cx_root ##no_handler . ENDTRY. ENDMETHOD. METHOD get_subtasks. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns subtasks of the request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SELECT trkorr FROM e070 WHERE strkorr = @me->trkorr INTO CORRESPONDING FIELDS OF TABLE @subtask ##TOO_MANY_ITAB_FIELDS . LOOP AT subtask ASSIGNING FIELD-SYMBOL(). -obj = ycl_addict_transport_request=>get_instance( -trkorr ). IF only_empty = abap_true AND -obj->is_empty( ) = abap_false. DELETE subtask. CONTINUE. ENDIF. ENDLOOP. ENDMETHOD. METHOD get_text. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns text of request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF me->lazy_flag-as4text = abap_false. SELECT SINGLE as4text FROM e07t WHERE trkorr = @me->trkorr AND langu = @sy-langu INTO @me->lazy_val-as4text. IF sy-subrc <> 0. SELECT SINGLE as4text FROM e07t WHERE trkorr = @me->trkorr INTO @me->lazy_val-as4text ##WARN_OK. ""#EC CI_NOORDER ENDIF. me->lazy_flag-as4text = abap_true. ENDIF. as4text = me->lazy_val-as4text. ENDMETHOD. METHOD get_toc_safety_safe. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns TOC safety, suppressing errors """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TRY. safe = get_instance( trkorr )->is_toc_safe( ). CATCH cx_root ##no_Handler . ENDTRY. ENDMETHOD. METHOD get_user_creatable_trf_rng. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Returns a range of TR functions, which can be created by a user """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" func = VALUE #( option = ycl_addict_toolkit=>option-eq sign = ycl_addict_toolkit=>sign-include ( low = ycl_addict_transport_request=>trfunction-cust ) ( low = ycl_addict_transport_request=>trfunction-toc ) ( low = ycl_addict_transport_request=>trfunction-wb ) ). ENDMETHOD. METHOD has_locked_object. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Does the Request contain a locked object? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SELECT SINGLE lockflag FROM e071 WHERE trkorr = @me->trkorr AND lockflag = @abap_true INTO @data(dummy) ##WARN_OK. has = xsdbool( sy-subrc = 0 ). ENDMETHOD. METHOD has_merge. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Does the Request contain a merged Request? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TRY. DATA(content) = get_content( ). has = xsdbool( line_exists( content-objects[ pgmid = 'CORR' object = 'MERG' ] ) ). CATCH cx_root INTO DATA(diaper). RAISE EXCEPTION TYPE ycx_addict_data_read EXPORTING textid = ycx_addict_data_read=>cant_read_data_type previous = diaper objectid = CONV #( me->trkorr ) data_type = CONV #( TEXT-407 ). ENDTRY. ENDMETHOD. METHOD is_empty. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Is Request completely empty? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF me->lazy_flag-empty = abap_false. me->lazy_val-empty = boolc( get_content( ) IS INITIAL ). me->lazy_flag-empty = abap_true. ENDIF. empty = me->lazy_val-empty. ENDMETHOD. METHOD is_obj_type_class_related. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Is the provided object type related to a class? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF ycl_addict_transport_request=>clazy_flag-class_related_obj_tags = abap_false. ycl_addict_transport_request=>clazy_val-class_related_obj_tag = VALUE #( ( pgmid = ycl_addict_transport_request=>pgmid-limu object = ycl_addict_transport_request=>object-cinc ) ( pgmid = ycl_addict_transport_request=>pgmid-limu object = ycl_addict_transport_request=>object-clsd ) ( pgmid = ycl_addict_transport_request=>pgmid-limu object = ycl_addict_transport_request=>object-cpri ) ( pgmid = ycl_addict_transport_request=>pgmid-limu object = ycl_addict_transport_request=>object-cpub ) ( pgmid = ycl_addict_transport_request=>pgmid-limu object = ycl_addict_transport_request=>object-meth ) ( pgmid = ycl_addict_transport_request=>pgmid-r3tr object = ycl_addict_transport_request=>object-clas ) ( pgmid = ycl_addict_transport_request=>pgmid-r3tr object = ycl_addict_transport_request=>object-intf ) ). ycl_addict_transport_request=>clazy_flag-class_related_obj_tags = abap_true. ENDIF. related = xsdbool( line_exists( ycl_addict_transport_request=>clazy_val-class_related_obj_tag[ KEY primary_key COMPONENTS pgmid = obj_type-pgmid object = obj_type-object ] ) ). ENDMETHOD. METHOD is_toc_safe. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Is this Request safe enough to be included in a ToC? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF me->lazy_flag-toc_safe = abap_false. DATA(rules) = ycl_addict_toolkit=>get_system_rules( ). me->lazy_val-toc_safe = rules->is_request_toc_safe( me->trkorr ). me->lazy_flag-toc_safe = abap_true. ENDIF. safe = me->lazy_val-toc_safe. ENDMETHOD. METHOD release. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Release the Request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" CLEAR rel_wait_success. DATA(wait_success) = VALUE abap_bool_list( ). IF del_empty_subtasks = abap_true. delete_empty_subtasks( ). ENDIF. "" Release subtasks if wanted """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA(max_wait) = COND i( WHEN max_rel_wait IS NOT INITIAL THEN max_rel_wait ELSE ycl_addict_toolkit=>get_system_definitions( )-max_wait ). IF rel_subtasks_too = abap_true. DATA(sub) = get_subtasks( ). LOOP AT sub ASSIGNING FIELD-SYMBOL(). release_single( EXPORTING trkorr = -trkorr req = -obj wait_until_released = wait_until_released max_rel_wait = max_wait compl_sh_piece_list = compl_sh_piece_list IMPORTING rel_wait_success = DATA(this_wait_success) ). APPEND this_wait_success TO wait_success. CLEAR this_wait_success. ENDLOOP. ENDIF. "" Release the Request itself """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" release_single( EXPORTING trkorr = me->trkorr req = me wait_until_released = wait_until_released max_rel_wait = max_rel_wait compl_sh_piece_list = compl_sh_piece_list IMPORTING rel_wait_success = this_wait_success ). APPEND this_wait_success TO wait_success. CLEAR this_wait_success. "" Success? """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SORT wait_success BY table_line. DELETE ADJACENT DUPLICATES FROM wait_success COMPARING table_line. rel_wait_success = xsdbool( wait_until_released = abap_true AND wait_success IS NOT INITIAL AND ( NOT line_exists( wait_success[ table_line = abap_false ] ) ) ). ENDMETHOD. METHOD release_single. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Releases a single request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" DATA request TYPE REF TO ycl_addict_transport_request. CLEAR rel_wait_success. "" Detect & check request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" request = COND #( WHEN req IS INITIAL THEN get_instance( trkorr ) ELSE req ). IF NOT request->get_header( )-trstatus IN get_open_status_rng( ). RETURN. ENDIF. "" Complete piece list """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF compl_sh_piece_list = abap_true. TRY. request->complete_shi_piece_list( ). CATCH cx_root ##no_handler. ENDTRY. ENDIF. "" Release """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" CALL FUNCTION 'TR_RELEASE_REQUEST' EXPORTING iv_trkorr = trkorr iv_dialog = abap_true iv_as_background_job = abap_false iv_success_message = abap_false iv_display_export_log = abap_false iv_simulation = abap_false EXCEPTIONS cts_initialization_failure = 1 enqueue_failed = 2 no_authorization = 3 invalid_request = 4 request_already_released = 5 repeat_too_early = 6 error_in_export_methods = 7 object_check_error = 8 docu_missing = 9 db_access_error = 10 action_aborted_by_user = 11 export_failed = 12 OTHERS = 13 ##FM_SUBRC_OK ##NUMBER_OK. IF sy-subrc <> 5. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TR_RELEASE_REQUEST' ). ENDIF. "" Wait until released (if wanted) """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" IF wait_until_released = abap_true. DATA(max_wait) = COND i( WHEN max_rel_wait IS NOT INITIAL THEN max_rel_wait ELSE ycl_addict_toolkit=>get_system_definitions( )-max_wait ). DATA(total_wait) = 0. DO. IF request->has_locked_object( ) = abap_false. rel_wait_success = abap_true. EXIT. ENDIF. WAIT UP TO 1 SECONDS. ADD 1 TO total_wait. CHECK total_wait > max_wait. rel_wait_success = abap_false. EXIT. ENDDO. ENDIF. ENDMETHOD. METHOD sort_and_compress. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "" Sort and compress request """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TRY. CALL FUNCTION 'TRINT_SORT_AND_COMPRESS_COMM' EXPORTING iv_trkorr = me->trkorr EXCEPTIONS request_doesnt_exist = 1 request_released = 2 no_authorization = 3 update_error = 4 OTHERS = 5 ##FM_SUBRC_OK. IF sy-subrc <> 2. ycx_addict_function_subrc=>raise_if_sysubrc_not_initial( 'TRINT_SORT_AND_COMPRESS_COMM' ). ENDIF. CATCH cx_root INTO DATA(diaper). RAISE EXCEPTION TYPE ycx_addict_sort_and_compress EXPORTING textid = ycx_addict_sort_and_compress=>soc_function_error previous = diaper trkorr = me->trkorr. ENDTRY. ENDMETHOD. ENDCLASS. ",16361,True,3706.8563250536126,median "CLASS zbag DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES if_oo_adt_classrun. METHODS count_bags IMPORTING color TYPE string RETURNING VALUE(number) TYPE i. METHODS set_rules IMPORTING i_rules TYPE string. METHODS contains_bags IMPORTING color TYPE string RETURNING VALUE(bags) TYPE i. PROTECTED SECTION. PRIVATE SECTION. DATA: rules_table TYPE string_table. METHODS build_riddle RETURNING VALUE(riddle) TYPE string. METHODS get_bags_that_contain IMPORTING color TYPE string RETURNING VALUE(bag_tab) TYPE string_table. ENDCLASS. CLASS zbag IMPLEMENTATION. METHOD count_bags. DATA bag_color_tab TYPE string_table. bag_color_tab = get_bags_that_contain( color ). LOOP AT bag_color_tab INTO DATA(bag). APPEND LINES OF get_bags_that_contain( bag ) TO bag_color_tab. ENDLOOP. SORT bag_color_tab. DELETE ADJACENT DUPLICATES FROM bag_color_tab. number = lines( bag_color_tab ). ENDMETHOD. METHOD set_rules. SPLIT i_rules AT cl_abap_char_utilities=>newline INTO TABLE rules_table. ENDMETHOD. METHOD get_bags_that_contain. DATA(pattern) = |*contain*{ color }*.|. LOOP AT rules_table INTO DATA(rule) WHERE table_line CP pattern. DATA(bag_color) = substring_before( val = rule sub = ' bags contain' ). IF NOT line_exists( bag_tab[ table_line = bag_color ] ). APPEND bag_color TO bag_tab. ENDIF. ENDLOOP. ENDMETHOD. METHOD if_oo_adt_classrun~main. set_rules( build_riddle( ) ). out->write( |Bags that contain at least one shiny gold bag: | && count_bags( 'shiny gold' ) ). out->write( |Shiny gold bag contains: | && contains_bags( 'shiny gold' ) ). ENDMETHOD. METHOD contains_bags. DATA(pattern) = |{ color } bags contain* |. FIND REGEX pattern IN TABLE me->rules_table RESULTS DATA(found). CHECK found IS NOT INITIAL. DATA(rule) = rules_table[ found-line ]. CHECK NOT rule CS 'no other bags.'. DATA(content) = substring_after( val = rule sub = 'contain ' ). SPLIT content AT ', ' INTO TABLE DATA(contents). bags = REDUCE #( INIT b = 0 FOR cnt IN contents NEXT b += CONV i( substring_before( val = condense( cnt ) regex = '\\s' ) ) + CONV i( substring_before( val = condense( cnt ) regex = '\\s' ) ) * contains_bags( substring_before( val = substring_after( val = condense( cnt ) regex = '\\d\\s' ) sub = ' bag' ) ) ). ENDMETHOD. METHOD build_riddle. riddle = |dim red bags contain 2 bright gold bags, 5 striped fuchsia bags.\\n| && |dotted purple bags contain 5 bright olive bags, 3 faded maroon bags.\\n| && |plaid chartreuse bags contain 1 vibrant olive bag, 5 bright black bags, 1 clear tomato bag.\\n| && |wavy orange bags contain 4 dark lavender bags, 4 posh white bags.\\n| && |light lavender bags contain 4 drab olive bags, 5 dark magenta bags.\\n| && |pale black bags contain 5 dotted beige bags, 5 clear chartreuse bags, 4 pale lime bags.\\n| && |wavy crimson bags contain 5 dull tomato bags.\\n| && |muted aqua bags contain 1 dotted aqua bag, 5 posh plum bags, 1 bright blue bag.\\n| && |striped green bags contain 3 light silver bags, 2 plaid purple bags.\\n| && |plaid cyan bags contain 3 pale maroon bags, 2 bright yellow bags.\\n| && |dull maroon bags contain 2 wavy black bags, 2 plaid tomato bags, 2 dim silver bags, 3 plaid salmon bags.\\n| && |bright gold bags contain 4 wavy olive bags, 3 muted gray bags, 4 dark indigo bags, 5 dark chartreuse bags.\\n| && |drab blue bags contain 1 light green bag.\\n| && |muted brown bags contain 4 dark red bags, 5 dull aqua bags, 4 drab blue bags.\\n| && |bright olive bags contain 5 dim salmon bags, 4 dotted beige bags, 2 pale bronze bags.\\n| && |mirrored red bags contain 3 mirrored chartreuse bags, 3 muted gold bags, 5 bright beige bags, 4 dim green bags.\\n| && |pale gray bags contain 4 vibrant tomato bags.\\n| && |striped purple bags contain 5 dotted gray bags.\\n| && |light brown bags contain 1 shiny silver bag, 3 plaid olive bags, 1 clear tan bag.\\n| && |dim tan bags contain 1 posh black bag, 3 faded maroon bags, 5 bright gray bags.\\n| && |faded fuchsia bags contain 5 posh fuchsia bags, 3 drab salmon bags, 1 posh orange bag.\\n| && |dim gray bags contain 4 bright crimson bags, 5 dotted salmon bags, 2 plaid indigo bags.\\n| && |bright tan bags contain 2 posh lime bags.\\n| && |faded olive bags contain 5 light fuchsia bags, 1 shiny orange bag, 4 posh lavender bags.\\n| && |vibrant indigo bags contain 3 vibrant turquoise bags, 4 faded magenta bags, 4 pale red bags, 4 mirrored turquoise bags.\\n| && |clear salmon bags contain 3 pale maroon bags, 5 drab green bags, 1 light green bag.\\n| && |clear maroon bags contain 2 pale black bags, 5 dark coral bags, 3 dark purple bags, 2 vibrant blue bags.\\n| && |clear olive bags contain 2 muted brown bags.\\n| && |drab bronze bags contain 3 wavy brown bags, 4 posh lime bags, 1 mirrored beige bag.\\n| && |dull red bags contain 3 dark cyan bags, 5 bright indigo bags, 4 clear brown bags, 5 plaid violet bags.\\n| && |vibrant green bags contain 3 clear brown bags, 5 plaid yellow bags, 4 vibrant crimson bags.\\n| && |dark bronze bags contain 5 dark silver bags.\\n| && |mirrored orange bags contain 2 shiny crimson bags, 3 clear tomato bags, 1 muted crimson bag.\\n| && |pale yellow bags contain 1 bright olive bag.\\n| && |dotted teal bags contain 1 plaid olive bag, 2 drab white bags.\\n| && |dull tan bags contain 2 faded aqua bags, 3 muted green bags.\\n| && |clear crimson bags contain 3 dark purple bags.\\n| && |light violet bags contain 3 pale beige bags, 2 mirrored silver bags.\\n| && |muted green bags contain 2 wavy brown bags, 3 dull gray bags, 4 drab tan bags, 3 plaid teal bags.\\n| && |mirrored beige bags contain no other bags.\\n| && |dotted silver bags contain 1 vibrant green bag.\\n| && |drab fuchsia bags contain 1 vibrant bronze bag, 1 striped fuchsia bag, 1 dotted beige bag.\\n| && |dim beige bags contain 4 dotted cyan bags, 4 vibrant fuchsia bags, 5 dull violet bags.\\n| && |shiny fuchsia bags contain 4 pale gold bags, 3 mirrored crimson bags, 4 plaid gold bags, 5 shiny yellow bags.\\n| && |dark yellow bags contain 2 faded chartreuse bags.\\n| && |light chartreuse bags contain 1 plaid blue bag, 5 dim green bags, 1 faded chartreuse bag.\\n| && |dull beige bags contain 2 wavy tomato bags, 1 striped yellow bag.\\n| && |clear tan bags contain 4 plaid yellow bags, 1 posh cyan bag, 2 dim silver bags.\\n| && |posh lime bags contain 3 pale brown bags, 5 dim tomato bags.\\n| && |dim aqua bags contain 4 plaid lavender bags, 5 striped violet bags, 4 plaid chartreuse bags.\\n| && |light salmon bags contain 4 striped red bags, 2 wavy indigo bags, 2 light tomato bags, 1 dark cyan bag.\\n| && |vibrant yellow bags contain 1 plaid blue bag, 3 dotted violet bags, 2 wavy red bags, 5 drab beige bags.\\n| && |drab white bags contain 4 faded tan bags.\\n| && |light gray bags contain 3 plaid gold bags, 2 light green bags, 5 dim blue bags, 4 posh turquoise bags.\\n| && |dull magenta bags contain 5 mirrored salmon bags, 1 mirrored chartreuse bag, 3 dull gray bags.\\n| && |striped tan bags contain 5 plaid red bags, 2 dim chartreuse bags, 3 muted tomato bags.\\n| && |shiny turquoise bags contain 1 drab gold bag, 5 posh teal bags, 2 vibrant bronze bags, 2 vibrant chartreuse bags.\\n| && |bright lime bags contain 1 drab olive bag, 3 dark blue bags, 2 mirrored lavender bags, 4 shiny indigo bags.\\n| && |mirrored lavender bags contain no other bags.\\n| && |pale white bags contain 1 plaid tan bag.\\n| && |wavy blue bags contain 2 light tomato bags, 4 dim bronze bags, 1 plaid green bag, 2 dark maroon bags.\\n| && |muted beige bags contain 1 bright black bag, 4 dull magenta bags, 2 shiny indigo bags.\\n| && |light purple bags contain 3 bright violet bags, 2 vibrant crimson bags.\\n| && |mirrored cyan bags contain 1 wavy salmon bag, 2 vibrant green bags, 1 muted coral bag, 2 drab bronze bags.\\n| && |faded coral bags contain 2 drab bronze bags, 2 wavy beige bags, 5 clear blue bags.\\n| && |wavy aqua bags contain 4 dotted beige bags.\\n| && |striped maroon bags contain 2 clear indigo bags, 4 pale black bags.\\n| && |dark white bags contain 1 vibrant green bag, 2 vibrant crimson bags.\\n| && |dim teal bags contain 1 pale plum bag.\\n| && |muted red bags contain 4 plaid maroon bags.\\n| && |plaid lavender bags contain 2 posh gold bags, 1 dark blue bag, 4 muted gold bags.\\n| && |drab crimson bags contain 2 dull green bags, 3 vibrant orange bags, 4 bright gray bags.\\n| && |posh aqua bags contain 1 dotted fuchsia bag, 5 posh turquoise bags.\\n| && |muted maroon bags contain 4 drab green bags, 5 pale plum bags, 4 shiny indigo bags, 1 light chartreuse bag.\\n| && |posh indigo bags contain 2 dim blue bags.\\n| && |light magenta bags contain 4 muted black bags, 1 muted green bag.\\n| && |dark plum bags contain 2 pale tomato bags, 2 dark maroon bags.\\n| && |faded lavender bags contain 2 bright magenta bags.\\n| && |light silver bags contain 2 pale red bags, 5 vibrant plum bags, 3 posh indigo bags.\\n| && |light plum bags contain 1 light red bag, 1 mirrored chartreuse bag, 1 dark cyan bag.\\n| && |plaid bronze bags contain 4 muted turquoise bags, 4 mirrored blue bags, 4 faded yellow bags, 1 pale bronze bag.\\n| && |striped cyan bags contain 4 posh black bags, 5 light maroon bags.\\n| && |striped magenta bags contain 5 faded brown bags, 4 pale aqua bags, 5 wavy brown bags.\\n| && |plaid olive bags contain 5 vibrant green bags, 2 posh plum bags.\\n| && |light maroon bags contain 4 muted tomato bags, 1 shiny lavender bag.\\n| && |mirrored salmon bags contain 2 dull tomato bags, 5 pale crimson bags, 2 striped yellow bags, 1 drab salmon bag.\\n| && |mirrored bronze bags contain 5 posh orange bags.\\n| && |muted black bags contain 2 light white bags, 5 wavy black bags, 5 wavy maroon bags.\\n| && |drab plum bags contain 5 light indigo bags, 5 dull silver bags, 3 dim green bags, 2 dim silver bags.\\n| && |light green bags contain no other bags.\\n| && |posh salmon bags contain 3 bright lime bags.\\n| && |light beige bags contain 1 faded indigo bag, 4 faded teal bags, 1 dark green bag, 3 vibrant bronze bags.\\n| && |light gold bags contain 4 pale black bags, 4 dotted white bags, 5 striped gray bags.\\n| && |pale lime bags contain 2 drab blue bags, 4 wavy beige bags, 3 striped red bags, 5 shiny purple bags.\\n| && |striped crimson bags contain 5 muted white bags, 3 plaid coral bags.\\n| && |dull aqua bags contain 2 vibrant maroon bags, 4 posh gold bags.\\n| && |mirrored indigo bags contain 4 wavy white bags.\\n| && |clear green bags contain 2 light white bags.\\n| && |clear gray bags contain 3 dull coral bags, 4 dim fuchsia bags.\\n| && |dim coral bags contain 1 muted olive bag.\\n| && |dark indigo bags contain 5 faded chartreuse bags, 4 dark red bags, 4 shiny indigo bags, 3 plaid blue bags.\\n| && |plaid purple bags contain 4 striped blue bags, 4 dark beige bags, 1 drab silver bag, 5 dotted blue bags.\\n| && |faded tan bags contain 4 wavy fuchsia bags, 2 mirrored beige bags, 5 dim chartreuse bags.\\n| && |faded white bags contain 1 plaid teal bag, 5 dark red bags, 4 dim olive bags, 2 dim bronze bags.\\n| && |dotted chartreuse bags contain 2 muted purple bags, 4 posh gold bags.\\n| && |dull plum bags contain 3 dark lime bags.\\n| && |dull lime bags contain 2 bright teal bags, 1 vibrant aqua bag, 4 plaid yellow bags, 2 vibrant silver bags.\\n| && |dim violet bags contain 4 wavy white bags, 3 vibrant aqua bags, 4 clear tomato bags.\\n| && |dotted olive bags contain 1 clear gray bag, 1 dotted fuchsia bag, 3 wavy tomato bags, 4 bright maroon bags.\\n| && |mirrored olive bags contain 4 drab salmon bags, 4 light indigo bags.\\n| && |wavy brown bags contain 5 wavy beige bags.\\n| && |drab salmon bags contain 4 wavy maroon bags, 5 bright purple bags.\\n| && |bright indigo bags contain 4 mirrored tomato bags.\\n| && |plaid violet bags contain 3 shiny white bags, 1 posh crimson bag.\\n| && |drab lavender bags contain 2 vibrant gold bags, 5 faded aqua bags.\\n| && |clear red bags contain 3 dotted plum bags, 4 striped crimson bags.\\n| && |vibrant salmon bags contain 2 light maroon bags, 1 light olive bag, 1 mirrored tomato bag.\\n| && |faded beige bags contain 3 plaid blue bags.\\n| && |vibrant magenta bags contain 2 vibrant black bags, 5 drab lavender bags, 4 dull indigo bags, 3 faded indigo bags.\\n| && |shiny lavender bags contain 4 drab gold bags, 4 plaid violet bags.\\n| && |striped coral bags contain 5 vibrant green bags.\\n| && |dotted green bags contain 1 wavy maroon bag, 1 wavy white bag, 4 striped fuchsia bags.\\n| && |dull purple bags contain 1 posh lavender bag, 5 posh brown bags, 1 plaid gray bag, 2 clear red bags.\\n| && |mirrored teal bags contain 4 posh chartreuse bags.\\n| && |faded lime bags contain 5 dark gray bags, 5 light purple bags, 3 dotted magenta bags, 1 mirrored blue bag.\\n| && |striped olive bags contain 3 clear purple bags, 2 light cyan bags, 5 mirrored chartreuse bags, 4 plaid cyan bags.\\n| && |dark cyan bags contain 5 faded violet bags, 4 clear brown bags, 3 shiny gold bags.\\n| && |mirrored tan bags contain 5 dim green bags, 5 clear brown bags.\\n| && |wavy maroon bags contain 3 pale lime bags, 1 muted brown bag.\\n| && |posh brown bags contain 3 wavy salmon bags, 1 shiny tan bag, 1 plaid tomato bag.\\n| && |mirrored lime bags contain 5 muted tomato bags.\\n| && |clear teal bags contain 3 muted lavender bags, 3 dotted fuchsia bags.\\n| && |dim silver bags contain 4 drab green bags, 5 striped yellow bags, 3 vibrant maroon bags.\\n| && |dim indigo bags contain 4 plaid blue bags, 3 bright brown bags.\\n| && |vibrant tomato bags contain 1 dim violet bag, 3 clear gray bags.\\n| && |wavy white bags contain 4 bright purple bags, 4 vibrant orange bags, 2 wavy yellow bags, 3 drab blue bags.\\n| && |plaid beige bags contain 4 shiny white bags, 4 drab chartreuse bags, 1 bright orange bag.\\n| && |pale fuchsia bags contain 1 plaid cyan bag, 3 striped coral bags, 5 muted violet bags, 3 wavy brown bags.\\n| && |posh plum bags contain 5 dotted brown bags, 5 muted green bags.\\n| && |dim gold bags contain 5 mirrored lavender bags.\\n| && |plaid aqua bags contain 3 drab magenta bags.\\n| && |dotted tan bags contain 3 dull tan bags, 4 pale lime bags, 5 wavy teal bags.\\n| && |faded bronze bags contain 4 dull silver bags, 3 dim cyan bags, 5 posh chartreuse bags, 4 pale maroon bags.\\n| && |wavy green bags contain 5 plaid teal bags, 2 bright teal bags.\\n| && |clear orange bags contain 5 faded yellow bags, 2 mirrored salmon bags, 3 faded coral bags, 4 clear tan bags.\\n| && |wavy lavender bags contain 3 dotted magenta bags, 5 wavy tomato bags, 1 pale maroon bag, 4 dull brown bags.\\n| && |striped chartreuse bags contain 5 dotted orange bags, 2 wavy black bags.\\n| && |wavy plum bags contain 2 dark tomato bags, 5 dim blue bags, 4 shiny violet bags.\\n| && |shiny blue bags contain 2 vibrant green bags.\\n| && |pale tomato bags contain 2 faded chartreuse bags.\\n| && |clear fuchsia bags contain 1 light lime bag, 2 shiny lavender bags.\\n| && |muted cyan bags contain 3 vibrant purple bags, 5 posh cyan bags, 4 muted red bags, 4 shiny indigo bags.\\n| && |dull cyan bags contain 1 striped black bag.\\n| && |light turquoise bags contain 5 plaid orange bags, 2 striped yellow bags.\\n| && |clear lime bags contain 4 drab fuchsia bags.\\n| && |vibrant lavender bags contain 4 drab olive bags.\\n| && |plaid crimson bags contain 1 vibrant cyan bag, 5 striped gray bags, 2 drab gray bags.\\n| && |shiny yellow bags contain 5 dark red bags, 1 shiny crimson bag.\\n| && |faded cyan bags contain 2 striped tan bags, 5 pale magenta bags.\\n| && |light coral bags contain 1 plaid gray bag, 3 plaid magenta bags, 5 faded tan bags, 5 clear blue bags.\\n| && |pale blue bags contain 5 vibrant silver bags, 5 pale black bags, 4 dotted red bags.\\n| && |dim fuchsia bags contain 1 posh lime bag, 2 bright purple bags, 4 clear tan bags, 1 light green bag.\\n| && |muted coral bags contain 5 dark indigo bags, 5 posh plum bags.\\n| && |plaid gray bags contain 2 dark crimson bags, 3 vibrant aqua bags, 1 posh lime bag, 5 faded bronze bags.\\n| && |dotted cyan bags contain 4 vibrant maroon bags, 3 dull gray bags, 2 dark red bags, 3 pale magenta bags.\\n| && |wavy coral bags contain 3 plaid maroon bags, 4 plaid gold bags, 1 posh lavender bag.\\n| && |bright crimson bags contain 5 faded bronze bags, 1 dark cyan bag, 4 shiny purple bags, 5 drab gold bags.\\n| && |drab lime bags contain 1 dim cyan bag, 3 shiny coral bags, 3 light crimson bags.\\n| && |drab red bags contain 3 dim silver bags, 3 dim purple bags.\\n| && |dark red bags contain 5 muted gold bags.\\n| && |pale coral bags contain 2 posh violet bags.\\n| && |bright purple bags contain 4 mirrored lavender bags, 1 bright lime bag, 4 posh gold bags.\\n| && |bright brown bags contain 3 faded aqua bags, 2 dull black bags, 4 striped magenta bags.\\n| && |faded violet bags contain 5 pale maroon bags, 4 wavy maroon bags, 3 dull gray bags, 4 posh gold bags.\\n| && |dark crimson bags contain 3 clear silver bags, 3 muted silver bags, 1 faded aqua bag, 5 drab gold bags.\\n| && |dotted red bags contain 2 drab gray bags, 4 clear bronze bags.\\n| && |pale bronze bags contain 4 shiny salmon bags, 5 drab bronze bags, 4 dull gray bags.\\n| && |plaid silver bags contain 5 wavy black bags, 1 muted plum bag, 5 posh blue bags.\\n| && |posh green bags contain 5 shiny white bags, 5 dotted fuchsia bags, 2 pale black bags.\\n| && |dotted orange bags contain 5 plaid red bags.\\n| && |bright red bags contain 1 faded beige bag.\\n| && |pale brown bags contain no other bags.\\n| && |drab magenta bags contain 4 dark indigo bags, 5 striped violet bags, 5 bright tan bags, 4 posh salmon bags.\\n| && |striped indigo bags contain 3 dotted indigo bags, 3 dim lavender bags, 1 wavy yellow bag, 4 pale gold bags.\\n| && |dark tomato bags contain 4 wavy yellow bags, 3 vibrant lavender bags, 1 bright black bag.\\n| && |wavy tomato bags contain 1 wavy green bag, 2 plaid red bags, 5 wavy yellow bags.\\n| && |dotted aqua bags contain 1 drab green bag, 4 clear chartreuse bags, 5 plaid yellow bags.\\n| && |faded black bags contain 5 clear lavender bags.\\n| && |muted gray bags contain 2 pale brown bags, 1 bright tan bag.\\n| && |bright green bags contain 1 light olive bag.\\n| && |wavy yellow bags contain 5 dark red bags.\\n| && |dark coral bags contain 4 mirrored turquoise bags, 3 dark maroon bags.\\n| && |shiny green bags contain 3 posh turquoise bags, 3 striped yellow bags, 1 bright lime bag, 4 dotted white bags.\\n| && |vibrant teal bags contain 1 shiny magenta bag, 5 light maroon bags.\\n| && |shiny bronze bags contain 5 pale brown bags.\\n| && |mirrored gold bags contain 3 shiny crimson bags, 3 muted turquoise bags, 4 striped fuchsia bags, 3 vibrant lavender bags.\\n| && |dotted salmon bags contain 2 dim lime bags, 4 pale tomato bags.\\n| && |dotted gold bags contain 1 drab magenta bag, 4 clear fuchsia bags, 3 shiny violet bags, 2 dark indigo bags.\\n| && |muted olive bags contain 4 mirrored olive bags.\\n| && |pale green bags contain 2 plaid magenta bags, 2 bright lavender bags.\\n| && |clear lavender bags contain 2 vibrant gold bags, 5 clear silver bags.\\n| && |dark brown bags contain 4 plaid coral bags, 1 dark tan bag, 3 dotted bronze bags.\\n| && |dotted brown bags contain 2 wavy brown bags, 1 wavy beige bag.\\n| && |wavy gray bags contain 4 pale turquoise bags.\\n| && |pale olive bags contain 1 plaid gray bag, 1 striped coral bag.\\n| && |pale salmon bags contain 4 striped gray bags, 4 striped tomato bags, 1 bright bronze bag.\\n| && |vibrant violet bags contain 5 bright red bags, 5 posh coral bags, 1 wavy aqua bag.\\n| && |shiny maroon bags contain 5 clear indigo bags, 1 striped lavender bag.\\n| && |vibrant red bags contain 5 mirrored beige bags, 5 wavy indigo bags, 2 light coral bags, 1 mirrored salmon bag.\\n| && |posh yellow bags contain 5 drab gray bags, 1 dark silver bag, 3 pale maroon bags.\\n| && |clear white bags contain 2 drab olive bags.\\n| && |posh red bags contain 1 faded teal bag, 2 wavy crimson bags, 4 vibrant beige bags.\\n| && |striped plum bags contain 4 striped purple bags, 2 pale red bags.\\n| && |drab violet bags contain 1 wavy black bag.\\n| && |posh orange bags contain 1 pale crimson bag, 5 pale magenta bags, 3 dull olive bags.\\n| && |clear bronze bags contain 2 clear aqua bags, 5 mirrored plum bags, 2 pale crimson bags.\\n| && |plaid white bags contain 2 faded cyan bags, 3 vibrant green bags, 5 wavy red bags.\\n| && |vibrant chartreuse bags contain 1 bright red bag, 2 bright gray bags, 5 faded bronze bags, 3 vibrant crimson bags.\\n| && |dim bronze bags contain 4 dull tomato bags, 2 pale gold bags, 2 striped yellow bags.\\n| && |plaid yellow bags contain 1 pale plum bag, 4 bright purple bags, 1 bright lavender bag.\\n| && |light orange bags contain 3 drab bronze bags, 5 wavy coral bags, 4 bright purple bags, 3 dark magenta bags.\\n| && |faded magenta bags contain 4 clear tomato bags, 2 drab fuchsia bags, 1 dull gray bag.\\n| && |mirrored magenta bags contain 5 vibrant maroon bags, 3 light fuchsia bags, 1 drab olive bag.\\n| && |dark teal bags contain 3 shiny chartreuse bags, 5 mirrored fuchsia bags, 4 bright green bags.\\n| && |dull teal bags contain 1 bright salmon bag, 1 mirrored salmon bag.\\n| && |bright silver bags contain 1 shiny fuchsia bag, 4 dotted blue bags, 5 posh indigo bags.\\n| && |dull orange bags contain 2 striped purple bags, 3 muted green bags, 2 vibrant indigo bags.\\n| && |dim purple bags contain 1 posh chartreuse bag, 1 dark chartreuse bag, 4 faded indigo bags, 4 bright purple bags.\\n| && |pale cyan bags contain 1 mirrored gray bag, 2 muted beige bags, 2 plaid lime bags.\\n| && |vibrant gray bags contain 2 mirrored lavender bags, 1 light tomato bag, 3 clear indigo bags.\\n| && |dark olive bags contain 1 dim fuchsia bag, 4 plaid teal bags, 1 plaid gold bag, 5 plaid coral bags.\\n| && |faded green bags contain 3 pale olive bags, 1 shiny crimson bag, 2 faded silver bags.\\n| && |muted plum bags contain 5 dotted white bags, 2 plaid coral bags, 5 dim purple bags, 2 dim fuchsia bags.\\n| && |dim blue bags contain 3 pale silver bags.\\n| && |dark orange bags contain 3 dull crimson bags, 2 mirrored tan bags.\\n| && |bright blue bags contain 4 dark turquoise bags.\\n| && |bright black bags contain 3 mirrored lavender bags, 5 mirrored blue bags, 1 faded violet bag.\\n| && |light olive bags contain 1 pale beige bag, 1 wavy maroon bag, 5 pale crimson bags, 1 striped gray bag.\\n| && |shiny teal bags contain 2 bright white bags.\\n| && |posh gold bags contain 1 dark blue bag.\\n| && |dull crimson bags contain 2 dim bronze bags.\\n| && |muted gold bags contain no other bags.\\n| && |striped turquoise bags contain 1 pale silver bag.\\n| && |posh olive bags contain 5 drab salmon bags, 2 striped coral bags.\\n| && |dim white bags contain 2 vibrant aqua bags, 3 bright green bags, 5 vibrant maroon bags, 4 dim tomato bags.\\n| && |pale plum bags contain 5 bright purple bags.\\n| && |shiny silver bags contain 1 plaid bronze bag, 3 plaid blue bags.\\n| && |muted lime bags contain 1 dull lime bag.\\n| && |shiny plum bags contain 2 bright teal bags, 1 striped yellow bag.\\n| && |plaid black bags contain 1 bright purple bag.\\n| && |dark gold bags contain 5 faded magenta bags, 1 shiny tan bag, 1 muted crimson bag.\\n| && |wavy chartreuse bags contain 5 faded beige bags, 3 faded crimson bags.\\n| && |light cyan bags contain 4 drab chartreuse bags, 1 clear gray bag, 5 clear indigo bags, 4 vibrant black bags.\\n| && |pale red bags contain 2 dark gray bags.\\n| && |clear yellow bags contain 2 drab black bags.\\n| && |faded silver bags contain 4 drab cyan bags, 3 light cyan bags, 5 clear tan bags.\\n| && |plaid turquoise bags contain 4 faded silver bags, 4 striped bronze bags, 1 drab purple bag.\\n| && |pale purple bags contain 5 clear chartreuse bags, 1 plaid bronze bag, 5 clear cyan bags, 3 light tan bags.\\n| && |bright fuchsia bags contain 4 wavy lavender bags.\\n| && |posh blue bags contain 5 muted gold bags, 3 dark gray bags.\\n| && |muted crimson bags contain 2 light tomato bags, 3 muted white bags, 4 muted brown bags, 3 faded yellow bags.\\n| && |striped fuchsia bags contain 5 vibrant aqua bags.\\n| && |pale silver bags contain 1 vibrant orange bag, 5 dull gray bags, 3 bright teal bags, 1 plaid tomato bag.\\n| && |faded blue bags contain 4 striped olive bags, 4 dull chartreuse bags.\\n| && |striped beige bags contain 3 drab teal bags, 1 posh gold bag.\\n| && |plaid maroon bags contain 5 muted turquoise bags, 2 dull aqua bags.\\n| && |light tan bags contain 1 mirrored gold bag, 3 shiny white bags, 5 faded maroon bags, 4 dim violet bags.\\n| && |mirrored plum bags contain 4 wavy beige bags, 2 dark turquoise bags, 2 plaid teal bags, 5 shiny purple bags.\\n| && |wavy teal bags contain 3 vibrant cyan bags, 3 plaid coral bags.\\n| && |striped bronze bags contain 3 dotted brown bags, 3 vibrant cyan bags.\\n| && |clear black bags contain 3 dim chartreuse bags, 2 vibrant beige bags, 2 clear cyan bags.\\n| && |drab purple bags contain 2 plaid red bags, 2 vibrant aqua bags.\\n| && |mirrored white bags contain 2 vibrant gray bags.\\n| && |shiny coral bags contain no other bags.\\n| && |dotted lavender bags contain 2 light brown bags.\\n| && |dark salmon bags contain 2 dark maroon bags, 4 dark teal bags.\\n| && |wavy bronze bags contain 3 striped teal bags.\\n| && |mirrored maroon bags contain 3 light green bags, 1 light chartreuse bag.\\n| && |vibrant black bags contain 3 clear bronze bags, 2 dotted beige bags, 2 dark crimson bags.\\n| && |clear indigo bags contain 1 light fuchsia bag, 2 striped coral bags.\\n| && |mirrored black bags contain 5 plaid lime bags, 1 clear plum bag.\\n| && |pale chartreuse bags contain 5 plaid crimson bags.\\n| && |dim black bags contain 4 dotted blue bags, 2 drab indigo bags, 3 clear indigo bags.\\n| && |striped lime bags contain 5 light fuchsia bags, 1 dim silver bag.\\n| && |clear magenta bags contain 4 striped bronze bags, 3 posh orange bags, 4 dotted olive bags, 4 dull cyan bags.\\n| && |drab chartreuse bags contain 4 vibrant gold bags, 4 vibrant orange bags, 3 striped red bags, 4 drab olive bags.\\n| && |light yellow bags contain 2 dark green bags, 1 light fuchsia bag, 3 bright orange bags.\\n| && |drab coral bags contain 5 light red bags, 4 posh plum bags, 4 drab crimson bags, 1 faded magenta bag.\\n| && |dull brown bags contain 2 plaid cyan bags, 4 dull aqua bags, 5 posh cyan bags.\\n| && |dotted plum bags contain 4 dull brown bags.\\n| && |vibrant plum bags contain 1 mirrored plum bag, 5 vibrant olive bags, 5 clear gray bags, 3 mirrored tomato bags.\\n| && |mirrored silver bags contain 2 faded indigo bags, 3 striped yellow bags, 3 muted tomato bags.\\n| && |pale teal bags contain 5 mirrored white bags, 4 wavy plum bags, 4 pale indigo bags, 2 bright turquoise bags.\\n| && |dotted black bags contain 3 plaid coral bags.\\n| && |drab gray bags contain 4 plaid red bags.\\n| && |striped white bags contain 2 vibrant teal bags, 3 posh aqua bags, 4 faded cyan bags.\\n| && |plaid green bags contain 3 mirrored chartreuse bags, 4 wavy yellow bags.\\n| && |posh chartreuse bags contain 5 clear gray bags, 1 striped lavender bag, 2 striped coral bags.\\n| && |posh turquoise bags contain 4 bright lime bags, 2 vibrant bronze bags.\\n| && |muted silver bags contain 2 dull gray bags, 3 plaid tomato bags, 5 light green bags.\\n| && |muted salmon bags contain 4 dotted brown bags, 5 dim lavender bags, 3 muted violet bags.\\n| && |dotted coral bags contain 4 drab cyan bags.\\n| && |striped teal bags contain 2 shiny tan bags, 3 dark turquoise bags, 3 wavy beige bags.\\n| && |vibrant coral bags contain 3 vibrant aqua bags, 2 pale brown bags.\\n| && |light indigo bags contain 2 dark cyan bags, 5 drab chartreuse bags, 5 clear tomato bags.\\n| && |dim tomato bags contain 2 pale lime bags, 2 muted brown bags, 4 dull gray bags.\\n| && |dull gray bags contain 3 dotted white bags, 3 drab olive bags, 3 plaid red bags, 2 plaid blue bags.\\n| && |bright beige bags contain 5 posh gold bags, 2 dull green bags, 1 wavy brown bag.\\n| && |dull coral bags contain 2 shiny gold bags, 2 dark red bags, 4 faded chartreuse bags, 3 vibrant orange bags.\\n| && |dark blue bags contain 3 dotted white bags, 5 light green bags, 5 vibrant gold bags, 4 mirrored lavender bags.\\n| && |clear turquoise bags contain 5 striped lavender bags, 5 plaid lime bags, 3 clear aqua bags, 1 mirrored salmon bag.\\n| && |dull turquoise bags contain 2 vibrant fuchsia bags, 2 light gold bags, 4 striped gray bags.\\n| && |clear aqua bags contain 1 mirrored lavender bag.\\n| && |drab maroon bags contain 1 mirrored indigo bag, 3 plaid crimson bags, 4 faded aqua bags, 3 clear violet bags.\\n| && |dull black bags contain 1 shiny tan bag.\\n| && |muted tomato bags contain 4 light green bags.\\n| && |muted lavender bags contain 3 pale maroon bags, 2 shiny lavender bags, 1 dark beige bag, 1 light red bag.\\n| && |dotted maroon bags contain 3 dotted magenta bags, 4 drab gray bags, 1 clear gray bag.\\n| && |muted turquoise bags contain 5 plaid orange bags, 2 vibrant bronze bags.\\n| && |striped violet bags contain 2 plaid lavender bags, 4 clear tomato bags, 4 striped crimson bags.\\n| && |posh purple bags contain 1 plaid blue bag, 2 pale tan bags, 5 light brown bags, 3 faded indigo bags.\\n| && |faded chartreuse bags contain 5 mirrored lavender bags, 2 dark red bags, 2 dull aqua bags.\\n| && |plaid fuchsia bags contain 4 mirrored maroon bags, 1 bright blue bag.\\n| && |faded teal bags contain 4 bright lavender bags, 5 light green bags, 2 striped yellow bags, 5 drab olive bags.\\n| && |mirrored gray bags contain 2 muted green bags, 5 dim cyan bags, 2 drab yellow bags.\\n| && |posh bronze bags contain 1 drab blue bag.\\n| && |drab yellow bags contain 1 bright lavender bag, 3 vibrant aqua bags, 5 bright beige bags, 2 dull olive bags.\\n| && |faded salmon bags contain 5 muted salmon bags.\\n| && |mirrored purple bags contain 2 mirrored turquoise bags, 1 pale bronze bag.\\n| && |shiny gray bags contain 2 dark bronze bags, 5 drab yellow bags, 2 clear salmon bags.\\n| && |posh gray bags contain 4 vibrant tan bags, 5 wavy maroon bags, 1 faded crimson bag.\\n| && |vibrant cyan bags contain 5 dark indigo bags, 3 bright purple bags, 1 dotted white bag, 3 muted gold bags.\\n| && |dotted fuchsia bags contain 2 plaid olive bags.\\n| && |shiny crimson bags contain 4 vibrant coral bags, 2 light brown bags, 1 wavy tan bag, 1 clear tomato bag.\\n| && |striped gold bags contain 5 vibrant olive bags, 4 vibrant tomato bags, 1 wavy red bag, 5 bright orange bags.\\n| && |dotted magenta bags contain 5 striped yellow bags, 2 dull brown bags, 4 clear silver bags.\\n| && |dull violet bags contain 3 posh maroon bags, 1 drab silver bag.\\n| && |drab gold bags contain 2 vibrant maroon bags, 5 posh plum bags, 1 shiny indigo bag.\\n| && |dull lavender bags contain 4 dull silver bags, 4 bright aqua bags, 2 striped bronze bags.\\n| && |faded gray bags contain 1 dim white bag, 1 bright bronze bag, 4 drab violet bags.\\n| && |dotted lime bags contain 1 striped white bag, 4 light turquoise bags, 2 light maroon bags.\\n| && |mirrored chartreuse bags contain 3 dull coral bags, 1 dark gray bag, 1 bright red bag, 4 posh blue bags.\\n| && |drab silver bags contain 2 striped violet bags, 1 light red bag.\\n| && |dark beige bags contain 1 posh maroon bag, 1 dark maroon bag, 5 shiny tan bags, 3 faded chartreuse bags.\\n| && |dim lavender bags contain 1 dim yellow bag, 3 dark coral bags, 1 wavy plum bag.\\n| && |shiny olive bags contain 4 pale gray bags, 5 striped coral bags, 5 dotted green bags.\\n| && |dim green bags contain 5 shiny purple bags, 4 mirrored lavender bags.\\n| && |clear tomato bags contain 1 clear aqua bag, 4 bright orange bags.\\n| && |striped orange bags contain 4 striped plum bags.\\n| && |drab green bags contain 3 shiny coral bags, 3 bright purple bags.\\n| && |shiny chartreuse bags contain 1 faded violet bag, 5 drab salmon bags, 5 vibrant orange bags.\\n| && |shiny magenta bags contain 2 plaid crimson bags.\\n| && |dim magenta bags contain 1 dim fuchsia bag, 5 dark red bags, 2 shiny crimson bags.\\n| && |dull white bags contain 5 pale tan bags, 1 shiny teal bag, 5 plaid cyan bags, 4 pale green bags.\\n| && |posh violet bags contain 4 vibrant orange bags, 5 mirrored fuchsia bags, 2 vibrant coral bags, 4 bright purple bags.\\n| && |dotted crimson bags contain 5 vibrant gray bags, 2 dark red bags, 5 vibrant bronze bags.\\n| && |dark black bags contain 2 pale maroon bags, 2 striped maroon bags.\\n| && |plaid teal bags contain 2 shiny coral bags, 1 posh gold bag.\\n| && |muted white bags contain 5 pale plum bags, 3 plaid teal bags.\\n| && |dim yellow bags contain 4 dark olive bags, 3 dim lime bags, 5 bright crimson bags, 1 dim fuchsia bag.\\n| && |dark lime bags contain 5 posh plum bags, 4 dim tan bags, 3 bright indigo bags.\\n| && |muted teal bags contain 4 vibrant purple bags, 5 mirrored orange bags, 3 drab green bags.\\n| && |vibrant white bags contain 3 pale plum bags, 2 bright orange bags, 4 posh bronze bags, 2 light yellow bags.\\n| && |plaid orange bags contain 2 drab blue bags, 5 plaid lavender bags.\\n| && |dim olive bags contain 2 vibrant bronze bags, 5 pale violet bags, 1 pale magenta bag, 4 dim salmon bags.\\n| && |light black bags contain 3 shiny purple bags, 4 faded tan bags, 5 light gold bags, 4 vibrant olive bags.\\n| && |pale orange bags contain 5 posh maroon bags, 2 clear olive bags, 2 muted beige bags, 2 dim violet bags.\\n| && |dull bronze bags contain 5 posh gold bags, 5 dark blue bags, 4 vibrant gold bags.\\n| && |faded aqua bags contain 4 striped fuchsia bags, 5 shiny white bags.\\n| && |dotted blue bags contain 1 bright salmon bag.\\n| && |pale maroon bags contain 1 light green bag, 3 posh gold bags, 2 mirrored lavender bags.\\n| && |plaid blue bags contain 5 dull bronze bags, 4 drab blue bags.\\n| && |posh cyan bags contain 1 shiny indigo bag, 1 bright purple bag, 5 dotted white bags, 3 vibrant orange bags.\\n| && |dim turquoise bags contain 4 clear purple bags, 3 mirrored cyan bags, 4 striped bronze bags.\\n| && |dull fuchsia bags contain 4 light black bags.\\n| && |striped black bags contain 4 shiny white bags, 3 mirrored blue bags.\\n| && |muted tan bags contain 2 plaid gold bags, 1 vibrant lavender bag, 5 plaid tomato bags, 1 dull silver bag.\\n| && |plaid tomato bags contain 1 wavy maroon bag, 5 muted brown bags, 4 faded violet bags.\\n| && |light tomato bags contain 5 pale maroon bags, 3 shiny indigo bags, 1 dull bronze bag, 1 light green bag.\\n| && |vibrant gold bags contain no other bags.\\n| && |shiny lime bags contain 1 posh plum bag, 3 vibrant beige bags, 1 clear plum bag.\\n| && |drab turquoise bags contain 3 pale beige bags, 5 dull beige bags, 3 dark black bags.\\n| && |bright violet bags contain 2 plaid coral bags, 1 vibrant lime bag, 3 pale silver bags.\\n| && |dotted white bags contain no other bags.\\n| && |dark green bags contain 1 vibrant aqua bag, 3 posh cyan bags.\\n| && |dim cyan bags contain 4 light green bags.\\n| && |striped aqua bags contain 2 dotted magenta bags.\\n| && |posh fuchsia bags contain 4 dull beige bags, 4 light turquoise bags, 5 pale violet bags, 1 pale beige bag.\\n| && |clear brown bags contain 4 wavy yellow bags, 1 shiny indigo bag, 5 wavy maroon bags, 1 mirrored lavender bag.\\n| && |drab black bags contain 2 striped crimson bags.\\n| && |vibrant turquoise bags contain 3 dull black bags.\\n| && |muted purple bags contain 4 wavy cyan bags.\\n| && |vibrant bronze bags contain 1 drab olive bag.\\n| && |light red bags contain 3 vibrant cyan bags, 2 striped gray bags, 4 plaid yellow bags.\\n| && |pale turquoise bags contain 4 mirrored lavender bags, 2 posh maroon bags, 2 pale gold bags, 1 clear gray bag.\\n| && |shiny aqua bags contain 4 clear silver bags, 3 vibrant lavender bags, 4 wavy olive bags.\\n| && |drab teal bags contain 3 faded tan bags.\\n| && |mirrored turquoise bags contain 4 clear aqua bags, 3 striped crimson bags, 3 dull black bags.\\n| && |vibrant beige bags contain 3 vibrant tan bags, 5 vibrant fuchsia bags.\\n| && |dotted bronze bags contain 3 muted lavender bags, 4 drab crimson bags, 1 dotted red bag.\\n| && |muted magenta bags contain 2 bright teal bags, 4 dim olive bags, 3 posh brown bags, 1 striped gray bag.\\n| && |striped red bags contain no other bags.\\n| && |pale lavender bags contain 5 mirrored maroon bags, 3 pale gray bags.\\n| && |dim brown bags contain 2 dull gray bags, 4 shiny purple bags, 4 vibrant gold bags.\\n| && |muted yellow bags contain 2 posh teal bags, 4 vibrant cyan bags.\\n| && |posh tomato bags contain 4 shiny silver bags, 2 mirrored lavender bags.\\n| && |faded yellow bags contain 1 muted brown bag, 1 light green bag, 4 pale lime bags.\\n| && |vibrant orange bags contain 4 shiny coral bags, 3 drab tan bags, 1 dark blue bag.\\n| && |dotted beige bags contain 1 dim olive bag, 2 pale lime bags, 1 plaid lavender bag, 2 wavy brown bags.\\n| && |pale magenta bags contain 2 pale brown bags, 2 faded violet bags, 1 dull gray bag, 2 dim green bags.\\n| && |plaid coral bags contain 1 wavy brown bag.\\n| && |drab indigo bags contain 5 vibrant plum bags, 1 striped crimson bag, 2 dim violet bags.\\n| && |pale crimson bags contain 2 wavy brown bags, 1 light green bag, 3 plaid orange bags.\\n| && |faded tomato bags contain 4 posh black bags, 1 mirrored orange bag.\\n| && |dim chartreuse bags contain 1 pale lime bag.\\n| && |bright orange bags contain 5 plaid blue bags.\\n| && |light crimson bags contain 3 drab gold bags.\\n| && |vibrant aqua bags contain 5 wavy white bags.\\n| && |wavy beige bags contain 1 mirrored beige bag, 3 vibrant maroon bags, 3 light green bags.\\n| && |dotted gray bags contain 1 dark cyan bag, 5 mirrored fuchsia bags.\\n| && |dim lime bags contain 5 vibrant maroon bags, 3 striped coral bags, 2 plaid crimson bags, 5 dotted magenta bags.\\n| && |faded purple bags contain 3 muted brown bags, 2 clear plum bags, 3 posh plum bags.\\n| && |dim orange bags contain 2 dotted lime bags, 3 posh violet bags, 4 dotted indigo bags.\\n| && |faded indigo bags contain 3 light brown bags, 3 plaid maroon bags, 1 bright aqua bag, 2 plaid red bags.\\n| && |shiny salmon bags contain 1 drab bronze bag, 5 faded yellow bags, 3 vibrant gold bags.\\n| && |light lime bags contain 1 vibrant plum bag.\\n| && |muted orange bags contain 5 posh red bags.\\n| && |vibrant fuchsia bags contain 5 drab gray bags, 4 clear chartreuse bags, 2 posh blue bags.\\n| && |faded turquoise bags contain 2 vibrant indigo bags, 5 dotted indigo bags, 3 mirrored silver bags.\\n| && |wavy indigo bags contain 3 vibrant white bags, 5 clear chartreuse bags.\\n| && |striped brown bags contain 4 dull aqua bags, 3 bright yellow bags.\\n| && |dotted violet bags contain 4 mirrored beige bags, 4 striped gray bags, 2 dim chartreuse bags, 3 dim brown bags.\\n| && |dark chartreuse bags contain 5 dark turquoise bags, 4 drab gold bags.\\n| && |drab tomato bags contain 3 striped magenta bags, 5 shiny tomato bags.\\n| && |striped gray bags contain 3 shiny coral bags, 4 pale brown bags, 5 light green bags.\\n| && |wavy olive bags contain 5 shiny silver bags, 3 plaid blue bags, 5 shiny coral bags.\\n| && |mirrored tomato bags contain 5 clear plum bags, 3 bright aqua bags, 4 bright lime bags.\\n| && |dark magenta bags contain 2 posh lavender bags, 5 light brown bags.\\n| && |shiny cyan bags contain 2 drab yellow bags, 4 dotted bronze bags.\\n| && |light white bags contain 3 wavy turquoise bags, 3 vibrant beige bags.\\n| && |shiny indigo bags contain 4 pale brown bags, 1 drab olive bag, 2 dark red bags, 1 striped gray bag.\\n| && |wavy lime bags contain 3 dark cyan bags, 1 vibrant green bag.\\n| && |vibrant brown bags contain 4 light bronze bags, 1 drab black bag.\\n| && |drab tan bags contain 1 striped gray bag.\\n| && |dotted yellow bags contain 5 dotted coral bags, 4 striped magenta bags.\\n| && |shiny brown bags contain 3 dull beige bags, 2 striped silver bags.\\n| && |dull chartreuse bags contain 3 pale black bags.\\n| && |pale aqua bags contain 1 posh turquoise bag, 3 vibrant aqua bags, 4 shiny white bags.\\n| && |muted indigo bags contain 4 dotted aqua bags, 3 striped black bags, 3 pale lime bags, 3 dotted violet bags.\\n| && |mirrored yellow bags contain 1 dim chartreuse bag, 3 pale black bags.\\n| && |posh beige bags contain 1 plaid bronze bag, 5 vibrant tan bags, 3 posh tomato bags.\\n| && |dim plum bags contain 3 plaid gold bags, 4 dim chartreuse bags, 1 pale green bag.\\n| && |wavy violet bags contain 5 striped turquoise bags, 4 drab chartreuse bags, 4 plaid maroon bags.\\n| && |dim crimson bags contain 1 posh chartreuse bag.\\n| && |dull salmon bags contain 3 muted black bags.\\n| && |vibrant blue bags contain 4 dark white bags, 5 mirrored plum bags.\\n| && |bright gray bags contain 4 bright lavender bags.\\n| && |bright plum bags contain 4 bright tomato bags, 3 light gold bags, 2 bright aqua bags, 4 striped red bags.\\n| && |clear chartreuse bags contain 1 plaid yellow bag.\\n| && |shiny tan bags contain 4 pale maroon bags.\\n| && |mirrored brown bags contain 2 pale maroon bags, 3 dark beige bags, 1 mirrored lime bag, 4 bright purple bags.\\n| && |plaid plum bags contain 5 pale magenta bags, 2 mirrored lavender bags, 2 plaid gold bags.\\n| && |faded crimson bags contain 4 plaid maroon bags, 1 light turquoise bag, 5 posh purple bags, 1 wavy beige bag.\\n| && |clear blue bags contain 3 dim salmon bags, 2 wavy fuchsia bags, 3 vibrant olive bags.\\n| && |light aqua bags contain 4 posh aqua bags, 4 striped black bags.\\n| && |bright chartreuse bags contain 2 plaid olive bags, 4 striped lavender bags.\\n| && |plaid tan bags contain 1 vibrant aqua bag.\\n| && |faded red bags contain 1 plaid maroon bag, 2 muted coral bags, 4 light brown bags.\\n| && |clear gold bags contain 4 striped red bags, 3 shiny gold bags, 4 light green bags, 4 dark blue bags.\\n| && |light teal bags contain 5 muted tomato bags, 3 dim cyan bags.\\n| && |pale gold bags contain 4 dim fuchsia bags, 4 dark indigo bags.\\n| && |faded maroon bags contain 5 dim silver bags, 4 vibrant cyan bags, 3 plaid coral bags, 3 bright purple bags.\\n| && |plaid red bags contain 2 dull bronze bags, 5 bright lime bags.\\n| && |mirrored blue bags contain 2 plaid coral bags, 5 dull indigo bags, 4 drab chartreuse bags, 3 vibrant gold bags.\\n| && |faded orange bags contain 2 wavy green bags, 5 bright purple bags, 1 dark cyan bag.\\n| && |mirrored fuchsia bags contain 5 light green bags.\\n| && |dark turquoise bags contain 4 bright white bags.\\n| && |shiny violet bags contain 1 pale magenta bag.\\n| && |shiny tomato bags contain 2 pale violet bags, 4 pale brown bags.\\n| && |posh magenta bags contain 2 shiny tan bags, 2 vibrant tan bags.\\n| && |plaid magenta bags contain 1 drab chartreuse bag, 1 vibrant orange bag, 2 plaid red bags, 2 faded yellow bags.\\n| && |light blue bags contain 5 dotted bronze bags, 3 dotted brown bags.\\n| && |plaid indigo bags contain 3 bright orange bags.\\n| && |striped tomato bags contain 2 striped yellow bags.\\n| && |shiny purple bags contain 5 dull bronze bags, 3 dull aqua bags.\\n| && |posh white bags contain 1 plaid teal bag, 1 striped blue bag, 3 posh magenta bags.\\n| && |clear violet bags contain 1 drab bronze bag.\\n| && |muted blue bags contain 3 dotted bronze bags, 2 light olive bags.\\n| && |muted chartreuse bags contain 4 posh purple bags, 1 dull magenta bag, 1 dim silver bag, 5 bright indigo bags.\\n| && |dark purple bags contain 3 faded aqua bags, 2 dull beige bags, 4 plaid coral bags, 1 pale black bag.\\n| && |wavy silver bags contain 5 muted salmon bags, 2 bright salmon bags, 1 posh magenta bag, 2 dim brown bags.\\n| && |posh black bags contain 1 dim tomato bag.\\n| && |bright lavender bags contain 1 vibrant crimson bag, 3 posh turquoise bags, 5 faded yellow bags.\\n| && |dull green bags contain 3 faded chartreuse bags, 2 faded beige bags, 2 shiny coral bags.\\n| && |posh crimson bags contain 5 bright red bags, 3 clear brown bags, 4 shiny salmon bags, 3 vibrant orange bags.\\n| && |plaid gold bags contain 2 plaid tomato bags, 4 muted turquoise bags, 4 clear salmon bags.\\n| && |bright coral bags contain 5 mirrored lavender bags, 1 bright yellow bag, 4 clear black bags, 5 posh lavender bags.\\n| && |wavy black bags contain 3 dim salmon bags.\\n| && |clear silver bags contain 4 plaid magenta bags.\\n| && |striped lavender bags contain 3 muted gold bags, 4 light brown bags, 2 vibrant green bags.\\n| && |dull blue bags contain 2 plaid violet bags, 5 vibrant white bags.\\n| && |dull olive bags contain 2 clear chartreuse bags, 1 pale violet bag, 2 vibrant crimson bags.\\n| && |wavy tan bags contain 4 posh cyan bags, 5 clear silver bags.\\n| && |bright salmon bags contain 1 drab tan bag, 1 dull indigo bag.\\n| && |wavy turquoise bags contain 1 dark maroon bag.\\n| && |drab olive bags contain 2 muted gold bags, 5 dark blue bags, 4 mirrored lavender bags.\\n| && |drab cyan bags contain 1 drab blue bag, 1 vibrant bronze bag.\\n| && |pale beige bags contain 5 clear gold bags, 3 dim tomato bags, 5 posh crimson bags, 2 drab gray bags.\\n| && |bright teal bags contain 1 wavy maroon bag, 4 dim green bags, 2 shiny tan bags.\\n| && |drab aqua bags contain 3 clear cyan bags, 3 dull silver bags.\\n| && |shiny white bags contain 4 dim green bags, 5 faded violet bags, 5 posh cyan bags, 4 pale brown bags.\\n| && |bright magenta bags contain 1 bright indigo bag.\\n| && |bright yellow bags contain 1 dark red bag, 2 posh cyan bags.\\n| && |dotted tomato bags contain 4 drab salmon bags, 1 shiny coral bag, 1 faded beige bag, 2 shiny magenta bags.\\n| && |vibrant silver bags contain 5 clear orange bags.\\n| && |dark aqua bags contain 3 bright tan bags, 3 dim cyan bags, 1 plaid chartreuse bag, 1 clear orange bag.\\n| && |shiny red bags contain 4 clear tomato bags.\\n| && |plaid lime bags contain 3 mirrored lavender bags, 4 drab green bags.\\n| && |shiny gold bags contain 4 striped yellow bags, 3 drab olive bags, 1 bright purple bag.\\n| && |bright maroon bags contain 5 dull indigo bags, 1 mirrored lavender bag, 5 posh salmon bags.\\n| && |light bronze bags contain 3 dim tan bags, 4 dotted brown bags, 1 drab green bag.\\n| && |light fuchsia bags contain 3 shiny crimson bags, 2 bright salmon bags.\\n| && |faded plum bags contain 3 dull brown bags.\\n| && |posh silver bags contain 3 wavy bronze bags, 2 plaid green bags, 5 drab fuchsia bags, 1 wavy red bag.\\n| && |bright tomato bags contain 2 bright black bags, 2 clear brown bags.\\n| && |dull gold bags contain 1 dark salmon bag.\\n| && |clear plum bags contain 1 mirrored tan bag, 1 shiny coral bag, 2 clear tan bags.\\n| && |pale tan bags contain 1 bright red bag, 5 light yellow bags, 4 vibrant olive bags.\\n| && |plaid salmon bags contain 3 drab maroon bags, 1 posh black bag, 1 vibrant blue bag.\\n| && |striped silver bags contain 4 faded coral bags, 5 clear black bags, 4 dark chartreuse bags, 5 pale tan bags.\\n| && |faded brown bags contain 5 wavy black bags.\\n| && |faded gold bags contain 5 plaid maroon bags, 4 posh blue bags, 4 posh crimson bags, 1 bright teal bag.\\n| && |dull tomato bags contain 4 muted coral bags, 5 drab tan bags.\\n| && |dotted turquoise bags contain 5 light gray bags, 4 plaid cyan bags, 5 dark lime bags.\\n| && |dull indigo bags contain 4 plaid red bags, 5 bright aqua bags.\\n| && |dull yellow bags contain 4 muted crimson bags, 5 bright black bags.\\n| && |striped yellow bags contain 4 dark red bags, 3 vibrant crimson bags, 4 vibrant maroon bags, 1 mirrored lavender bag.\\n| && |dotted indigo bags contain 4 drab turquoise bags, 2 posh purple bags.\\n| && |mirrored aqua bags contain 4 plaid blue bags, 1 dark white bag, 4 bright magenta bags, 5 drab lime bags.\\n| && |striped blue bags contain 5 dotted red bags, 3 light fuchsia bags, 3 light crimson bags, 5 striped yellow bags.\\n| && |shiny orange bags contain 1 shiny crimson bag, 4 vibrant silver bags.\\n| && |dim maroon bags contain 2 bright lavender bags.\\n| && |wavy gold bags contain 2 muted chartreuse bags.\\n| && |bright bronze bags contain 1 posh crimson bag, 4 wavy red bags.\\n| && |dark fuchsia bags contain 2 pale tan bags, 3 posh orange bags, 1 shiny chartreuse bag.\\n| && |pale violet bags contain 1 drab green bag, 1 drab tan bag.\\n| && |bright turquoise bags contain 2 posh gold bags, 3 dull green bags, 2 pale tan bags.\\n| && |wavy salmon bags contain 5 plaid olive bags, 5 posh cyan bags.\\n| && |wavy magenta bags contain 5 plaid chartreuse bags, 5 muted bronze bags.\\n| && |dark violet bags contain 3 dim chartreuse bags, 1 faded aqua bag.\\n| && |dull silver bags contain 5 plaid orange bags.\\n| && |vibrant purple bags contain 2 mirrored turquoise bags, 5 plaid gray bags.\\n| && |dark lavender bags contain 4 dull red bags.\\n| && |dark silver bags contain 1 posh brown bag, 4 wavy white bags, 5 muted fuchsia bags, 1 clear plum bag.\\n| && |dark gray bags contain 4 wavy white bags, 5 plaid lavender bags, 2 dull aqua bags, 4 bright purple bags.\\n| && |pale indigo bags contain 5 plaid green bags, 2 dull aqua bags.\\n| && |posh maroon bags contain 4 plaid magenta bags, 4 bright orange bags.\\n| && |muted violet bags contain 4 muted brown bags.\\n| && |mirrored violet bags contain 3 dim tomato bags.\\n| && |posh lavender bags contain 3 muted turquoise bags, 4 wavy maroon bags.\\n| && |posh tan bags contain 4 muted coral bags, 4 shiny beige bags, 5 light red bags, 4 faded beige bags.\\n| && |vibrant crimson bags contain 4 mirrored lavender bags, 2 mirrored beige bags, 1 striped red bag.\\n| && |bright white bags contain 3 striped fuchsia bags, 2 mirrored tan bags, 4 dull bronze bags, 4 posh plum bags.\\n| && |bright cyan bags contain 5 light cyan bags, 3 vibrant crimson bags, 1 faded cyan bag.\\n| && |clear beige bags contain 1 plaid yellow bag, 5 drab white bags, 2 drab lime bags, 5 dim orange bags.\\n| && |mirrored coral bags contain 2 light tomato bags, 3 wavy bronze bags, 3 mirrored fuchsia bags.\\n| && |vibrant olive bags contain 2 posh turquoise bags, 3 mirrored fuchsia bags, 4 dotted beige bags.\\n| && |shiny black bags contain 2 faded coral bags, 4 plaid indigo bags, 3 dark violet bags, 4 posh indigo bags.\\n| && |mirrored green bags contain 4 bright teal bags.\\n| && |clear purple bags contain 1 posh turquoise bag, 3 dull black bags, 3 faded violet bags.\\n| && |vibrant tan bags contain 4 drab blue bags.\\n| && |mirrored crimson bags contain 2 mirrored chartreuse bags, 4 muted red bags, 4 vibrant purple bags.\\n| && |posh teal bags contain 4 dim fuchsia bags, 2 shiny tan bags, 2 dull indigo bags, 3 pale plum bags.\\n| && |striped salmon bags contain 3 plaid fuchsia bags, 3 muted teal bags.\\n| && |wavy fuchsia bags contain 1 drab green bag, 2 dim salmon bags, 2 light crimson bags, 4 muted turquoise bags.\\n| && |clear cyan bags contain 4 mirrored cyan bags, 1 dull bronze bag, 4 dim brown bags.\\n| && |posh coral bags contain 3 pale beige bags, 2 plaid salmon bags.\\n| && |shiny beige bags contain 5 faded violet bags.\\n| && |wavy cyan bags contain 2 posh lime bags, 2 dotted white bags, 4 dim lime bags.\\n| && |dark tan bags contain 5 clear green bags, 1 light cyan bag, 5 light chartreuse bags, 1 dark lime bag.\\n| && |clear coral bags contain 2 wavy beige bags, 2 muted cyan bags, 5 dark turquoise bags, 4 posh green bags.\\n| && |drab orange bags contain 5 wavy salmon bags, 5 wavy olive bags, 3 posh green bags.\\n| && |vibrant maroon bags contain no other bags.\\n| && |drab beige bags contain 1 dark red bag.\\n| && |muted bronze bags contain 4 striped teal bags, 5 faded brown bags, 4 light silver bags, 3 muted beige bags.\\n| && |muted fuchsia bags contain 2 shiny coral bags, 4 dull tomato bags, 1 wavy teal bag, 5 faded tan bags.\\n| && |plaid brown bags contain 5 dull magenta bags.\\n| && |dim salmon bags contain 3 mirrored lavender bags, 2 shiny salmon bags, 4 plaid lavender bags.\\n| && |wavy purple bags contain 1 shiny yellow bag, 1 dim plum bag.\\n| && |bright aqua bags contain 4 plaid red bags, 5 pale lime bags, 5 bright lime bags.\\n| && |vibrant lime bags contain 5 light green bags.\\n| && |dark maroon bags contain 5 drab bronze bags, 4 bright red bags, 1 posh cyan bag.\\n| && |wavy red bags contain 2 mirrored beige bags, 5 muted crimson bags, 5 vibrant orange bags, 3 posh turquoise bags.\\n| && |drab brown bags contain 1 faded tan bag, 3 vibrant maroon bags.|. ENDMETHOD. ENDCLASS. ",16204,True,6281.319097682509,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 zif_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. METHODS get_program_title IMPORTING !it_tpool TYPE textpool_table RETURNING VALUE(rv_title) TYPE repti . METHODS insert_program IMPORTING !is_progdir TYPE ty_progdir !it_source TYPE abaptxt255_tab !iv_title TYPE repti !iv_package TYPE devclass RAISING zcx_abapgit_exception . METHODS update_program IMPORTING !is_progdir TYPE ty_progdir !it_source TYPE abaptxt255_tab !iv_title TYPE repti RAISING zcx_abapgit_exception . METHODS update_progdir IMPORTING !is_progdir TYPE ty_progdir RAISING zcx_abapgit_exception . METHODS insert_tpool IMPORTING !is_progdir TYPE ty_progdir !it_tpool TYPE textpool_table RAISING zcx_abapgit_exception . 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/abapGit/abapGit/issues/562 zcx_abapgit_exception=>raise_t100( ). ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'CUAD' iv_name = iv_program_name ). ENDMETHOD. METHOD deserialize_dynpros. CONSTANTS lc_rpyty_force_off TYPE c LENGTH 1 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_progname TYPE reposrc-progname, lv_title TYPE rglif-title. 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 <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. lv_title = get_program_title( it_tpool ). "" Check if program already exists SELECT SINGLE progname FROM reposrc INTO lv_progname WHERE progname = is_progdir-name AND r3state = 'A'. IF sy-subrc = 0. update_program( is_progdir = is_progdir it_source = it_source iv_title = lv_title ). ELSE. insert_program( is_progdir = is_progdir it_source = it_source iv_title = lv_title iv_package = iv_package ). ENDIF. insert_tpool( is_progdir = is_progdir it_tpool = it_tpool ). update_progdir( is_progdir ). 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 main 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 ""main 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 main 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 main language needs to be activated zcl_abapgit_objects_activation=>add( iv_type = 'REPT' iv_name = iv_program iv_delete = lv_delete ). ENDIF. ENDMETHOD. METHOD get_program_title. DATA ls_tpool LIKE LINE OF it_tpool. FIELD-SYMBOLS TYPE any. 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. rv_title = ls_tpool-entry. ENDIF. ENDMETHOD. METHOD insert_program. CALL FUNCTION 'RPY_PROGRAM_INSERT' EXPORTING development_class = iv_package program_name = is_progdir-name program_type = is_progdir-subc title_string = iv_title save_inactive = 'I' suppress_dialog = abap_true TABLES source_extended = it_source EXCEPTIONS already_exists = 1 cancelled = 2 name_not_allowed = 3 permission_error = 4 OTHERS = 5. IF sy-subrc = 3. "" For cases that standard function does not handle (like FUGR), "" we save active and inactive version of source with the given PROGRAM TYPE. "" Without the active version, the code will not be visible in case of activation errors. INSERT REPORT is_progdir-name FROM it_source STATE 'A' PROGRAM TYPE is_progdir-subc. 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 .. PROGRAM TYPE' ). ENDIF. ELSEIF sy-subrc > 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD insert_tpool. 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. 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_t100( ). 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_t100( ). 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_t100( ). 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, li_xml TYPE REF TO zif_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_t100( ). ENDIF. zcl_abapgit_language=>restore_login_language( ). ls_progdir = read_progdir( lv_program_name ). IF io_xml IS BOUND. li_xml = io_xml. ELSE. CREATE OBJECT li_xml TYPE zcl_abapgit_xml_output. ENDIF. li_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 ). li_xml->add( iv_name = 'DYNPROS' ig_data = lt_dynpros ). ls_cua = serialize_cua( lv_program_name ). IF NOT ls_cua IS INITIAL. li_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. li_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 ii_xml = li_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. METHOD update_progdir. DATA ls_progdir_new TYPE progdir. 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( 'Error reading program directory' ). ENDIF. 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. ls_progdir_new-clas = is_progdir-clas. 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( 'Error updating program directory' ). ENDIF. "" function UPDATE_PROGDIR does not update VARCL, so we do it here 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 <> ls_progdir_new-varcl. UPDATE progdir SET varcl = is_progdir-varcl WHERE name = ls_progdir_new-name AND state = ls_progdir_new-state. ""#EC CI_SUBRC ENDIF. ENDMETHOD. METHOD update_program. zcl_abapgit_language=>set_current_language( mv_language ). CALL FUNCTION 'RPY_PROGRAM_UPDATE' EXPORTING program_name = is_progdir-name title_string = iv_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_t100( ). ENDIF. ENDIF. zcl_abapgit_language=>restore_login_language( ). ENDMETHOD. ENDCLASS. ",8397,False,1657.5299586540434,median "CLASS zcl_dbbr_field_output_tree DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_uitb_page_scroller . INTERFACES zif_uitb_content_searcher . TYPES mty_node_move_type TYPE int1 . CONSTANTS: BEGIN OF c_node_move_types, up TYPE mty_node_move_type VALUE 1, down TYPE mty_node_move_type VALUE 2, top TYPE mty_node_move_type VALUE 3, bottom TYPE mty_node_move_type VALUE 4, to_specified TYPE mty_node_move_type VALUE 5, END OF c_node_move_types . EVENTS tree_data_updated . METHODS constructor IMPORTING io_fields TYPE REF TO zcl_dbbr_tabfield_list io_original_fields TYPE REF TO zcl_dbbr_tabfield_list !if_field_aggregation TYPE boolean OPTIONAL !if_single_table_mode TYPE boolean OPTIONAL !iv_mode TYPE zdbbr_field_chooser_mode !iv_entity_type TYPE zsat_entity_type !iv_current_table TYPE tabname OPTIONAL . METHODS fill_tree IMPORTING !if_update_data TYPE boolean OPTIONAL . METHODS reset_update_ability . METHODS create_tree . METHODS sort_fields_in_ddic_order . METHODS delete_selected_nodes . METHODS free . METHODS update_current_table IMPORTING !iv_tabname TYPE tabname . METHODS move_selected_nodes IMPORTING !iv_move_type TYPE mty_node_move_type !it_selected_nodes TYPE treemnotab OPTIONAL !iv_target_node TYPE tm_nodekey OPTIONAL . PROTECTED SECTION. TYPES: BEGIN OF mty_node_data. INCLUDE TYPE treemsnod. TYPES: items TYPE treemcitab. TYPES: END OF mty_node_data . TYPES: mtt_node_data TYPE TABLE OF mty_node_data . CONSTANTS c_output_field_container TYPE dynfnam VALUE 'OUTPUT_CONTAINER' ##NO_TEXT. CONSTANTS c_top_node TYPE tm_nodekey VALUE 'TOP' ##NO_TEXT. CONSTANTS c_toolbar_container TYPE dynfnam VALUE 'OUTPUT_TOOLBAR' ##NO_TEXT. CONSTANTS: BEGIN OF c_column_names, hierarchy_column TYPE tv_itmname VALUE 'HIERARCHY', key_column TYPE tv_itmname VALUE 'KEYCOL', description_column TYPE tv_itmname VALUE 'DESCRCOL', sorted_column TYPE tv_itmname VALUE 'SORTCOL', END OF c_column_names . CONSTANTS: BEGIN OF c_fcode, cut_nodes TYPE ui_func VALUE 'CUT_NODES' ##NO_TEXT, insert_nodes TYPE ui_func VALUE 'INSERT_NODES' ##NO_TEXT, discard_nodes TYPE ui_func VALUE 'DISCARD_NODES' ##NO_TEXT, del_nodes TYPE ui_func VALUE 'DEL_NODES' ##NO_TEXT, insert_text_fields TYPE ui_func VALUE 'INS_TEXT_FIELDS' ##NO_TEXT, insert_form_fields TYPE ui_func VALUE 'INS_FORM_FIELDS' ##NO_TEXT, END OF c_fcode. DATA mo_tree_model TYPE REF TO cl_column_tree_model . DATA mo_container TYPE REF TO cl_gui_custom_container . DATA mo_toolbar_container TYPE REF TO cl_gui_custom_container . DATA mo_toolbar TYPE REF TO cl_gui_toolbar . DATA mo_output_tree_container TYPE REF TO cl_gui_custom_container . DATA mo_tree_dnd_behaviour TYPE REF TO cl_dragdrop . DATA mo_fields TYPE REF TO zcl_dbbr_tabfield_list . DATA mo_original_fields TYPE REF TO zcl_dbbr_tabfield_list . DATA mf_update_off TYPE boolean . DATA mv_mode TYPE zdbbr_field_chooser_mode . DATA mv_field_count TYPE sy-tabix . DATA mf_field_aggregation TYPE boolean . DATA mf_single_table_mode TYPE boolean . DATA mv_current_table TYPE tabname . DATA mt_node_data_buffer TYPE mtt_node_data . DATA mv_entity_type TYPE zsat_entity_type . METHODS create_sortorder_from_checked . METHODS create_sort_order_from_visible . METHODS create_table_field_node IMPORTING VALUE(io_tabfield_info) TYPE REF TO zdbbr_tabfield_info_ui !iv_dnd_handle TYPE i OPTIONAL . METHODS create_nodes_from_tabfields IMPORTING !iv_dnd_handle TYPE i . METHODS get_node_image IMPORTING !if_is_key TYPE boolean OPTIONAL !if_is_formula TYPE boolean OPTIONAL !if_is_textfield TYPE boolean OPTIONAL RETURNING VALUE(rv_image) TYPE tv_image . PRIVATE SECTION. METHODS create_nodes . METHODS sort_fields_in_user_order . METHODS create_toolbar . METHODS move_nodes IMPORTING !it_selected_nodes TYPE treemnotab OPTIONAL !iv_target_node TYPE tm_nodekey OPTIONAL !iv_move_type TYPE mty_node_move_type EXPORTING !ef_no_nodes_selected TYPE boolean . METHODS determine_previous_node IMPORTING !it_node_key TYPE treemnotab RETURNING VALUE(rv_node_key) TYPE tm_nodekey . METHODS determine_next_node IMPORTING !it_node_key TYPE treemnotab RETURNING VALUE(rv_node_key) TYPE tm_nodekey . METHODS cut_selected_nodes IMPORTING it_selected_nodes TYPE treemnotab. METHODS discard_selected_nodes. METHODS insert_nodes_from_buffer IMPORTING iv_insert_at_node TYPE tm_nodekey. METHODS create_missing_text_fld_nodes. METHODS create_missing_form_fld_nodes. METHODS on_tree_drag FOR EVENT drag OF cl_column_tree_model IMPORTING !drag_drop_object !node_key . METHODS on_tree_drop FOR EVENT drop OF cl_column_tree_model IMPORTING !drag_drop_object !node_key !sender . METHODS on_tree_drag_multiple FOR EVENT drag_multiple OF cl_column_tree_model IMPORTING !drag_drop_object !item_name !node_key_table . METHODS on_toolbar_button_clicked FOR EVENT function_selected OF cl_gui_toolbar IMPORTING !fcode . METHODS on_node_context_menu_request FOR EVENT node_context_menu_request OF cl_column_tree_model IMPORTING !menu !node_key . METHODS on_node_context_menu_select FOR EVENT node_context_menu_select OF cl_column_tree_model IMPORTING !fcode !node_key . ENDCLASS. CLASS zcl_dbbr_field_output_tree IMPLEMENTATION. METHOD constructor. mo_fields = io_fields. mo_original_fields = io_original_fields. mo_fields->build_complete_fieldnames( ). mv_field_count = mo_fields->get_field_count( ). mf_field_aggregation = if_field_aggregation. mf_single_table_mode = if_single_table_mode. mv_mode = iv_mode. mv_current_table = iv_current_table. mv_entity_type = iv_entity_type. ENDMETHOD. METHOD create_missing_text_fld_nodes. DATA(lo_iterator) = mo_fields->zif_uitb_data_ref_list~get_iterator( iv_where = 'OUTPUT_ACTIVE = abap_false AND IS_TEXT_FIELD = abap_true' ). mo_tree_dnd_behaviour->get_handle( IMPORTING handle = DATA(lv_dnd_handle) ). WHILE lo_iterator->has_next( ). DATA(lr_element) = CAST zdbbr_tabfield_info_ui( lo_iterator->get_next( ) ). lr_element->output_active = abap_true. create_table_field_node( io_tabfield_info = lr_element iv_dnd_handle = lv_dnd_handle ). ENDWHILE. ENDMETHOD. METHOD create_missing_form_fld_nodes. DATA: lo_iterator TYPE REF TO zif_uitb_data_ref_iterator, lr_element TYPE REF TO zdbbr_tabfield_info_ui. IF mf_field_aggregation = abap_true. lo_iterator = mo_original_fields->zif_uitb_data_ref_list~get_iterator( iv_where = 'IS_FORMULA_FIELD = abap_true' ). ELSE. lo_iterator = mo_fields->zif_uitb_data_ref_list~get_iterator( iv_where = 'OUTPUT_ACTIVE = abap_false AND IS_FORMULA_FIELD = abap_true' ). ENDIF. mo_tree_dnd_behaviour->get_handle( IMPORTING handle = DATA(lv_dnd_handle) ). WHILE lo_iterator->has_next( ). lr_element = CAST zdbbr_tabfield_info_ui( lo_iterator->get_next( ) ). IF mf_field_aggregation = abap_true. "" check if field already exists in aggregation list TRY. mo_fields->get_field_ref( iv_tabname_alias = lr_element->tabname_alias iv_fieldname = lr_element->fieldname ). CONTINUE. CATCH cx_sy_itab_line_not_found. mo_fields->add( lr_element ). ENDTRY. ENDIF. lr_element->output_active = abap_true. create_table_field_node( io_tabfield_info = lr_element iv_dnd_handle = lv_dnd_handle ). ENDWHILE. ENDMETHOD. METHOD create_nodes. *... create drag-n-drop behaviour object mo_tree_dnd_behaviour = NEW #( ). mo_tree_dnd_behaviour->add( flavor = 'Node' dragsrc = abap_true droptarget = abap_true effect = cl_dragdrop=>move ). *...get handle of drag n drop control mo_tree_dnd_behaviour->get_handle( IMPORTING handle = DATA(lv_dnd_handle) ). *... create top node for fields mo_tree_model->add_node( node_key = c_top_node isfolder = abap_true style = cl_list_tree_model=>style_emphasized_c item_table = VALUE treemcitab( ( item_name = c_column_names-hierarchy_column class = cl_list_tree_model=>item_class_text font = cl_list_tree_model=>item_font_prop text = COND #( WHEN mv_mode = zif_dbbr_c_global=>c_field_chooser_modes-output THEN TEXT-009 WHEN mv_mode = zif_dbbr_c_global=>c_field_chooser_modes-selection THEN TEXT-010 ) ) ) ). create_nodes_from_tabfields( lv_dnd_handle ). mo_tree_model->expand_root_nodes( ). ENDMETHOD. METHOD create_nodes_from_tabfields. mo_fields->initialize_iterator( if_for_active = abap_true ). WHILE mo_fields->has_more_lines( ). create_table_field_node( io_tabfield_info = mo_fields->get_next_entry( ) iv_dnd_handle = iv_dnd_handle ). ENDWHILE. ENDMETHOD. METHOD create_sortorder_from_checked. *&---------------------------------------------------------------------* *& Description: Creates user output/selection order from current checked fields *&---------------------------------------------------------------------* "" first sort fields in ddic order mo_fields->sort_in_ddic_order( ). mo_fields->create_order_from_active( ). ENDMETHOD. METHOD create_sort_order_from_visible. mo_tree_model->node_get_children( EXPORTING node_key = c_top_node IMPORTING node_key_table = DATA(lt_child_nodes) ). LOOP AT lt_child_nodes ASSIGNING FIELD-SYMBOL(). DATA(lv_index) = sy-tabix. mo_tree_model->node_get_user_object( EXPORTING node_key = IMPORTING user_object = DATA(lr_user_object) ). CAST zcl_dbbr_tabfield( lr_user_object )->set_custom_order( CONV #( lv_index ) ). ENDLOOP. ENDMETHOD. METHOD create_table_field_node. FIELD-SYMBOLS: TYPE zdbbr_tabfield_info_ui. ASSIGN io_tabfield_info->* TO . DATA(lv_prefix) = COND string( WHEN -alias IS NOT INITIAL THEN -alias && '~' ). DATA(lv_node_key) = COND tm_nodekey( WHEN -is_text_field = abap_true THEN -sql_fieldname ELSE lv_prefix && -fieldname_raw ). DATA(lt_items) = VALUE treemcitab( ( item_name = c_column_names-hierarchy_column class = cl_list_tree_model=>item_class_text font = cl_list_tree_model=>item_font_prop text = lv_node_key ) ( item_name = c_column_names-key_column class = cl_list_tree_model=>item_class_text font = cl_list_tree_model=>item_font_prop text = -is_key ) ). "" add sorted column symbol IF -sort_active = abap_true. lt_items = VALUE #( BASE lt_items ( item_name = c_column_names-sorted_column class = cl_list_tree_model=>item_class_text font = cl_list_tree_model=>item_font_prop t_image = SWITCH #( -sort_direction WHEN zif_dbbr_c_global=>c_sort_direction-ascending THEN icon_sort_up WHEN zif_dbbr_c_global=>c_sort_direction-descending THEN icon_sort_down ) ) ). ENDIF. lt_items = VALUE #( BASE lt_items ( item_name = c_column_names-description_column class = cl_list_tree_model=>item_class_text font = cl_list_tree_model=>item_font_prop text = -field_ddtext ) ). mo_tree_model->add_node( node_key = lv_node_key relative_node_key = c_top_node relationship = cl_list_tree_model=>relat_last_child image = get_node_image( if_is_key = -is_key if_is_formula = -is_formula_field if_is_textfield = -is_text_field ) isfolder = abap_false drag_drop_id = iv_dnd_handle user_object = NEW zcl_dbbr_tabfield( ir_table_field_info = io_tabfield_info iv_mode = mv_mode ) item_table = lt_items ). ENDMETHOD. METHOD create_toolbar. DATA: lt_events TYPE cntl_simple_events. "" create toolbar mo_toolbar_container = NEW cl_gui_custom_container( container_name = c_toolbar_container ). mo_toolbar = NEW cl_gui_toolbar( parent = mo_toolbar_container ). IF mv_mode = zif_dbbr_c_global=>c_field_chooser_modes-output. mo_toolbar->add_button( fcode = c_fcode-insert_text_fields "" fcode associated to a button icon = icon_insert_row "" icon name defined like '@0a@' butn_type = cntb_btype_button text = 'Text Fields' quickinfo = 'Add Missing Text Fields' ). mo_toolbar->add_button( fcode = c_fcode-insert_form_fields "" fcode associated to a button icon = icon_biw_formula "" icon name defined like '@0a@' butn_type = cntb_btype_button text = 'Formula Fields' quickinfo = 'Add Missing Formula' ). ENDIF. lt_events = VALUE #( ( eventid = cl_gui_toolbar=>m_id_function_selected appl_event = abap_true ) ). mo_toolbar->set_registered_events( lt_events ). SET HANDLER on_toolbar_button_clicked FOR mo_toolbar. ENDMETHOD. METHOD create_tree. DATA: lt_events TYPE cntl_simple_events. CHECK mo_container IS INITIAL. mo_container = NEW cl_gui_custom_container( container_name = c_output_field_container ). mo_tree_model = NEW cl_column_tree_model( node_selection_mode = cl_gui_list_tree=>node_sel_mode_multiple item_selection = abap_false hierarchy_header = VALUE treemhhdr( heading = 'Feld' width = 60 ) hierarchy_column_name = c_column_names-hierarchy_column ). mo_tree_model->add_column( name = c_column_names-key_column width = 7 alignment = cl_column_tree_model=>align_center header_text = 'Key Field' header_tooltip = 'Key Field' ). mo_tree_model->add_column( name = c_column_names-sorted_column width = 7 alignment = cl_column_tree_model=>align_center header_text = 'Sorted' header_tooltip = 'Sort Column' ). mo_tree_model->add_column( name = c_column_names-description_column width = 50 header_text = 'Description' ). "" create tree control from model mo_tree_model->create_tree_control( parent = mo_container ). create_toolbar( ). lt_events = VALUE #( ( eventid = cl_column_tree_model=>eventid_node_context_menu_req appl_event = abap_true ) ). mo_tree_model->set_registered_events( lt_events ). """""" set event handler methods to tree control SET HANDLER: on_tree_drag FOR mo_tree_model, on_tree_drag_multiple FOR mo_tree_model, on_tree_drop FOR mo_tree_model, on_node_context_menu_request FOR mo_tree_model, on_node_context_menu_select FOR mo_tree_model. ENDMETHOD. METHOD cut_selected_nodes. "" collect complete node data DATA: lv_relatkey TYPE tm_nodekey, lv_relatship TYPE i, lf_first_iteration TYPE boolean VALUE abap_true. LOOP AT it_selected_nodes ASSIGNING FIELD-SYMBOL(). mo_tree_model->node_get_items( EXPORTING node_key = IMPORTING item_table = DATA(lt_items) ). mo_tree_model->node_get_properties( EXPORTING node_key = IMPORTING properties = DATA(ls_node_properties) ). DATA(ls_tabfield_info) = CAST zcl_dbbr_tabfield( ls_node_properties-userobject )->get_tabfield_info( ). "" cache node with item data APPEND VALUE mty_node_data( node_key = relatkey = lv_relatkey relatship = lv_relatship n_image = COND #( WHEN ls_tabfield_info-is_formula_field = abap_true THEN icon_biw_formula WHEN ls_tabfield_info-is_key = abap_true THEN icon_foreign_key WHEN ls_tabfield_info-is_text_field = abap_true THEN icon_text_ina ELSE zif_dbbr_c_icon=>no_icon ) style = ls_node_properties-style dragdropid = ls_node_properties-dragdropid userobject = ls_node_properties-userobject items = lt_items ) TO mt_node_data_buffer. "" update relative node key and relationship for following nodes IF lf_first_iteration = abap_true. lv_relatkey = . lv_relatship = cl_column_tree_model=>relat_next_sibling. CLEAR lf_first_iteration. ENDIF. ENDLOOP. "" delete all nodes mo_tree_model->delete_nodes( it_selected_nodes ). ENDMETHOD. METHOD delete_selected_nodes. *&---------------------------------------------------------------------* *& Description: Delete all the selected nodes *&---------------------------------------------------------------------* mo_tree_model->get_selected_nodes( IMPORTING node_key_table = DATA(lt_selected_nodes) ). DELETE lt_selected_nodes WHERE table_line = c_top_node. IF lt_selected_nodes IS INITIAL. RETURN. ENDIF. LOOP AT lt_selected_nodes ASSIGNING FIELD-SYMBOL(). "" reset user object behind node mo_tree_model->node_get_user_object( EXPORTING node_key = IMPORTING user_object = DATA(lr_user_object) ). DATA(lo_tabfield) = CAST zcl_dbbr_tabfield( lr_user_object ). IF mf_field_aggregation = abap_true. IF lo_tabfield->get_tabfield_info( )-is_text_field = abap_false. MESSAGE |{ 'Only Text Fields can be deleted if Aggregation is active' }| TYPE 'E'. RETURN. ENDIF. ENDIF. lo_tabfield->set_custom_active( abap_false ). "" delete the node mo_tree_model->delete_node( node_key = ). ENDLOOP. RAISE EVENT tree_data_updated. ENDMETHOD. METHOD determine_next_node. "" get last node in passed table DATA(lv_node) = it_node_key[ 1 ]. mo_tree_model->node_get_next_sibling( EXPORTING node_key = it_node_key[ lines( it_node_key ) ] IMPORTING sibling_node_key = rv_node_key ). ENDMETHOD. METHOD determine_previous_node. "" get first node in passed table DATA(lv_node) = it_node_key[ 1 ]. mo_tree_model->node_get_prev_sibling( EXPORTING node_key = it_node_key[ 1 ] IMPORTING sibling_node_key = rv_node_key ). ENDMETHOD. METHOD discard_selected_nodes. LOOP AT mt_node_data_buffer ASSIGNING FIELD-SYMBOL() WHERE userobject IS BOUND. CHECK -userobject IS BOUND. CAST zcl_dbbr_tabfield( -userobject )->set_custom_active( abap_false ). ENDLOOP. CLEAR mt_node_data_buffer. RAISE EVENT tree_data_updated. ENDMETHOD. METHOD fill_tree. CHECK mf_update_off = abap_false. create_tree( ). *... default order will be the custom user order *... check if output fields need to be sorted IF mo_fields->custom_order_exists( ). mo_fields->sort_in_custom_order( ). ELSE. mo_fields->sort_in_ddic_order( ). ENDIF. *... delete old nodes mo_tree_model->delete_all_nodes( ). *... create nodes for model create_nodes( ). mo_tree_model->update_view( ). mf_update_off = abap_true. ENDMETHOD. METHOD free. IF mo_container IS BOUND. mo_container->free( ). ENDIF. IF mo_toolbar_container IS BOUND. mo_toolbar_container->free( ). ENDIF. ENDMETHOD. METHOD get_node_image. IF if_is_formula = abap_false AND if_is_key = abap_false AND if_is_textfield = abap_false. rv_image = zif_dbbr_c_icon=>no_icon. RETURN. ENDIF. IF if_is_key = abap_true. rv_image = icon_foreign_key. ELSEIF if_is_formula = abap_true. rv_image = icon_biw_formula. ELSEIF if_is_textfield = abap_true. rv_image = icon_text_ina. ENDIF. ENDMETHOD. METHOD insert_nodes_from_buffer. DATA: lv_relatship TYPE i. "" first get the node info CHECK iv_insert_at_node IS NOT INITIAL. IF iv_insert_at_node = c_top_node. lv_relatship = cl_list_tree_model=>relat_first_child. ELSE. lv_relatship = cl_list_tree_model=>relat_next_sibling. ENDIF. "" insert cached nodes at top node LOOP AT mt_node_data_buffer ASSIGNING FIELD-SYMBOL(). mo_tree_model->add_node( node_key = -node_key relative_node_key = COND #( WHEN sy-tabix = 1 THEN iv_insert_at_node ELSE -relatkey ) relationship = COND #( WHEN sy-tabix = 1 THEN lv_relatship ELSE -relatship ) isfolder = abap_false style = -style image = -n_image drag_drop_id = CONV #( -dragdropid ) user_object = -userobject item_table = -items ). ENDLOOP. CLEAR mt_node_data_buffer. create_sort_order_from_visible( ). RAISE EVENT tree_data_updated. ENDMETHOD. METHOD move_nodes. *&---------------------------------------------------------------------* *& Author: stockbal Date: 2016/11/27 *&---------------------------------------------------------------------* *& Description: Moves the selected nodes according to mode *&---------------------------------------------------------------------* DATA: lt_node_data TYPE mtt_node_data, lv_relatship TYPE i, lv_relatkey TYPE tm_nodekey. "" get selected nodes IF it_selected_nodes IS NOT INITIAL. DATA(lt_sel_nodes) = it_selected_nodes. ELSE. mo_tree_model->get_selected_nodes( IMPORTING node_key_table = lt_sel_nodes ). ENDIF. IF lt_sel_nodes IS INITIAL. ef_no_nodes_selected = abap_true. RETURN. ENDIF. CASE iv_move_type. WHEN c_node_move_types-top. lv_relatship = cl_column_tree_model=>relat_first_child. lv_relatkey = c_top_node. WHEN c_node_move_types-bottom. lv_relatship = cl_column_tree_model=>relat_last_child. lv_relatkey = c_top_node. WHEN c_node_move_types-up. lv_relatkey = determine_previous_node( lt_sel_nodes ). lv_relatship = cl_column_tree_model=>relat_prev_sibling. IF lv_relatkey IS INITIAL. "" insert nodes at the top lv_relatkey = c_top_node. lv_relatship = cl_column_tree_model=>relat_first_child. ENDIF. WHEN c_node_move_types-down. lv_relatkey = determine_next_node( lt_sel_nodes ). lv_relatship = cl_column_tree_model=>relat_next_sibling. IF lv_relatkey IS INITIAL. "" insert node(s) at the bottom lv_relatship = cl_column_tree_model=>relat_last_child. lv_relatkey = c_top_node. ENDIF. WHEN c_node_move_types-to_specified. IF iv_target_node IS INITIAL. ef_no_nodes_selected = abap_true. RETURN. ENDIF. lv_relatship = cl_column_tree_model=>relat_prev_sibling. lv_relatkey = iv_target_node. ENDCASE. "" collect complete node data LOOP AT lt_sel_nodes ASSIGNING FIELD-SYMBOL(). mo_tree_model->node_get_items( EXPORTING node_key = IMPORTING item_table = DATA(lt_items) ). mo_tree_model->node_get_properties( EXPORTING node_key = IMPORTING properties = DATA(ls_node_properties) ). DATA(ls_tabfield_info) = CAST zcl_dbbr_tabfield( ls_node_properties-userobject )->get_tabfield_info( ). "" cache node with item data APPEND VALUE mty_node_data( node_key = relatkey = lv_relatkey relatship = lv_relatship n_image = COND #( WHEN ls_tabfield_info-is_formula_field = abap_true THEN icon_biw_formula WHEN ls_tabfield_info-is_key = abap_true THEN icon_foreign_key WHEN ls_tabfield_info-is_text_field = abap_true THEN icon_text_ina ELSE zif_dbbr_c_icon=>no_icon ) style = ls_node_properties-style dragdropid = ls_node_properties-dragdropid userobject = ls_node_properties-userobject items = lt_items ) TO lt_node_data. "" update relative node key and relationship for following nodes lv_relatkey = . lv_relatship = cl_column_tree_model=>relat_next_sibling. ENDLOOP. "" delete all nodes mo_tree_model->delete_nodes( lt_sel_nodes ). "" insert cached nodes at top node LOOP AT lt_node_data ASSIGNING FIELD-SYMBOL(). mo_tree_model->add_node( node_key = -node_key relative_node_key = -relatkey relationship = -relatship isfolder = abap_false style = -style image = -n_image drag_drop_id = CONV #( -dragdropid ) user_object = -userobject item_table = -items ). ENDLOOP. "" select moved nodes mo_tree_model->unselect_all( ). mo_tree_model->select_nodes( lt_sel_nodes ). ENDMETHOD. METHOD move_selected_nodes. move_nodes( EXPORTING iv_move_type = iv_move_type iv_target_node = iv_target_node IMPORTING ef_no_nodes_selected = DATA(lf_no_nodes_selected) ). IF lf_no_nodes_selected = abap_false. create_sort_order_from_visible( ). RAISE EVENT tree_data_updated. ENDIF. ENDMETHOD. METHOD on_node_context_menu_request. IF mf_field_aggregation = abap_false. IF node_key <> c_top_node. menu->add_function( fcode = c_fcode-cut_nodes text = 'Cut selected Fields' ). ENDIF. IF mt_node_data_buffer IS NOT INITIAL. menu->add_function( fcode = c_fcode-insert_nodes text = 'Insert Fields from Buffer' ). menu->add_function( fcode = c_fcode-discard_nodes text = 'Discard Cut Fields' ). ENDIF. IF node_key <> c_top_node. menu->add_separator( ). menu->add_function( fcode = c_fcode-del_nodes text = 'Delete selected Fields' ). ENDIF. ELSE. mo_tree_model->get_selected_nodes( IMPORTING node_key_table = DATA(lt_selected) ). IF lines( lt_selected ) = 1 AND lt_selected[ 1 ] <> c_top_node. mo_tree_model->node_get_user_object( EXPORTING node_key = lt_selected[ 1 ] IMPORTING user_object = DATA(lr_user_object) ). DATA(lr_tabfield_user_object) = CAST zcl_dbbr_tabfield( lr_user_object ). IF lr_tabfield_user_object->get_tabfield_info( )-is_text_field = abap_true. menu->add_function( fcode = c_fcode-del_nodes text = 'Delete selected Fields' ). ENDIF. ENDIF. ENDIF. ENDMETHOD. METHOD on_node_context_menu_select. CASE fcode. WHEN c_fcode-cut_nodes. "" get selected nodes mo_tree_model->get_selected_nodes( IMPORTING node_key_table = DATA(lt_selected_nodes) ). cut_selected_nodes( it_selected_nodes = lt_selected_nodes ). WHEN c_fcode-discard_nodes. discard_selected_nodes( ). WHEN c_fcode-insert_nodes. insert_nodes_from_buffer( iv_insert_at_node = node_key ). WHEN c_fcode-del_nodes. delete_selected_nodes( ). WHEN c_fcode-insert_text_fields. create_missing_text_fld_nodes( ). ENDCASE. ENDMETHOD. METHOD on_toolbar_button_clicked. CASE fcode. WHEN zcl_dbbr_tabfield_manager=>c_fcode-delete_selected. delete_selected_nodes( ). WHEN zcl_dbbr_tabfield_manager=>c_fcode-sort_in_ddic. sort_fields_in_ddic_order( ). WHEN c_fcode-insert_text_fields. create_missing_text_fld_nodes( ). WHEN c_fcode-insert_form_fields. create_missing_form_fld_nodes( ). ENDCASE. ENDMETHOD. METHOD on_tree_drag. """""" create drag and drop object drag_drop_object->object = NEW zcl_dbbr_tree_dnd_object( VALUE #( ( node_key ) ) ). ENDMETHOD. METHOD on_tree_drag_multiple. drag_drop_object->object = NEW zcl_dbbr_tree_dnd_object( node_key_table ). ENDMETHOD. METHOD on_tree_drop. DATA(lv_current_node) = node_key. """""" get drag and drop object TRY. DATA(lr_dnd_object) = CAST zcl_dbbr_tree_dnd_object( drag_drop_object->object ). DATA(lv_relationship) = cl_list_tree_model=>relat_prev_sibling. WHILE lr_dnd_object->has_more_keys( ). DATA(lv_next_node) = lr_dnd_object->get_next_node( ). sender->move_node( EXPORTING node_key = lv_next_node relative_node_key = lv_current_node relationship = lv_relationship EXCEPTIONS control_not_existing = 1 control_dead = 2 failed = 3 cntl_system_error = 4 node_not_found = 5 move_error = 6 relative_node_not_found = 7 illegal_relationship = 8 OTHERS = 9 ). IF sy-subrc <> 0. CONTINUE. ENDIF. lv_current_node = lv_next_node. lv_relationship = cl_list_tree_model=>relat_next_sibling. ENDWHILE. CATCH cx_sy_move_cast_error. drag_drop_object->abort( ). RETURN. ENDTRY. """""" recreate sort order create_sort_order_from_visible( ). ENDMETHOD. METHOD reset_update_ability. CLEAR mf_update_off. ENDMETHOD. METHOD sort_fields_in_ddic_order. create_sortorder_from_checked( ). "" delete old nodes mo_tree_model->delete_all_nodes( ). """""" create nodes for model create_nodes( ). ENDMETHOD. METHOD sort_fields_in_user_order. mo_fields->sort_in_custom_order( ). ENDMETHOD. METHOD update_current_table. mv_current_table = iv_tabname. ENDMETHOD. METHOD zif_uitb_content_searcher~search. CHECK mo_tree_model IS NOT INITIAL. mo_tree_model->find( IMPORTING result_item_key_table = DATA(lt_result_item) result_type = DATA(lv_result_type) ). IF lv_result_type <> 0 AND lt_result_item IS NOT INITIAL. mo_tree_model->unselect_all( ). mo_tree_model->select_nodes( VALUE #( ( lt_result_item[ 1 ]-node_key ) ) ). ENDIF. ENDMETHOD. METHOD zif_uitb_content_searcher~search_next. mo_tree_model->find_next( IMPORTING result_item_key_table = DATA(lt_result_item) result_expander_node_key = DATA(lt_result_expander_node_key) result_type = DATA(lv_result_type) ). IF lv_result_type <> 0 AND lt_result_item IS NOT INITIAL. mo_tree_model->unselect_all( ). mo_tree_model->select_nodes( VALUE #( ( lt_result_item[ 1 ]-node_key ) ) ). ENDIF. ENDMETHOD. METHOD zif_uitb_page_scroller~scroll_page_bottom. mo_tree_model->scroll( cl_column_tree_model=>scroll_end ). ENDMETHOD. METHOD zif_uitb_page_scroller~scroll_page_down. mo_tree_model->scroll( cl_column_tree_model=>scroll_down_page ). ENDMETHOD. METHOD zif_uitb_page_scroller~scroll_page_top. mo_tree_model->scroll( cl_column_tree_model=>scroll_home ). ENDMETHOD. METHOD zif_uitb_page_scroller~scroll_page_up. mo_tree_model->scroll( cl_column_tree_model=>scroll_up_page ). ENDMETHOD. ENDCLASS. ",7983,False,1764.616264919808,median "CLASS zcl_gtt_mia_tp_reader_shh DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_gtt_mia_tp_reader . METHODS constructor IMPORTING !io_ef_parameters TYPE REF TO zif_gtt_mia_ef_parameters . PROTECTED SECTION. PRIVATE SECTION. TYPES: tt_trobj_res_id TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_trobj_res_id WITH EMPTY KEY . TYPES: tt_trobj_res_val TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_trobj_res_val WITH EMPTY KEY . TYPES: tt_resrc_cnt TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_resrc_cnt WITH EMPTY KEY . TYPES: tt_resrc_tp_id TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_resrc_tp_id WITH EMPTY KEY . TYPES: tt_crdoc_ref_typ TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_crdoc_ref_typ WITH EMPTY KEY . TYPES: tt_crdoc_ref_val TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_crdoc_ref_val WITH EMPTY KEY . TYPES: BEGIN OF ts_sh_header, tknum TYPE vttkvb-tknum, bu_id_num TYPE /saptrx/paramval200, cont_dg TYPE vttkvb-cont_dg, tndr_trkid TYPE vttkvb-tndr_trkid, ship_type TYPE zif_gtt_mia_app_types=>tv_ship_type, trans_mode TYPE zif_gtt_mia_app_types=>tv_trans_mode, ship_kind TYPE zif_gtt_mia_app_types=>tv_shipment_kind, departure_dt TYPE zif_gtt_mia_app_types=>tv_departure_dt, departure_tz TYPE zif_gtt_mia_app_types=>tv_departure_tz, departure_locid TYPE zif_gtt_mia_app_types=>tv_locid, departure_loctype TYPE zif_gtt_mia_app_types=>tv_loctype, arrival_dt TYPE zif_gtt_mia_app_types=>tv_arrival_dt, arrival_tz TYPE zif_gtt_mia_app_types=>tv_arrival_tz, arrival_locid TYPE zif_gtt_mia_app_types=>tv_locid, arrival_loctype TYPE zif_gtt_mia_app_types=>tv_loctype, tdlnr TYPE vttkvb-tdlnr, * deliv_cnt TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_deliv_cnt WITH EMPTY KEY, * deliv_no TYPE STANDARD TABLE OF vbeln WITH EMPTY KEY, trobj_res_id TYPE tt_trobj_res_id, trobj_res_val TYPE tt_trobj_res_val, resrc_cnt TYPE tt_resrc_cnt, resrc_tp_id TYPE tt_resrc_tp_id, crdoc_ref_typ TYPE tt_crdoc_ref_typ, crdoc_ref_val TYPE tt_crdoc_ref_val, stpid_stopid TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_stopid WITH EMPTY KEY, stpid_stopcnt TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_stopcnt WITH EMPTY KEY, stpid_loctype TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_loctype WITH EMPTY KEY, stpid_locid TYPE STANDARD TABLE OF zif_gtt_mia_app_types=>tv_locid WITH EMPTY KEY, shpdoc_ref_typ TYPE STANDARD TABLE OF /scmtms/btd_type_code WITH EMPTY KEY, shpdoc_ref_val TYPE STANDARD TABLE OF vbeln WITH EMPTY KEY, END OF ts_sh_header . DATA mo_ef_parameters TYPE REF TO zif_gtt_mia_ef_parameters . CONSTANTS: BEGIN OF cs_mapping, tknum TYPE /saptrx/paramname VALUE 'YN_SHP_NO', bu_id_num TYPE /saptrx/paramname VALUE 'YN_SHP_SA_LBN_ID', cont_dg TYPE /saptrx/paramname VALUE 'YN_SHP_CONTAIN_DGOODS', tndr_trkid TYPE /saptrx/paramname VALUE 'YN_SHP_FA_TRACKING_ID', ship_type TYPE /saptrx/paramname VALUE 'YN_SHP_SHIPPING_TYPE', trans_mode TYPE /saptrx/paramname VALUE 'YN_SHP_TRANSPORTATION_MODE', ship_kind TYPE /saptrx/paramname VALUE 'YN_SHP_SHIPMENT_TYPE', departure_dt TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_DEP_BUS_DATETIME', departure_tz TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_DEP_BUS_TIMEZONE', departure_locid TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_DEP_LOC_ID', departure_loctype TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_DEP_LOC_TYPE', arrival_dt TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_AR_BUS_DATETIME', arrival_tz TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_AR_BUS_TIMEZONE', arrival_locid TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_AR_LOC_ID', arrival_loctype TYPE /saptrx/paramname VALUE 'YN_SHP_PLN_AR_LOC_TYPE', tdlnr TYPE /saptrx/paramname VALUE 'YN_SHP_SA_ERP_ID', * deliv_cnt TYPE /saptrx/paramname VALUE 'YN_SHP_HDR_DLV_LINE_COUNT', * deliv_no TYPE /saptrx/paramname VALUE 'YN_SHP_HDR_DLV_NO', trobj_res_id TYPE /saptrx/paramname VALUE 'YN_SHP_TRACKED_RESOURCE_ID', trobj_res_val TYPE /saptrx/paramname VALUE 'YN_SHP_TRACKED_RESOURCE_VALUE', resrc_cnt TYPE /saptrx/paramname VALUE 'YN_SHP_RESOURCE_TP_LINE_COUNT', resrc_tp_id TYPE /saptrx/paramname VALUE 'YN_SHP_RESOURCE_TP_ID', crdoc_ref_typ TYPE /saptrx/paramname VALUE 'YN_SHP_CARRIER_REF_TYPE', crdoc_ref_val TYPE /saptrx/paramname VALUE 'YN_SHP_CARRIER_REF_VALUE', stpid_stopid TYPE /saptrx/paramname VALUE 'YN_SHP_VP_STOP_ID', stpid_stopcnt TYPE /saptrx/paramname VALUE 'YN_SHP_VP_STOP_ORD_NO', stpid_loctype TYPE /saptrx/paramname VALUE 'YN_SHP_VP_STOP_LOC_TYPE', stpid_locid TYPE /saptrx/paramname VALUE 'YN_SHP_VP_STOP_LOC_ID', shpdoc_ref_typ TYPE /saptrx/paramname VALUE 'YN_SHP_SHIPPER_REF_TYPE', shpdoc_ref_val TYPE /saptrx/paramname VALUE 'YN_SHP_SHIPPER_REF_VALUE', END OF cs_mapping . METHODS fill_header_from_vttk IMPORTING !ir_vttk TYPE REF TO data !iv_vttp_cnt TYPE i CHANGING !cs_header TYPE ts_sh_header RAISING cx_udm_message . METHODS fill_header_from_vttp IMPORTING !ir_vttk TYPE REF TO data !ir_vttp TYPE REF TO data CHANGING !cs_header TYPE ts_sh_header RAISING cx_udm_message . METHODS fill_header_from_vtts IMPORTING !ir_vttk TYPE REF TO data !ir_vttp TYPE REF TO data !ir_vtts TYPE REF TO data !ir_vtsp TYPE REF TO data OPTIONAL CHANGING !cs_header TYPE ts_sh_header RAISING cx_udm_message . METHODS fill_tracked_object_tables IMPORTING !is_vttk TYPE vttkvb EXPORTING !et_res_id TYPE tt_trobj_res_id !et_res_val TYPE tt_trobj_res_val . METHODS fill_resource_tables IMPORTING !is_vttk TYPE vttkvb EXPORTING !et_ref_cnt TYPE tt_resrc_cnt !et_tp_id TYPE tt_resrc_tp_id . METHODS fill_carrier_ref_doc_tables IMPORTING !is_vttk TYPE vttkvb EXPORTING !et_ref_typ TYPE tt_crdoc_ref_typ !et_ref_val TYPE tt_crdoc_ref_val . METHODS get_forwarding_agent_id_number IMPORTING !iv_tdlnr TYPE tdlnr RETURNING VALUE(rv_id_num) TYPE /saptrx/paramval200 . METHODS get_resource_tracking_id IMPORTING !is_vttk TYPE vttkvb RETURNING VALUE(rv_tracking_id) TYPE /saptrx/trxid . METHODS get_shippment_header IMPORTING !is_app_object TYPE trxas_appobj_ctab_wa !ir_vttk TYPE REF TO data RETURNING VALUE(rr_vttk) TYPE REF TO data RAISING cx_udm_message . METHODS get_shippment_item_count IMPORTING !ir_vttp TYPE REF TO data RETURNING VALUE(rv_count) TYPE i RAISING cx_udm_message . METHODS get_shippment_type IMPORTING !iv_vsart TYPE clike !iv_vttp_cnt TYPE i RETURNING VALUE(rv_ship_type) TYPE zif_gtt_mia_app_types=>tv_ship_type . METHODS get_transportation_mode IMPORTING !iv_vsart TYPE clike RETURNING VALUE(rv_trans_mode) TYPE zif_gtt_mia_app_types=>tv_trans_mode . METHODS is_object_changed IMPORTING !is_app_object TYPE trxas_appobj_ctab_wa RETURNING VALUE(rv_result) TYPE abap_bool RAISING cx_udm_message . ENDCLASS. CLASS ZCL_GTT_MIA_TP_READER_SHH IMPLEMENTATION. METHOD constructor. mo_ef_parameters = io_ef_parameters. ENDMETHOD. METHOD fill_carrier_ref_doc_tables. zcl_gtt_mia_sh_tools=>get_carrier_reference_document( EXPORTING is_vttk = is_vttk IMPORTING ev_ref_typ = DATA(lv_ref_typ) ev_ref_val = DATA(lv_ref_val) ). IF lv_ref_typ IS NOT INITIAL AND lv_ref_val IS NOT INITIAL. et_ref_typ = VALUE #( ( lv_ref_typ ) ). et_ref_val = VALUE #( ( lv_ref_val ) ). ELSE. CLEAR: et_ref_typ[], et_ref_val[]. ENDIF. ENDMETHOD. METHOD fill_header_from_vttk. FIELD-SYMBOLS: TYPE vttkvb. ASSIGN ir_vttk->* TO . IF sy-subrc = 0. cs_header-tknum = zcl_gtt_mia_sh_tools=>get_formated_sh_number( ir_vttk = ir_vttk ). cs_header-bu_id_num = get_forwarding_agent_id_number( iv_tdlnr = -tdlnr ). cs_header-cont_dg = -cont_dg. cs_header-tndr_trkid = -tndr_trkid. cs_header-ship_type = get_shippment_type( iv_vsart = -vsart iv_vttp_cnt = iv_vttp_cnt ). cs_header-trans_mode = get_transportation_mode( iv_vsart = -vsart ) . cs_header-ship_kind = zif_gtt_mia_app_constants=>cs_shipment_kind-shipment. cs_header-tdlnr = -tdlnr. fill_tracked_object_tables( EXPORTING is_vttk = IMPORTING et_res_id = cs_header-trobj_res_id et_res_val = cs_header-trobj_res_val ). fill_resource_tables( EXPORTING is_vttk = IMPORTING et_ref_cnt = cs_header-resrc_cnt et_tp_id = cs_header-resrc_tp_id ). fill_carrier_ref_doc_tables( EXPORTING is_vttk = IMPORTING et_ref_typ = cs_header-crdoc_ref_typ et_ref_val = cs_header-crdoc_ref_val ). ELSE. MESSAGE e002(zgtt_mia) WITH 'VTTK' INTO DATA(lv_dummy). zcl_gtt_mia_tools=>throw_exception( ). ENDIF. ENDMETHOD. METHOD fill_header_from_vttp. TYPES: tt_vttp TYPE STANDARD TABLE OF vttpvb. DATA: lv_count TYPE i VALUE 0, lv_vbeln TYPE vbeln_vl. FIELD-SYMBOLS: TYPE vttkvb, TYPE tt_vttp. ASSIGN ir_vttk->* TO . ASSIGN ir_vttp->* TO . IF sy-subrc = 0. LOOP AT ASSIGNING FIELD-SYMBOL() WHERE tknum = -tknum. lv_vbeln = zcl_gtt_mia_dl_tools=>get_formated_dlv_number( ir_likp = REF #( ) ). * For inbound Delivery,add shipper reference document IF -abfer = zif_gtt_mia_app_constants=>cs_abfer-empty_inb_ship OR -abfer = zif_gtt_mia_app_constants=>cs_abfer-loaded_inb_ship. APPEND zif_gtt_mia_app_constants=>cs_base_btd_tco-inb_dlv TO cs_header-shpdoc_ref_typ. APPEND lv_vbeln TO cs_header-shpdoc_ref_val. * For outbound Delivery,add shipper reference document ELSE. APPEND zif_gtt_mia_app_constants=>cs_base_btd_tco-outb_dlv TO cs_header-shpdoc_ref_typ. APPEND lv_vbeln TO cs_header-shpdoc_ref_val. ENDIF. ENDLOOP. ELSEIF IS NOT ASSIGNED. MESSAGE e002(zgtt_mia) WITH 'VTTK' INTO DATA(lv_dummy). zcl_gtt_mia_tools=>throw_exception( ). ELSE. MESSAGE e002(zgtt_mia) WITH 'VTTP' INTO lv_dummy. zcl_gtt_mia_tools=>throw_exception( ). ENDIF. ENDMETHOD. METHOD fill_header_from_vtts. TYPES: BEGIN OF ts_stop_id, stopid_txt TYPE zif_gtt_mia_app_types=>tv_stopid, stopcnt TYPE zif_gtt_mia_app_types=>tv_stopcnt, loctype TYPE zif_gtt_mia_app_types=>tv_loctype, locid TYPE zif_gtt_mia_app_types=>tv_locid, END OF ts_stop_id. DATA(lv_tknum) = CONV tknum( zcl_gtt_mia_tools=>get_field_of_structure( ir_struct_data = ir_vttk iv_field_name = 'TKNUM' ) ). DATA: lt_vtts TYPE vttsvb_tab, lt_stops TYPE zif_gtt_mia_app_types=>tt_stops, lt_stop_ids TYPE STANDARD TABLE OF ts_stop_id, lv_datetime TYPE zif_gtt_mia_app_types=>tv_pln_evt_datetime, lv_locid TYPE zif_gtt_mia_app_types=>tv_locid, lv_stopid TYPE zif_gtt_mia_app_types=>tv_stopid, lv_count TYPE i. FIELD-SYMBOLS: TYPE vttpvb_tab, TYPE vttsvb_tab, TYPE vtspvb_tab, TYPE zif_gtt_mia_app_types=>ts_stops. ASSIGN ir_vtts->* TO . ASSIGN ir_vttp->* TO . ASSIGN ir_vtsp->* TO . IF IS ASSIGNED AND IS ASSIGNED AND IS ASSIGNED. lt_vtts[] = []. SORT lt_vtts BY tsrfo. zcl_gtt_mia_sh_tools=>get_stops_from_shipment( EXPORTING iv_tknum = lv_tknum it_vtts = lt_vtts it_vtsp = it_vttp = IMPORTING et_stops = lt_stops ). CLEAR: lv_count. SORT lt_stops BY stopid. MOVE-CORRESPONDING lt_stops TO lt_stop_ids. DELETE ADJACENT DUPLICATES FROM lt_stop_ids. LOOP AT lt_stop_ids ASSIGNING FIELD-SYMBOL(). lv_locid = zcl_gtt_mia_tools=>get_pretty_location_id( iv_locid = -locid iv_loctype = -loctype ). APPEND -stopid_txt TO cs_header-stpid_stopid. APPEND -stopcnt TO cs_header-stpid_stopcnt. APPEND -loctype TO cs_header-stpid_loctype. APPEND lv_locid TO cs_header-stpid_locid. ENDLOOP. READ TABLE lt_stops ASSIGNING INDEX 1. IF sy-subrc = 0. cs_header-departure_dt = zcl_gtt_mia_tools=>convert_datetime_to_utc( iv_datetime = -pln_evt_datetime iv_timezone = -pln_evt_timezone ). cs_header-departure_tz = -pln_evt_timezone. cs_header-departure_locid = zcl_gtt_mia_tools=>get_pretty_location_id( iv_locid = -locid iv_loctype = -loctype ). cs_header-departure_loctype = -loctype. ENDIF. READ TABLE lt_stops ASSIGNING INDEX lines( lt_stops ). IF sy-subrc = 0. cs_header-arrival_dt = zcl_gtt_mia_tools=>convert_datetime_to_utc( iv_datetime = -pln_evt_datetime iv_timezone = -pln_evt_timezone ). cs_header-arrival_tz = -pln_evt_timezone. cs_header-arrival_locid = zcl_gtt_mia_tools=>get_pretty_location_id( iv_locid = -locid iv_loctype = -loctype ). cs_header-arrival_loctype = -loctype. ENDIF. ELSE. MESSAGE e002(zgtt_mia) WITH 'VTTS' INTO DATA(lv_dummy). zcl_gtt_mia_tools=>throw_exception( ). ENDIF. ENDMETHOD. METHOD fill_resource_tables. DATA(lv_res_tid) = get_resource_tracking_id( is_vttk = is_vttk ). IF lv_res_tid IS NOT INITIAL. et_ref_cnt = VALUE #( ( 1 ) ). et_tp_id = VALUE #( ( CONV #( lv_res_tid ) ) ). ENDIF. ENDMETHOD. METHOD fill_tracked_object_tables. IF is_vttk-exti1 IS NOT INITIAL AND is_vttk-vsart = '01'. et_res_id = VALUE #( ( 'NA' ) ). et_res_val = VALUE #( ( is_vttk-exti1 ) ). ELSEIF is_vttk-vsart = '04' AND is_vttk-signi IS NOT INITIAL. et_res_id = VALUE #( ( 'CONTAINER_ID' ) ). et_res_val = VALUE #( ( is_vttk-signi ) ). ELSEIF is_vttk-exti1 IS NOT INITIAL AND ( is_vttk-vsart = '05' OR is_vttk-vsart = '15' ). et_res_id = VALUE #( ( 'FLIGHT_NUMBER' ) ). et_res_val = VALUE #( ( is_vttk-exti1 ) ). ELSE. CLEAR: et_res_id[], et_res_val[]. ENDIF. ENDMETHOD. METHOD get_forwarding_agent_id_number. DATA: lv_forward_agt TYPE bu_partner, lt_bpdetail TYPE STANDARD TABLE OF bapibus1006_id_details. CALL METHOD cl_site_bp_assignment=>select_bp_via_cvi_link EXPORTING i_lifnr = iv_tdlnr IMPORTING e_bp = lv_forward_agt. CALL FUNCTION 'BAPI_IDENTIFICATIONDETAILS_GET' EXPORTING businesspartner = lv_forward_agt TABLES identificationdetail = lt_bpdetail. READ TABLE lt_bpdetail ASSIGNING FIELD-SYMBOL() WITH KEY identificationtype = zif_gtt_mia_app_constants=>cv_agent_id_type BINARY SEARCH. rv_id_num = COND #( WHEN sy-subrc = 0 THEN zif_gtt_mia_app_constants=>cv_agent_id_prefix && -identificationnumber ). ENDMETHOD. METHOD get_resource_tracking_id. rv_tracking_id = COND #( WHEN is_vttk-exti1 IS NOT INITIAL AND ( is_vttk-vsart = '01' OR is_vttk-vsart = '05' OR is_vttk-vsart = '15' ) THEN |{ is_vttk-tknum ALPHA = OUT }{ is_vttk-exti1 }| WHEN is_vttk-signi IS NOT INITIAL AND is_vttk-vsart = '04' THEN |{ is_vttk-tknum ALPHA = OUT }{ is_vttk-signi }| ). CONDENSE rv_tracking_id NO-GAPS. ENDMETHOD. METHOD get_shippment_header. TYPES: tt_vttk TYPE STANDARD TABLE OF vttkvb. FIELD-SYMBOLS: TYPE tt_vttk. DATA(lv_tknum) = zcl_gtt_mia_tools=>get_field_of_structure( ir_struct_data = is_app_object-maintabref iv_field_name = 'TKNUM' ). ASSIGN ir_vttk->* TO . IF IS ASSIGNED. READ TABLE ASSIGNING FIELD-SYMBOL() WITH KEY tknum = lv_tknum. IF sy-subrc = 0. rr_vttk = REF #( ). ELSE. MESSAGE e005(zgtt_mia) WITH 'VTTK OLD' lv_tknum INTO DATA(lv_dummy). zcl_gtt_mia_tools=>throw_exception( ). ENDIF. ELSE. MESSAGE e002(zgtt_mia) WITH 'VTTK' INTO lv_dummy. zcl_gtt_mia_tools=>throw_exception( ). ENDIF. ENDMETHOD. METHOD get_shippment_item_count. FIELD-SYMBOLS: TYPE ANY TABLE. ASSIGN ir_vttp->* TO . rv_count = lines( ). ENDMETHOD. METHOD get_shippment_type. rv_ship_type = COND #( WHEN iv_vttp_cnt <= 1 THEN SWITCH #( iv_vsart WHEN '01' THEN '18' WHEN '04' THEN '3' ) ELSE SWITCH #( iv_vsart WHEN '01' THEN '17' WHEN '04' THEN '2' ) ). ENDMETHOD. METHOD get_transportation_mode. rv_trans_mode = SWITCH #( iv_vsart WHEN '04' THEN '01' ""Sea WHEN '03' THEN '02' ""Rail WHEN '01' THEN '03' ""Road WHEN '05' THEN '04' ""Air WHEN '15' THEN '04' ""Air WHEN '02' THEN '05' ""Mail WHEN '' THEN '00' ""Not specified ELSE '09'). ""Not applicable ENDMETHOD. METHOD is_object_changed. rv_result = zcl_gtt_mia_tools=>is_object_changed( is_app_object = is_app_object io_ef_parameters = mo_ef_parameters it_check_tables = VALUE #( ( zif_gtt_mia_app_constants=>cs_tabledef-sh_item_new ) ( zif_gtt_mia_app_constants=>cs_tabledef-sh_item_new ) ( zif_gtt_mia_app_constants=>cs_tabledef-sh_stage_new ) ( zif_gtt_mia_app_constants=>cs_tabledef-sh_stage_old ) ( zif_gtt_mia_app_constants=>cs_tabledef-sh_item_stage_new ) ( zif_gtt_mia_app_constants=>cs_tabledef-sh_item_stage_old ) ) iv_key_field = 'TKNUM' iv_upd_field = 'UPDKZ' ). ENDMETHOD. METHOD zif_gtt_mia_tp_reader~check_relevance. DATA(lr_vttp) = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_mia_app_constants=>cs_tabledef-sh_item_new ). rv_result = zif_gtt_mia_ef_constants=>cs_condition-false. IF zcl_gtt_mia_sh_tools=>is_appropriate_type( ir_vttk = is_app_object-maintabref ) = abap_true AND zcl_gtt_mia_sh_tools=>is_delivery_assigned( ir_vttp = lr_vttp ) = abap_true AND is_object_changed( is_app_object = is_app_object ) = abap_true. CASE is_app_object-update_indicator. WHEN zif_gtt_mia_ef_constants=>cs_change_mode-insert. rv_result = zif_gtt_mia_ef_constants=>cs_condition-true. WHEN zif_gtt_mia_ef_constants=>cs_change_mode-update OR zif_gtt_mia_ef_constants=>cs_change_mode-undefined. rv_result = zcl_gtt_mia_tools=>are_structures_different( ir_data1 = zif_gtt_mia_tp_reader~get_data( is_app_object = is_app_object ) ir_data2 = zif_gtt_mia_tp_reader~get_data_old( is_app_object = is_app_object ) ). ENDCASE. ENDIF. ENDMETHOD. METHOD zif_gtt_mia_tp_reader~get_app_obj_type_id. rv_appobjid = zcl_gtt_mia_sh_tools=>get_tracking_id_sh_header( ir_vttk = is_app_object-maintabref ). ENDMETHOD. METHOD zif_gtt_mia_tp_reader~get_data. FIELD-SYMBOLS: TYPE ts_sh_header. rr_data = NEW ts_sh_header( ). ASSIGN rr_data->* TO . DATA(lr_vttp) = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_mia_app_constants=>cs_tabledef-sh_item_new ). fill_header_from_vttk( EXPORTING ir_vttk = is_app_object-maintabref iv_vttp_cnt = get_shippment_item_count( ir_vttp = lr_vttp ) CHANGING cs_header = ). fill_header_from_vttp( EXPORTING ir_vttk = is_app_object-maintabref ir_vttp = lr_vttp CHANGING cs_header = ). fill_header_from_vtts( EXPORTING ir_vttk = is_app_object-maintabref ir_vttp = lr_vttp ir_vtts = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_mia_app_constants=>cs_tabledef-sh_stage_new ) ir_vtsp = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_mia_app_constants=>cs_tabledef-sh_item_stage_new ) CHANGING cs_header = ). ENDMETHOD. METHOD zif_gtt_mia_tp_reader~get_data_old. FIELD-SYMBOLS: TYPE ts_sh_header. DATA(lo_sh_data) = NEW zcl_gtt_mia_sh_data_old( io_ef_parameters = mo_ef_parameters ). DATA(lr_vttk) = get_shippment_header( is_app_object = is_app_object ir_vttk = lo_sh_data->get_vttk( ) ). rr_data = NEW ts_sh_header( ). ASSIGN rr_data->* TO . fill_header_from_vttk( EXPORTING ir_vttk = lr_vttk iv_vttp_cnt = get_shippment_item_count( ir_vttp = lo_sh_data->get_vttp( ) ) CHANGING cs_header = ). fill_header_from_vttp( EXPORTING ir_vttk = lr_vttk ir_vttp = lo_sh_data->get_vttp( ) CHANGING cs_header = ). fill_header_from_vtts( EXPORTING ir_vttk = lr_vttk ir_vttp = lo_sh_data->get_vttp( ) ir_vtts = lo_sh_data->get_vtts( ) ir_vtsp = lo_sh_data->get_vtsp( ) CHANGING cs_header = ). ENDMETHOD. METHOD zif_gtt_mia_tp_reader~get_field_parameter. CASE iv_parameter. WHEN zif_gtt_mia_ef_constants=>cs_parameter_id-key_field. rv_result = boolc( ""iv_field_name = cs_mapping-deliv_cnt OR iv_field_name = cs_mapping-trobj_res_val OR iv_field_name = cs_mapping-resrc_cnt OR iv_field_name = cs_mapping-crdoc_ref_val OR iv_field_name = cs_mapping-stpid_stopcnt ). WHEN zif_gtt_mia_ef_constants=>cs_parameter_id-no_empty_tag. rv_result = boolc( iv_field_name = cs_mapping-departure_dt OR iv_field_name = cs_mapping-departure_tz OR iv_field_name = cs_mapping-departure_locid OR iv_field_name = cs_mapping-departure_loctype OR iv_field_name = cs_mapping-arrival_dt OR iv_field_name = cs_mapping-arrival_tz OR iv_field_name = cs_mapping-arrival_locid OR iv_field_name = cs_mapping-arrival_loctype ). WHEN OTHERS. CLEAR: rv_result. ENDCASE. ENDMETHOD. METHOD zif_gtt_mia_tp_reader~get_mapping_structure. rr_data = REF #( cs_mapping ). ENDMETHOD. METHOD zif_gtt_mia_tp_reader~get_track_id_data. ""another tip is that: for tracking ID type 'SHIPMENT_ORDER' of delivery header, ""and for tracking ID type 'RESOURCE' of shipment header, ""DO NOT enable START DATE and END DATE DATA: lv_dummy TYPE string, lv_tmp_shptrxcod TYPE /saptrx/trxcod, lv_tmp_restrxcod TYPE /saptrx/trxcod, lv_shptrxcod TYPE /saptrx/trxcod, lv_restrxcod TYPE /saptrx/trxcod. FIELD-SYMBOLS: TYPE vttkvb, TYPE vttkvb. lv_shptrxcod = zif_gtt_mia_app_constants=>cs_trxcod-sh_number. lv_restrxcod = zif_gtt_mia_app_constants=>cs_trxcod-sh_resource. CLEAR et_track_id_data. TRY. CALL FUNCTION 'ZGTT_SOF_GET_TRACKID' EXPORTING iv_type = is_app_object-appobjtype iv_app = 'MIA' IMPORTING ev_shptrxcod = lv_tmp_shptrxcod ev_restrxcod = lv_tmp_restrxcod. IF lv_tmp_shptrxcod IS NOT INITIAL. lv_shptrxcod = lv_tmp_shptrxcod. ENDIF. IF lv_tmp_restrxcod IS NOT INITIAL. lv_restrxcod = lv_tmp_restrxcod. ENDIF. CATCH cx_sy_dyn_call_illegal_func. ENDTRY. ASSIGN is_app_object-maintabref->* TO . IF IS ASSIGNED. "" SHIPMENT Tracking ID et_track_id_data = VALUE #( ( appsys = mo_ef_parameters->get_appsys( ) appobjtype = is_app_object-appobjtype appobjid = is_app_object-appobjid trxcod = lv_shptrxcod trxid = zcl_gtt_mia_sh_tools=>get_tracking_id_sh_header( ir_vttk = is_app_object-maintabref ) timzon = zcl_gtt_mia_tools=>get_system_time_zone( ) ) ). DATA(lv_res_tid_new) = get_resource_tracking_id( is_vttk = ). "" is shipment created? IF -updkz = zif_gtt_mia_ef_constants=>cs_change_mode-insert AND lv_res_tid_new IS NOT INITIAL. "" add RESOURCE Tracking ID for the new Shipment et_track_id_data = VALUE #( BASE et_track_id_data ( appsys = mo_ef_parameters->get_appsys( ) appobjtype = is_app_object-appobjtype appobjid = is_app_object-appobjid trxcod = lv_restrxcod trxid = lv_res_tid_new ) ). "" is shipment updated? ELSEIF -updkz = zif_gtt_mia_ef_constants=>cs_change_mode-update. DATA(lr_vttk_old) = get_shippment_header( is_app_object = is_app_object ir_vttk = mo_ef_parameters->get_appl_table( iv_tabledef = zif_gtt_mia_app_constants=>cs_tabledef-sh_header_old ) ). ASSIGN lr_vttk_old->* TO . IF IS ASSIGNED. DATA(lv_res_tid_old) = get_resource_tracking_id( is_vttk = ). "" is RESOURCE Tracking ID changed? IF lv_res_tid_old <> lv_res_tid_new. "" add new RESOURCE Tracking ID IF lv_res_tid_new IS NOT INITIAL. et_track_id_data = VALUE #( BASE et_track_id_data ( appsys = mo_ef_parameters->get_appsys( ) appobjtype = is_app_object-appobjtype appobjid = is_app_object-appobjid trxcod = lv_restrxcod trxid = lv_res_tid_new ) ). ENDIF. "" delete old RESOURCE Tracking ID IF lv_res_tid_old IS NOT INITIAL. et_track_id_data = VALUE #( BASE et_track_id_data ( appsys = mo_ef_parameters->get_appsys( ) appobjtype = is_app_object-appobjtype appobjid = is_app_object-appobjid trxcod = lv_restrxcod trxid = lv_res_tid_old action = zif_gtt_mia_ef_constants=>cs_change_mode-delete ) ). ENDIF. ENDIF. ELSE. MESSAGE e002(zgtt_mia) WITH 'VTTK' INTO lv_dummy. zcl_gtt_mia_tools=>throw_exception( ). ENDIF. ENDIF. ELSE. MESSAGE e002(zgtt_mia) WITH 'VTTK' INTO lv_dummy. zcl_gtt_mia_tools=>throw_exception( ). ENDIF. ENDMETHOD. ENDCLASS. ",8378,False,1509.0731250677266,median "class ZCL_GUIDRASIL_BUILDER definition public final create public . *""* public components of class ZCL_GUIDRASIL_BUILDER *""* do not include other source files here!!! public section. type-pools ABAP . type-pools CNTB . type-pools ICON . interfaces ZIF_GUIDRASIL_FUNC_RECEIVER . constants ICON_CONTAINER type ZGUIDRASIL_ICON_NAME value ICON_WD_VIEW_CONTAINER ##NO_TEXT. constants K_MODE_DESIGN type CHAR01 value 'D' ##NO_TEXT. constants K_MODE_PATTERN type CHAR01 value 'P' ##NO_TEXT. class-methods CLASS_CONSTRUCTOR . class-methods INIT_CONTROL_NAME importing !IV_TEXT type C returning value(EV_NAME) type TEXT30 . methods ADD_CONTAINER importing !IV_SIDE type I !IV_CONTROL_ID type I optional . methods ADD_CONTAINER_BOX . methods ADD_CONTAINER_CC importing !CC_NAME type CLIKE optional . methods BUILD . methods CONSTRUCTOR importing !IV_PNAME type ZGUIDRASIL_PROJECT !IV_MODE type CHAR01 default SPACE . methods GET_CREATION_CODE returning value(CODE) type STRING_TABLE . methods GET_EVENT_PATTERN returning value(PATTERN) type STRING_TABLE . methods GET_EVENT_PATTERN_PLUS returning value(PATTERN) type STRING_TABLE . methods GET_OBJECT_BY_NAME importing !NAME type CLIKE returning value(OBJECT) type ref to CL_GUI_OBJECT . methods SAVE . PROTECTED SECTION. *""* protected components of class ZCL_GUIDRASIL_CONTROL_BUILDER *""* do not include other source files here!!! METHODS add_control_object IMPORTING VALUE(fcode) TYPE ui_func VALUE(r_sender) TYPE REF TO object VALUE(r_receiver) TYPE REF TO object VALUE(r_toolbar) TYPE REF TO cl_gui_toolbar . METHODS get_menu_functions IMPORTING !fcode TYPE clike RETURNING VALUE(it_functions) TYPE ttb_button . private section. types: *""* private components of class ZCL_GUIDRASIL_BUILDER *""* do not include other source files here!!! BEGIN OF gys_control_classes, id TYPE i, ""numc5, classname TYPE seoclsname, END OF gys_control_classes . types: gyt_control_classes TYPE SORTED TABLE OF gys_control_classes WITH UNIQUE KEY id . types: BEGIN OF gys_control_admin, id TYPE i, name TYPE string, parent TYPE REF TO zcl_guidrasil_control_base, parent_name TYPE zguidrasil_container_name, control TYPE REF TO zcl_guidrasil_control_base, END OF gys_control_admin . types: gyt_control_admin TYPE TABLE OF gys_control_admin . class-data MT_IDX type TY_IDX_T . class-data MT_CTLS type ZGUIDRASIL_CTLS_T . class-data GV_CONTROL_ID type NUMC3 . data CURRENT_CONTROL_ID type I . data R_TOOLBAR type ref to CL_GUI_TOOLBAR . data MT_CONTROLS type ZGUIDRASIL_OBJ_T . data MODE type CHAR01 . data PNAME type CHAR40 . data R_DOCKING type ref to CL_GUI_DOCKING_CONTAINER . data R_TOOLBAR_CONTAINER type ref to CL_GUI_DIALOGBOX_CONTAINER . class-data GT_CONTROL_CLASSES type GYT_CONTROL_CLASSES . data T_CONTROL_ADMIN type GYT_CONTROL_ADMIN . class-data GT_DELETE_FUNCTION type TTB_BUTTON . class-data GT_CLOSE_FUNCTION type TTB_BUTTON . class-data GT_INSERT_FUNCTION type TTB_BUTTON . class-data GT_PATTERN_FUNCTION type TTB_BUTTON . data GT_CONTROL_LIST type ZGUIDRASIL_CONTROL_LIST_T . class-methods GET_NAME_BUTTON importing !IR_CONTROL type ref to ZCL_GUIDRASIL_CONTROL_BASE changing !CT_FUNCTIONS type TTB_BUTTON . methods ADD_CONTROL importing !IR_CONTROL type ref to ZCL_GUIDRASIL_CONTROL_BASE !IR_PARENT type ref to ZCL_GUIDRASIL_CONTROL_BASE optional !IV_PARENT_NAME type CLIKE optional . methods BUILD_CONTROL_TOOLBAR importing !IR_WRAPPER type ref to ZCL_GUIDRASIL_DESIGN_CONTAINER . methods BUILD_DESIGN_TOOLBAR . methods BUILD_EDIT_TOOLBAR importing !IR_WRAPPER type ref to ZCL_GUIDRASIL_DESIGN_CONTAINER !IR_CONTROL_BUILDER type ref to ZCL_GUIDRASIL_CONTROL_BASE . methods BUILD_PATTERN_TOOLBAR importing !IR_WRAPPER type ref to ZCL_GUIDRASIL_DESIGN_CONTAINER !IR_CONTROL_BUILDER type ref to ZCL_GUIDRASIL_CONTROL_BASE . methods CODE_REPLACE importing !SEARCH type CLIKE !REPLACE type CLIKE !PREFIX type CLIKE changing !CODE type STRING_TABLE . methods CREATE_WRAPPER importing !IV_CONTROL_TOOLBAR type XFELD optional !IV_EDIT_TOOLBAR type XFELD optional !IR_CONTAINER type ref to CL_GUI_CONTAINER optional !IR_PARENT_BUILDER type ref to ZCL_GUIDRASIL_CONTROL_BASE exporting !ER_WRAPPER type ref to ZCL_GUIDRASIL_DESIGN_CONTAINER . methods IS_CLOSE_FUNCTION_ENABLED importing !IR_WRAPPER type ref to ZCL_GUIDRASIL_DESIGN_CONTAINER returning value(RV_ENABLED) type XFELD . methods ON_DESIGN_FUNCTION_SELECTED for event FUNCTION_SELECTED of CL_GUI_TOOLBAR importing !FCODE . methods SET_CURRENT_CONTROL_ID returning value(CONTROL_ID) type I . methods UPDATE_CONTROLS . ENDCLASS. CLASS ZCL_GUIDRASIL_BUILDER IMPLEMENTATION. METHOD add_container. DATA lv_extension TYPE i. DATA lv_control_id TYPE i. DATA lr_control_builder TYPE REF TO zcl_guidrasil_control_base. DATA lr_wrapper TYPE REF TO zcl_guidrasil_design_container. DATA lr_docking_container TYPE REF TO cl_gui_docking_container. IF iv_control_id IS INITIAL. lv_control_id = set_current_control_id( ). ELSE. lv_control_id = iv_control_id. ENDIF. CASE iv_side. WHEN cl_gui_docking_container=>dock_at_bottom OR cl_gui_docking_container=>dock_at_top. lv_extension = 160. WHEN cl_gui_docking_container=>dock_at_left OR cl_gui_docking_container=>dock_at_right. lv_extension = 400. ENDCASE. * entsprechenden Control-Builder anlegen CALL METHOD zcl_guidrasil_control_base=>get_instance EXPORTING iv_classname = 'ZCL_GUIDRASIL_CONTROL_DOCKING' iv_control_id = lv_control_id IMPORTING er_control = lr_control_builder EXCEPTIONS OTHERS = 1. zcl_guidrasil_tools=>todo( 'Setzen Daten innerhalb drasil-Control' ). lr_control_builder->apply_settings( ). * Seite und Größe festlegen lr_docking_container ?= lr_control_builder->gr_control. lr_docking_container->dock_at( side = iv_side ). lr_docking_container->set_extension( extension = lv_extension ). * Control zur Verwaltungstabelle hinzufügen add_control( ir_control = lr_control_builder ). * im Designmode Wrapper hinzufügen create_wrapper( iv_control_toolbar = abap_true ir_parent_builder = lr_control_builder ). ENDMETHOD. METHOD add_container_box. DATA lv_extension TYPE i. DATA lr_control_builder TYPE REF TO zcl_guidrasil_control_base. DATA lr_wrapper TYPE REF TO zcl_guidrasil_design_container. DATA lv_control_id TYPE i. lv_control_id = set_current_control_id( ). * entsprechenden Control-Builder anlegen CALL METHOD zcl_guidrasil_control_base=>get_instance EXPORTING iv_classname = 'ZCL_GUIDRASIL_CONTROL_DIABOX' ir_parent_container = cl_gui_container=>screen0 iv_control_id = 0 IMPORTING er_control = lr_control_builder EXCEPTIONS OTHERS = 1. * Control zur Verwaltungstabelle hinzufügen add_control( lr_control_builder ). * im Designmode Wrapper hinzufügen CALL METHOD create_wrapper EXPORTING iv_control_toolbar = abap_true ir_parent_builder = lr_control_builder. ENDMETHOD. METHOD add_container_cc. DATA lv_extension TYPE i. DATA lr_control_builder TYPE REF TO zcl_guidrasil_control_base. DATA lr_wrapper TYPE REF TO zcl_guidrasil_design_container. DATA lr_cc_container TYPE REF TO cl_gui_custom_container. DATA lv_control_id TYPE i. lv_control_id = set_current_control_id( ). * entsprechenden Control-Builder anlegen CALL METHOD zcl_guidrasil_control_base=>get_instance EXPORTING iv_classname = 'ZCL_GUIDRASIL_CONTROL_CUSTOM' iv_name = cc_name iv_control_id = 0 IMPORTING er_control = lr_control_builder EXCEPTIONS OTHERS = 1. * Seite und Größe festlegen lr_cc_container ?= lr_control_builder->gr_control. * Control zur Verwaltungstabelle hinzufügen add_control( lr_control_builder ). * im Designmode Wrapper hinzufügen CALL METHOD create_wrapper EXPORTING iv_control_toolbar = abap_true ir_parent_builder = lr_control_builder. ENDMETHOD. METHOD add_control. DATA ls_control_admin TYPE gys_control_admin. *== New Control ls_control_admin-id = current_control_id. ls_control_admin-name = ir_control->gv_control_name. ls_control_admin-control = ir_control. ls_control_admin-parent = ir_parent. ls_control_admin-parent_name = iv_parent_name. APPEND ls_control_admin TO t_control_admin. set_current_control_id( ). DATA ls_control_list TYPE zguidrasil_control_list. CLEAR ls_control_list. READ TABLE gt_control_list TRANSPORTING NO FIELDS WITH TABLE KEY guid = ir_control->gv_guid. IF sy-subrc > 0. ls_control_list-guid = ir_control->gv_guid. ls_control_list-r_control_builder = ir_control. ls_control_list-t_container = ir_control->get_container_list( ). INSERT ls_control_list INTO TABLE gt_control_list. ENDIF. ENDMETHOD. METHOD add_control_object. DATA lr_container TYPE REF TO cl_gui_container. DATA lr_wrapper TYPE REF TO zcl_guidrasil_design_container. DATA lr_control_builder TYPE REF TO zcl_guidrasil_control_base. DATA ls_control_list LIKE LINE OF gt_control_list. ""ew20160609 FIELD-SYMBOLS TYPE gys_control_classes. CHECK fcode(1) <> '$'. * Lesen, welches Control hinzugefügt werden soll READ TABLE gt_control_classes ASSIGNING WITH KEY id = fcode. * Hinzufüge-Funktion eines Controls? CHECK sy-subrc = 0. * Container vom Wrapper holen lr_wrapper ?= r_sender. lr_container = lr_wrapper->get_container_first( ). ls_control_list-parent_container = lr_wrapper->get_container_name( ). * entsprechenden Control-Builder anlegen zcl_guidrasil_control_base=>get_instance( EXPORTING iv_classname = -classname ir_parent_container = lr_container iv_parent_container = ls_control_list-parent_container iv_control_id = -id IMPORTING er_control = lr_control_builder EXCEPTIONS OTHERS = 1 ). CHECK sy-subrc = 0. READ TABLE gt_control_list TRANSPORTING NO FIELDS WITH KEY guid = lr_control_builder->gv_guid. IF sy-subrc > 0. ls_control_list-guid = lr_control_builder->gv_guid. ls_control_list-r_control_builder = lr_control_builder. INSERT ls_control_list INTO TABLE gt_control_list. ""ew20160609 ENDIF. * Untergeordnetes Control bekannt machen lr_wrapper->add_child( lr_control_builder ). add_control( ir_control = lr_control_builder ir_parent = lr_wrapper->get_parent( ) iv_parent_name = ls_control_list-parent_container ). * Einfüge-Toolbar in Editiertoolbar ändern build_edit_toolbar( ir_wrapper = lr_wrapper ir_control_builder = lr_control_builder ). * Wrapper aufbauen, falls Control weitere Kindcontainer hat create_wrapper( iv_control_toolbar = abap_true ir_parent_builder = lr_control_builder ). ENDMETHOD. METHOD build. DATA lv_classname TYPE seoclsname. DATA ls_control_list TYPE zguidrasil_control_list. DATA lr_control_builder TYPE REF TO zcl_guidrasil_control_base. DATA lr_container TYPE REF TO cl_gui_container. DATA lr_wrapper TYPE REF TO zcl_guidrasil_design_container. DATA lv_parent_container_found TYPE boolean. FIELD-SYMBOLS TYPE zguidrasil_obj. FIELD-SYMBOLS LIKE ls_control_list. *TODO: Prüfung Klassennamen CASE mode. WHEN k_mode_design. * CALL METHOD build_design_toolbar. ENDCASE. SORT mt_controls BY control_index. * Controls aufbauen LOOP AT mt_controls ASSIGNING . READ TABLE gt_control_list ASSIGNING WITH TABLE KEY guid = -parent_guid. * Root -> erzeugen IF sy-subrc <> 0. * derzeit nur Docking-Container/ Custom Control lv_classname = -parent. CALL METHOD zcl_guidrasil_control_base=>get_instance EXPORTING iv_classname = lv_classname iv_guid = -parent_guid iv_control_id = -control_index IMPORTING er_control = lr_control_builder EXCEPTIONS OTHERS = 1. CLEAR ls_control_list. ls_control_list-guid = lr_control_builder->gv_guid. ls_control_list-r_control_builder = lr_control_builder. lr_container ?= lr_control_builder->gr_control. APPEND lr_container TO ls_control_list-t_container. INSERT ls_control_list INTO TABLE gt_control_list ASSIGNING . * Control zur Verwaltungstabelle hinzufügen set_current_control_id( ). add_control( ir_control = lr_control_builder ). ENDIF. * 1. Container ermitteln LOOP AT -t_container INTO lr_container. IF lr_container->get_name( ) = -parent_container. lv_parent_container_found = abap_true. EXIT. ENDIF. ENDLOOP. IF lv_parent_container_found = abap_false. READ TABLE -t_container INTO lr_container INDEX 1. * nur freie Container behalten und aktuellen rausnehmen DELETE -t_container INDEX 1. ENDIF. * es gibt keine? CHECK sy-subrc = 0. * im Designmode Wrapper mit Toolbar hinzufügen CASE mode. WHEN k_mode_design OR k_mode_pattern. CALL METHOD create_wrapper EXPORTING ir_container = lr_container ir_parent_builder = -r_control_builder IMPORTING er_wrapper = lr_wrapper. lr_container = lr_wrapper->get_container_first( ). ENDCASE. * Kind erzeugen lv_classname = -object. CALL METHOD zcl_guidrasil_control_base=>get_instance EXPORTING iv_classname = lv_classname iv_guid = -object_guid ir_parent_container = lr_container iv_parent_container = -parent_container iv_name = -control_name iv_control_id = -control_index * iv_dont_create = lv_dont_create IMPORTING er_control = lr_control_builder EXCEPTIONS OTHERS = 1. CLEAR ls_control_list. ls_control_list-guid = lr_control_builder->gv_guid. ls_control_list-r_control_builder = lr_control_builder. ls_control_list-t_container = lr_control_builder->get_container_list( ). INSERT ls_control_list INTO TABLE gt_control_list. CASE mode. WHEN k_mode_design. lr_wrapper->add_child( lr_control_builder ). build_edit_toolbar( ir_wrapper = lr_wrapper ir_control_builder = lr_control_builder ). WHEN k_mode_pattern. lr_wrapper->add_child( lr_control_builder ). build_pattern_toolbar( ir_wrapper = lr_wrapper ir_control_builder = lr_control_builder ). ENDCASE. add_control( ir_control = lr_control_builder ir_parent = -r_control_builder ). ENDLOOP. * Falls noch Container übrig sind -> Wrapper mit Control-Hinzufügefunktionen IF mode = k_mode_design. LOOP AT gt_control_list ASSIGNING . LOOP AT -t_container INTO lr_container. create_wrapper( iv_control_toolbar = abap_true ir_container = lr_container ir_parent_builder = -r_control_builder ). ENDLOOP. ENDLOOP. ENDIF. ENDMETHOD. METHOD build_control_toolbar. DATA lt_funcmenus TYPE ttb_btnmnu. ""ew DATA lt_functions TYPE ttb_button. DATA ls_function TYPE stb_button. * Buttons löschen CALL METHOD ir_wrapper->clear_toolbar. * Schließen Funktion IF is_close_function_enabled( ir_wrapper ) = abap_true. APPEND LINES OF gt_close_function TO lt_functions. ENDIF. *== MENÜ Eintrag für Auswahl ""CONTAINER"" CLEAR ls_function. ls_function-function = '$CONTAINER'. ls_function-text = ''. ls_function-icon = zcl_guidrasil_constants=>icon_container. ""icon_wd_view_container. ls_function-butn_type = cntb_btype_dropdown. APPEND ls_function TO lt_functions. *== MENÜ Eintrag für Auswahl ""Control"" CLEAR ls_function. ls_function-function = '$CONTROLS'. ls_function-text = ''. ls_function-icon = icon_oo_object. ls_function-butn_type = zcl_guidrasil_constants=>icon_control. ""cntb_btype_dropdown. APPEND ls_function TO lt_functions. *== MENÜ Eintrag für Auswahl ""Control"" CLEAR ls_function. ls_function-function = '$CUSTOM'. ls_function-text = ''. ls_function-icon = icon_interface. ls_function-butn_type = zcl_guidrasil_constants=>icon_control. ""cntb_btype_dropdown. APPEND ls_function TO lt_functions. * Hinzufügbare Controls APPEND LINES OF gt_insert_function TO lt_functions. CALL METHOD ir_wrapper->add_functions EXPORTING it_function = lt_functions it_funcmenu = lt_funcmenus ir_sender = ir_wrapper ir_receiver = me. ENDMETHOD. METHOD build_design_toolbar. DATA lt_events TYPE cntl_simple_events. DATA ls_event TYPE cntl_simple_event. * Design-Toolbar einmalig aufbauen CHECK mode = k_mode_design. CHECK r_toolbar_container IS NOT BOUND. * Dialogbox-Container CREATE OBJECT r_toolbar_container EXPORTING width = 30 height = 30 top = 0 left = 0 caption = 'Design-Toolbar'. * Toolbar CREATE OBJECT r_toolbar EXPORTING parent = r_toolbar_container. * ls_event-eventid = cl_gui_toolbar=>m_id_dropdown_clicked. ""ew * APPEND ls_event TO lt_event. ls_event-eventid = cl_gui_toolbar=>m_id_function_selected. APPEND ls_event TO lt_events. r_toolbar->set_registered_events( events = lt_events ). SET HANDLER on_design_function_selected FOR r_toolbar. * Funktionen für neue Docking-Container CALL METHOD r_toolbar->add_button EXPORTING fcode = '$BOTTOM' icon = icon_previous_value butn_type = cntb_btype_button quickinfo = 'Dockingcontainer unten' EXCEPTIONS cntb_error_fcode = 1. CALL METHOD r_toolbar->add_button EXPORTING fcode = '$LEFT' icon = icon_column_left butn_type = cntb_btype_button quickinfo = 'Dockingcontainer links' EXCEPTIONS cntb_error_fcode = 1. CALL METHOD r_toolbar->add_button EXPORTING fcode = '$RIGHT' icon = icon_column_right butn_type = cntb_btype_button quickinfo = 'Dockingcontainer rechts' EXCEPTIONS cntb_error_fcode = 1. CALL METHOD r_toolbar->add_button EXPORTING fcode = '$TOP' icon = icon_next_value butn_type = cntb_btype_button quickinfo = 'Dockingcontainer oben' EXCEPTIONS cntb_error_fcode = 1. ENDMETHOD. METHOD build_edit_toolbar. DATA: lt_funcmenu TYPE ttb_btnmnu, ""ew lt_function TYPE ttb_button, lrt_container TYPE cwb_container. * Buttons löschen CALL METHOD ir_wrapper->clear_toolbar. * Funktionen zum Container/Control löschen IF is_close_function_enabled( ir_wrapper ) = abap_true. APPEND LINES OF gt_close_function TO lt_function. ENDIF. APPEND LINES OF gt_delete_function TO lt_function. *** add ""Name of Control"" Button CALL METHOD get_name_button EXPORTING ir_control = ir_control_builder CHANGING ct_functions = lt_function. CALL METHOD ir_wrapper->add_functions EXPORTING it_function = lt_function it_funcmenu = lt_funcmenu ""ew ir_sender = ir_wrapper ir_receiver = me. * Prüfen, ob das Control weitere Container bereitstellt lrt_container = ir_control_builder->get_container_list( ). CHECK lrt_container IS INITIAL. ir_control_builder->init( ). * wennn nicht, evtl. Einstellungsfunktionen hinzufügen ir_control_builder->get_design_functions( IMPORTING et_functions = lt_function et_funcmenus = lt_funcmenu ). ir_wrapper->add_functions( it_function = lt_function it_funcmenu = lt_funcmenu ir_sender = ir_wrapper ir_receiver = ir_control_builder ). ENDMETHOD. METHOD build_pattern_toolbar. DATA lt_funcmenu TYPE ttb_btnmnu. DATA lt_function TYPE ttb_button. DATA lrt_container TYPE cwb_container. * Buttons löschen ir_wrapper->clear_toolbar( ). IF ir_control_builder->has_pattern( ) > 0. APPEND LINES OF gt_pattern_function TO lt_function. ENDIF. *** add ""Name of Control"" Button get_name_button( EXPORTING ir_control = ir_control_builder CHANGING ct_functions = lt_function ). ir_wrapper->add_functions( it_function = lt_function it_funcmenu = lt_funcmenu ir_sender = ir_wrapper ir_receiver = me ). * Prüfen, ob das Control weitere Container bereitstellt lrt_container = ir_control_builder->get_container_list( ). CHECK lrt_container IS INITIAL. * wennn nicht, evtl. Einstellungsfunktionen hinzufügen * lt_function = ir_control_builder->get_design_functions( ). ir_wrapper->add_functions( it_function = lt_function it_funcmenu = lt_funcmenu ir_sender = ir_wrapper ir_receiver = ir_control_builder ). ENDMETHOD. METHOD class_constructor. DATA: ls_ctls TYPE zguidrasil_ctls, ls_control_classes TYPE gys_control_classes, ls_function TYPE stb_button. * Funktion zum Schließen von Containern CLEAR ls_function. ls_function-function = '$CLOSE'. ls_function-icon = icon_close. ls_function-butn_type = cntb_btype_button. ls_function-quickinfo = 'Destroy Container'. APPEND ls_function TO gt_close_function. CLEAR ls_function. ls_function-function = '$SEP0'. ls_function-butn_type = cntb_btype_sep. APPEND ls_function TO gt_close_function. * Funktion zum Entfernen von Controls CLEAR ls_function. ls_function-function = '$DELETE'. ls_function-icon = icon_delete. ls_function-butn_type = cntb_btype_button. ls_function-quickinfo = 'Delete Current Control'. APPEND ls_function TO gt_delete_function. CLEAR ls_function. ls_function-function = '$SEP1'. ls_function-butn_type = cntb_btype_sep. APPEND ls_function TO gt_delete_function. * Funktion für die Auswahl eines Controls für Pattern CLEAR ls_function. ls_function-function = '$SELECT'. ls_function-icon = icon_system_okay. ls_function-butn_type = cntb_btype_button. APPEND ls_function TO gt_pattern_function. CLEAR ls_function. SELECT * FROM zguidrasil_ctls INTO TABLE mt_ctls WHERE usable = abap_true. LOOP AT mt_ctls INTO ls_ctls. ls_control_classes-classname = ls_ctls-classname. * verwendbare Klassen merken ADD 1 TO ls_control_classes-id. INSERT ls_control_classes INTO TABLE gt_control_classes. * Funktionsliste aufbauen SELECT SINGLE id FROM icon INTO ls_function-icon WHERE name = ls_ctls-iconname. ls_function-function = ls_control_classes-id. SHIFT ls_function-function LEFT DELETING LEADING space. ls_function-quickinfo = ls_ctls-quickinfo. ls_function-butn_type = cntb_btype_menu. APPEND ls_function TO gt_insert_function. ENDLOOP. ENDMETHOD. METHOD code_replace. LOOP AT code ASSIGNING FIELD-SYMBOL(). REPLACE ALL OCCURRENCES OF search IN WITH |{ prefix }_{ replace }|. ENDLOOP. ENDMETHOD. METHOD constructor. mode = iv_mode. pname = iv_pname. * gespeicherten Zustand laden SELECT * FROM zguidrasil_obj INTO TABLE mt_controls WHERE report = iv_pname. DATA ls_control LIKE LINE OF mt_controls. FIELD-SYMBOLS LIKE LINE OF mt_idx. DATA ls_idx LIKE LINE OF mt_idx. DATA name TYPE zguidrasil_container_name. DATA id LIKE ls_idx-control_id. LOOP AT mt_controls INTO ls_control. SPLIT ls_control-control_name AT '_' INTO name id. READ TABLE mt_idx WITH TABLE KEY name = name ASSIGNING . IF sy-subrc = 0. IF id > -control_id. -control_id = id . ENDIF. ELSE. ls_idx-name = name. ls_idx-control_id = id. INSERT ls_idx INTO TABLE mt_idx. ENDIF. ENDLOOP. ENDMETHOD. METHOD create_wrapper. DATA lrt_container TYPE cwb_container. DATA lr_container TYPE REF TO cl_gui_container. CHECK mode = k_mode_design OR mode = k_mode_pattern. * wenn angegeben, nur den übergebenen Container verwenden IF ir_container IS BOUND. CLEAR lrt_container. APPEND ir_container TO lrt_container. ELSE. * Container ermitteln lrt_container = ir_parent_builder->get_container_list( ). ENDIF. * Wrapper für jeden Container hinzufügen LOOP AT lrt_container INTO lr_container. DATA(lv_container_name) = lr_container->get_name( ). lr_container->set_name( |{ lr_container->get_name( ) }| ). * Wrappercontrol aufbauen CREATE OBJECT er_wrapper EXPORTING ir_parent_container = lr_container ir_parent_control = ir_parent_builder. * Übergeordnetes Control und Wrapper verlinken CALL METHOD ir_parent_builder->add_child( er_wrapper ). * Toolbar mit hinzufügbaren Controls IF iv_control_toolbar = abap_true. CALL METHOD build_control_toolbar EXPORTING ir_wrapper = er_wrapper. * Toolbar mit Einstellungen zum Control ELSEIF iv_edit_toolbar = abap_true. CALL METHOD build_edit_toolbar EXPORTING ir_wrapper = er_wrapper ir_control_builder = ir_parent_builder. ENDIF. ENDLOOP. ENDMETHOD. METHOD get_creation_code. DATA lt_data TYPE string_table. DATA lt_code TYPE string_table. DATA xt_data TYPE string_table. DATA xt_code TYPE string_table. LOOP AT mt_controls ASSIGNING FIELD-SYMBOL(). READ TABLE gt_control_list INTO DATA(ls_object) WITH TABLE KEY guid = -object_guid. IF sy-subrc = 0. READ TABLE gt_control_list INTO DATA(ls_parent) WITH TABLE KEY guid = -parent_guid. IF sy-subrc > 0. CLEAR ls_parent. ENDIF. IF ls_object-r_control_builder->return_creation_code( IMPORTING data = lt_data code = lt_code ) = abap_false. code_replace( EXPORTING search = '$control' prefix = 'lr' replace = ls_object-r_control_builder->gv_control_name CHANGING code = lt_data ). code_replace( EXPORTING search = '$control' prefix = 'lr' replace = ls_object-r_control_builder->gv_control_name CHANGING code = lt_code ). IF ls_parent IS NOT INITIAL. code_replace( EXPORTING search = '$parent' prefix = 'lr' replace = ls_parent-r_control_builder->gv_control_name CHANGING code = lt_code ). ENDIF. APPEND LINES OF lt_data TO xt_data. APPEND LINES OF lt_code TO xt_code. ENDIF. ENDIF. ENDLOOP. APPEND LINES OF xt_data TO code. APPEND LINES OF xt_code TO code. ENDMETHOD. METHOD get_event_pattern. DATA ls_control LIKE LINE OF gt_control_list. DATA ls_object LIKE LINE OF mt_controls. DATA lr_object TYPE REF TO cl_gui_object. DATA line TYPE string. DATA event TYPE string. DATA lr_obj TYPE REF TO cl_abap_classdescr. DATA lv_name TYPE string. TYPES: BEGIN OF ty_event_ctrl, event TYPE string, control TYPE string, name TYPE string, END OF ty_event_ctrl, BEGIN OF ty_event, event TYPE string, control TYPE string, END OF ty_event. DATA lt_events TYPE STANDARD TABLE OF ty_event. DATA ls_event TYPE ty_event. DATA lt_events_c TYPE STANDARD TABLE OF ty_event_ctrl. DATA ls_event_c TYPE ty_event_ctrl. DATA ls_event2 TYPE ty_event. *clear t_controls. * update_controls( ). _code 'CLASS lcl_main DEFINITION.'. _code ' PUBLIC SECTION.'. _code ' DATA mr_guidrasil TYPE REF TO zcl_guidrasil_builder.'. LOOP AT mt_controls INTO ls_object. READ TABLE gt_control_list INTO ls_control WITH KEY guid = ls_object-object_guid. IF sy-subrc = 0 . *== DATA DEFINITION lr_object ?= ls_control-r_control_builder->get_control( ). IF lr_object IS BOUND. lr_obj ?= cl_abap_typedescr=>describe_by_object_ref( lr_object ). lv_name = lr_obj->get_relative_name( ). line = | DATA mr_{ ls_object-control_name } TYPE REF TO { lv_name }.|. ENDIF. APPEND line TO pattern. *== EVENT HANDLER IF ls_control-r_control_builder->gt_events IS NOT INITIAL. LOOP AT ls_control-r_control_builder->gt_events INTO ls_event-event. ls_event-control = lv_name. READ TABLE lt_events TRANSPORTING NO FIELDS WITH KEY event = ls_event-event control = ls_event-control. IF sy-subrc > 0. APPEND ls_event TO lt_events. ENDIF. ls_event_c-event = ls_event-event. ls_event_c-control = lv_name. ls_event_c-name = ls_object-control_name. APPEND ls_event_c TO lt_events_c. ENDLOOP. ENDIF. ENDIF. ENDLOOP. _code ' METHODS constructor.'. LOOP AT lt_events_c INTO ls_event_c. line = | METHODS h_{ ls_event_c-event } FOR EVENT { ls_event_c-event } OF { ls_event_c-control } IMPORTING sender.|. APPEND line TO pattern. ENDLOOP. _code 'ENDCLASS.'. _code 'CLASS lcl_main IMPLEMENTATION.'. _code ' METHOD constructor.'. _code ' CREATE OBJECT mr_guidrasil'. _code ' EXPORTING'. line = ` iv_pname = '$$PROJECT$$'.`. REPLACE '$$PROJECT$$' WITH pname INTO line. APPEND line TO pattern. _code ' mr_guidrasil->build( ).'. _code ' ENDMETHOD.'. LOOP AT lt_events INTO ls_event. line = | METHOD h_{ ls_event-event }.|. APPEND line TO pattern. _code ' CASE sender.'. LOOP AT lt_events_c INTO ls_event_c WHERE event = ls_event-event AND control = ls_event-control. line = | WHEN mr_{ ls_event_c-name }.|. APPEND line TO pattern. line = | MESSAGE i000(oo) WITH '{ ls_event_c-event }' '{ ls_event_c-name }'.|. APPEND line TO pattern. ENDLOOP. _code ' ENDCASE.'. _code ' ENDMETHOD.'. ENDLOOP. _code 'ENDCLASS.'. _code 'DATA gr_main TYPE REF TO lcl_main.'. *CLASS lcl_main DEFINITION. * PUBLIC SECTION. * DATA mr_guidrasil TYPE REF TO zcl_guidrasil_builder. * DATA mr_text1 TYPE REF TO cl_gui_textedit. * DATA mr_pic TYPE REF TO cl_gui_picture. * METHODS constructor. * METHODS handle_pic_click * FOR EVENT picture_click OF cl_gui_picture * IMPORTING sender. * *ENDCLASS. * *CLASS lcl_main IMPLEMENTATION. * METHOD constructor. * CREATE OBJECT mr_guidrasil * EXPORTING * iv_pname = 'GF' * EXCEPTIONS * OTHERS = 3. * IF sy-subrc = 0. * mr_guidrasil->build( ). * * mr_text1 ?= mr_guidrasil->get_object_by_name( 'INFOTEXT' ). * mr_pic ?= mr_guidrasil->get_object_by_name( 'MEINHAUS' ). * IF mr_pic IS BOUND. * SET HANDLER handle_pic_click FOR mr_pic. * ENDIF. * * ENDIF. * ENDMETHOD. * METHOD handle_pic_click. * MESSAGE i000(oo) WITH 'BildKlick!!'. * ENDMETHOD. * *ENDCLASS. * *DATA gr_guidrasil TYPE REF TO lcl_main. ENDMETHOD. METHOD get_event_pattern_plus. pattern = zcl_guidrasil_code_creation=>create_code_complete( it_controls = mt_controls it_control_list = gt_control_list ). ENDMETHOD. METHOD get_menu_functions. DATA ls_function TYPE stb_button. DATA ls_ctls TYPE zguidrasil_ctls. DATA ls_control_class LIKE LINE OF gt_control_classes. CASE fcode. WHEN '$CONTAINER'. LOOP AT mt_ctls INTO ls_ctls WHERE type = 'C'. * Funktionsliste aufbauen für CONTAINER aufbauen READ TABLE gt_control_classes INTO ls_control_class WITH KEY classname = ls_ctls-classname. IF sy-subrc = 0. ls_function-function = ls_control_class-id. ENDIF. ls_function-quickinfo = ls_ctls-quickinfo. APPEND ls_function TO it_functions. ENDLOOP. WHEN '$CONTROLS'. LOOP AT mt_ctls INTO ls_ctls WHERE type = 'O'. * Funktionsliste aufbauen für CONTROLS aufbauen READ TABLE gt_control_classes INTO ls_control_class WITH KEY classname = ls_ctls-classname. IF sy-subrc = 0. ls_function-function = ls_control_class-id. ENDIF. ls_function-quickinfo = ls_ctls-quickinfo. APPEND ls_function TO it_functions. ENDLOOP. WHEN '$CUSTOM'. LOOP AT mt_ctls INTO ls_ctls WHERE type = 'Q'. * Funktionsliste aufbauen für CONTROLS aufbauen READ TABLE gt_control_classes INTO ls_control_class WITH KEY classname = ls_ctls-classname. IF sy-subrc = 0. ls_function-function = ls_control_class-id. ENDIF. ls_function-quickinfo = ls_ctls-quickinfo. APPEND ls_function TO it_functions. ENDLOOP. ENDCASE. ENDMETHOD. METHOD get_name_button. DATA ls_function TYPE stb_button. CHECK ir_control IS BOUND. * Funktionen zur Controlsteuerung CLEAR ls_function. ls_function-function = '$NAME'. ls_function-icon = icon_interface. ls_function-butn_type = cntb_btype_button. ls_function-text = ir_control->gv_control_name. APPEND ls_function TO ct_functions. ""==> will now only use ""CTRLFUNC ** Funktion für die Änderung des Namens * CLEAR ls_function. * ls_function-function = '$ATTRIBUTES'. * ls_function-icon = icon_system_favorites. * ls_function-butn_type = cntb_btype_button. * ls_function-quickinfo = 'Change Control Attributes'. * APPEND ls_function TO ct_functions. * Funktion für die control eigenen Änderungen CLEAR ls_function. ls_function-function = '$CTRLFUNC'. ls_function-icon = icon_system_favorites. ls_function-butn_type = cntb_btype_dropdown. ls_function-quickinfo = 'Control attributes'(cta). APPEND ls_function TO ct_functions. zcl_guidrasil_tools=>todo( 'Wenn control keine Funktionen zur Verfügung stellt, darf der Knopf nicht angezeigt werden...' ). ENDMETHOD. METHOD get_object_by_name. DATA ls_control_list TYPE zguidrasil_control_list. READ TABLE mt_controls ASSIGNING FIELD-SYMBOL() WITH KEY control_name = name. IF sy-subrc = 0. READ TABLE gt_control_list INTO ls_control_list WITH KEY guid = -object_guid. IF sy-subrc = 0. TRY . object ?= ls_control_list-r_control_builder->get_control( ). CATCH cx_sy_move_cast_error. ENDTRY. ENDIF. ENDIF. ENDMETHOD. METHOD init_control_name. DATA lv_name TYPE zguidrasil_container_name. FIELD-SYMBOLS LIKE LINE OF mt_idx. DATA ls_idx LIKE LINE OF mt_idx. IF iv_text IS INITIAL. lv_name = 'CONTROL'. ELSE. lv_name = iv_text. ENDIF. READ TABLE mt_idx WITH TABLE KEY name = lv_name ASSIGNING . IF sy-subrc = 0. ADD 1 TO -control_id. CONCATENATE iv_text '_' -control_id INTO ev_name. ELSE. ls_idx-name = lv_name. ls_idx-control_id = 1. INSERT ls_idx INTO TABLE mt_idx. CONCATENATE iv_text '_' ls_idx-control_id INTO ev_name. ENDIF. ENDMETHOD. METHOD is_close_function_enabled. DATA lr_parent_builder TYPE REF TO zcl_guidrasil_control_base. DATA lrt_container TYPE cwb_container. rv_enabled = abap_true. * Vater fragen, ob er mehrere Container bereitstellt lr_parent_builder = ir_wrapper->get_parent( ). lrt_container = lr_parent_builder->get_container_list( ). * wenn ja, dann können diese nicht einzeln geschlossen werden IF lines( lrt_container ) > 1. rv_enabled = abap_false. ENDIF. ENDMETHOD. METHOD on_design_function_selected. CASE fcode. WHEN '$BOTTOM'. * add_container( cl_gui_docking_container=>dock_at_bottom ). WHEN '$LEFT'. * add_container( cl_gui_docking_container=>dock_at_left ). WHEN '$RIGHT'. * add_container( cl_gui_docking_container=>dock_at_right ). WHEN '$TOP'. * add_container( cl_gui_docking_container=>dock_at_top ). WHEN OTHERS. EXIT. ENDCASE. ENDMETHOD. METHOD save. DATA lv_id TYPE i. DATA lv_name TYPE string. DATA ls_object TYPE zguidrasil_obj. DATA lt_objects TYPE TABLE OF zguidrasil_obj. DATA ls_control_admin TYPE gys_control_admin. DATA ls_control_list TYPE zguidrasil_ctl_hierarchy_s. DATA lt_control_list TYPE zguidrasil_ctl_hierarchy_t. DATA lr_control_builder TYPE REF TO zcl_guidrasil_control_base. DATA lr_obj TYPE REF TO cl_abap_classdescr. DATA lr_docking TYPE REF TO cl_gui_docking_container. DATA lr_splitter TYPE REF TO cl_gui_easy_splitter_container. * anfangen bei den Basiscontrols LOOP AT t_control_admin INTO ls_control_admin. ls_control_list-control = ls_control_admin-control. APPEND ls_control_list TO lt_control_list. * Liste untergeordneter Controls ermitteln CALL METHOD ls_control_admin-control->get_control_list EXPORTING ir_parent_control = ls_control_list-control CHANGING ct_control_list = lt_control_list. * Einstellungen der Controls speichern CALL METHOD ls_control_admin-control->save_all. ENDLOOP. ls_object-report = pname. LOOP AT lt_control_list INTO ls_control_list. CHECK ls_control_list-parent IS BOUND. * Control IF ls_control_list-control IS BOUND. lr_obj ?= cl_abap_typedescr=>describe_by_object_ref( ls_control_list-control ). lv_name = lr_obj->get_relative_name( ). * alles außer Wrapper speichern IF lv_name <> 'ZCL_GUIDRASIL_DESIGN_CONTAINER'. ls_object-object = lv_name. ls_object-object_guid = ls_control_list-control->gv_guid. ls_object-control_name = ls_control_list-control->gv_control_name. ls_object-parent_container = ls_control_list-control->mv_parent_container_name. ENDIF. ENDIF. * ggf. Parent speichern IF ls_control_list-parent IS BOUND. lr_obj ?= cl_abap_typedescr=>describe_by_object_ref( ls_control_list-parent ). lv_name = lr_obj->get_relative_name( ). * alles außer Wrapper speichern IF lv_name <> 'ZCL_GUIDRASIL_DESIGN_CONTAINER'. ls_object-parent = lv_name. ls_object-parent_guid = ls_control_list-parent->gv_guid. ENDIF. ENDIF. * wenn sowohl Parent als auch Child gesetzt sind IF ls_object-parent IS NOT INITIAL AND ls_object-object IS NOT INITIAL. ADD 1 TO lv_id. ls_object-control_index = lv_id. APPEND ls_object TO lt_objects. CLEAR ls_object. ls_object-report = pname. ENDIF. ENDLOOP. ** update_controls( ). * ** anfangen bei den Basiscontrols * LOOP AT t_control_admin INTO ls_control_admin. ** Einstellungen der Controls speichern * CALL METHOD ls_control_admin-control->save_all. * ENDLOOP. * * * * bisheriges Projekt löschen DELETE FROM zguidrasil_obj WHERE report = pname. * und neuen Stand speichern IF lt_objects IS NOT INITIAL. INSERT zguidrasil_obj FROM TABLE lt_objects. ENDIF. COMMIT WORK. mt_controls = lt_objects. MESSAGE s001. ENDMETHOD. METHOD set_current_control_id. ADD 1 TO current_control_id. IF control_id IS REQUESTED. control_id = current_control_id. ENDIF. ENDMETHOD. METHOD update_controls. * DATA: * lv_id TYPE i, * lv_name TYPE string, * ls_guidrasil TYPE /inw/guidrasil, ** lt_guidrasil TYPE TABLE OF /INW/guidrasil, * ls_control_admin TYPE gys_control_admin, * ls_control_list TYPE /inw/guidrasil_ctl_hierarchy, * lt_control_list TYPE /inw/guidrasil_ctl_hierarchy_t, * lr_control_builder TYPE REF TO /inw/guidrasil_control_base, * lr_obj TYPE REF TO cl_abap_classdescr, * lr_docking TYPE REF TO cl_gui_docking_container, * lr_splitter TYPE REF TO cl_gui_easy_splitter_container. * **== Geht noch nicht, wenn neue Controls hinzukommen. **== es muss erst gespeichert werden... :/ * zcl_guidrasil_tools=>todo( ). * ** anfangen bei den Basiscontrols * LOOP AT t_control_admin INTO ls_control_admin. * * ls_control_list-control = ls_control_admin-control. * APPEND ls_control_list TO lt_control_list. * ** Liste untergeordneter Controls ermitteln * CALL METHOD ls_control_admin-control->get_control_list * EXPORTING * ir_parent_control = ls_control_list-control * CHANGING * ct_control_list = lt_control_list. * ** Einstellungen der Controls speichern ** CALL METHOD ls_control_admin-control->save_all. * * ENDLOOP. * ** CLEAR ls_control_list. ** ls_control_list-guid = ls_control-r_control_builder->gv_guid. ** ls_control_list-r_control_builder = lr_control_builder. ** lr_container ?= lr_control_builder->gr_control. ** APPEND lr_container TO ls_control_list-t_container. ** INSERT ls_control_list INTO TABLE gt_control_list ** ASSIGNING . * * ls_guidrasil-report = pname. * * LOOP AT lt_control_list INTO ls_control_list. * * * CHECK ls_control_list-parent IS BOUND. * ** Control * IF ls_control_list-control IS BOUND. * * lr_obj ?= cl_abap_typedescr=>describe_by_object_ref( ls_control_list-control ). * lv_name = lr_obj->get_relative_name( ). * ** alles außer Wrapper speichern * IF lv_name <> 'ZCL_GUIDRASIL_DESIGN_CONTAINER'. * ls_guidrasil-object = lv_name. * ls_guidrasil-object_guid = ls_control_list-control->gv_guid. * ls_guidrasil-control_name = ls_control_list-control->gv_control_name. * ENDIF. * * ENDIF. * * ** ggf. Parent speichern * IF ls_control_list-parent IS BOUND. * * lr_obj ?= cl_abap_typedescr=>describe_by_object_ref( ls_control_list-parent ). * lv_name = lr_obj->get_relative_name( ). * ** alles außer Wrapper speichern * IF lv_name <> 'ZCL_GUIDRASIL_DESIGN_CONTAINER'. * ls_guidrasil-parent = lv_name. * ls_guidrasil-parent_guid = ls_control_list-parent->gv_guid. * ENDIF. * * ENDIF. * * ** wenn sowohl Parent als auch Child gesetzt sind * IF ls_guidrasil-parent IS NOT INITIAL AND * ls_guidrasil-object IS NOT INITIAL. * * ADD 1 TO lv_id. * ls_guidrasil-control_index = lv_id. * APPEND ls_guidrasil TO t_controls. * * CLEAR ls_guidrasil. * ls_guidrasil-report = pname. * * ENDIF. * * ENDLOOP. ENDMETHOD. METHOD zif_guidrasil_func_receiver~on_dropdown_clicked. ""functions DATA lt_functions TYPE ttb_button. DATA ls_function TYPE stb_button. ""Menu DATA lr_text TYPE REF TO cl_gui_textedit. DATA lv_icon TYPE icon_d. DATA lv_disabled TYPE cua_active. DATA lv_checked TYPE cua_active. DATA lv_text TYPE gui_text. DATA lx_menu TYPE REF TO cl_ctmenu. DATA lx_menu_sub TYPE REF TO cl_ctmenu. DATA lv_flag TYPE i. lt_functions = get_menu_functions( fcode ). IF lt_functions IS NOT INITIAL. *== Create menu CREATE OBJECT lx_menu. *== Set functions for Container and Controls LOOP AT lt_functions INTO ls_function. lv_text = ls_function-quickinfo. SHIFT ls_function-function LEFT DELETING LEADING space. CALL METHOD lx_menu->add_function EXPORTING fcode = ls_function-function disabled = lv_disabled checked = lv_checked text = lv_text. ENDLOOP. * create object lx_menu_sub. * CALL METHOD lx_menu_sub->add_function * EXPORTING * fcode = 'SUB1' * text = 'Sub-Menu-Test 1'. * * CALL METHOD lx_menu_sub->add_function * EXPORTING * fcode = 'SUB2' * text = 'Sub-Menu-Test 2'. * * lx_menu->add_submenu( menu = lx_menu_sub * text = 'Sub1' ). *== set menu r_toolbar->track_context_menu( context_menu = lx_menu posx = posx posy = posy ). ENDIF. ENDMETHOD. METHOD zif_guidrasil_func_receiver~on_function_selected. DATA lr_container TYPE REF TO cl_gui_container. DATA lr_wrapper TYPE REF TO zcl_guidrasil_design_container. DATA lr_control_builder TYPE REF TO zcl_guidrasil_control_base. DATA lr_parent TYPE REF TO zcl_guidrasil_control_base. DATA lrt_container TYPE cwb_container. DATA ls_function TYPE stb_button. DATA lt_function TYPE ttb_button. DATA lt_controls TYPE zguidrasil_control_t. DATA ls_control_admin TYPE gys_control_admin. DATA lv_string TYPE string. DATA lt_pattern TYPE STANDARD TABLE OF string. DATA lt_child_controls TYPE zguidrasil_control_t. DATA lr_child_control TYPE REF TO zcl_guidrasil_control_base. DATA ls_control_list LIKE LINE OF gt_control_list. FIELD-SYMBOLS TYPE string. FIELD-SYMBOLS TYPE REF TO zcl_guidrasil_control_base. FIELD-SYMBOLS TYPE gys_control_classes. * bin ich gemeint oder ein anderes Objekt? CHECK r_receiver = me. CASE fcode. * Control wurde ausgewählt für Pattern WHEN '$SELECT'. lr_wrapper ?= r_sender. CALL METHOD lr_wrapper->get_children IMPORTING er_first_control = lr_control_builder. IF lr_control_builder IS BOUND. lt_pattern = lr_control_builder->get_pattern( ). IF lt_pattern IS NOT INITIAL. CLEAR lv_string. LOOP AT lt_pattern ASSIGNING . CONCATENATE lv_string cl_abap_char_utilities=>cr_lf INTO lv_string. ENDLOOP. CALL FUNCTION 'SRM_DISPLAY_TEXT' EXPORTING im_text = lv_string. ENDIF. ENDIF. * Control löschen WHEN '$DELETE'. lr_wrapper ?= r_sender. CALL METHOD lr_wrapper->get_children IMPORTING et_controls = lt_child_controls er_first_control = lr_control_builder. LOOP AT lt_child_controls INTO lr_child_control. DELETE t_control_admin WHERE parent = lr_child_control OR control = lr_child_control. ENDLOOP. IF lr_control_builder IS BOUND. lr_control_builder->destroy( ). lr_wrapper->remove_child( ). ENDIF. CALL METHOD build_control_toolbar EXPORTING ir_wrapper = lr_wrapper. * Basis-Container schließen WHEN '$CLOSE'. lr_wrapper ?= r_sender. lr_parent = lr_wrapper->get_parent( ). IF lr_parent IS BOUND. lr_parent->destroy( ). ENDIF. WHEN '$NAME'. DATA lv_answer TYPE c LENGTH 1. DATA lv_name TYPE char30. lr_wrapper ?= r_sender. CALL METHOD lr_wrapper->get_children IMPORTING er_first_control = lr_control_builder et_controls = lt_controls. READ TABLE lt_controls ASSIGNING INDEX 1. IF sy-subrc = 0. lv_name = ->gv_control_name. TRANSLATE lv_name TO UPPER CASE. CALL FUNCTION 'POPUP_TO_GET_VALUE' EXPORTING fieldname = 'CONTROL_NAME' tabname = 'ZGUIDRASIL_OBJ' titel = 'Name Of Control' valuein = lv_name IMPORTING answer = lv_answer valueout = lv_name EXCEPTIONS fieldname_not_found = 1 OTHERS = 2. IF sy-subrc = 0 AND lv_answer IS INITIAL. TRANSLATE lv_name TO UPPER CASE. ->gv_control_name = lv_name. ENDIF. * Container vom Wrapper holen lr_wrapper ?= r_sender. * Einfüge-Toolbar in Editiertoolbar ändern build_edit_toolbar( ir_wrapper = lr_wrapper ir_control_builder = ). ENDIF. WHEN '$CTRLFUNC'. lr_wrapper ?= r_sender. CALL METHOD lr_wrapper->get_children IMPORTING er_first_control = lr_control_builder et_controls = lt_controls. READ TABLE lt_controls ASSIGNING INDEX 1. IF sy-subrc = 0. ->view_attributes( iv_edit = 'X' ). * Container vom Wrapper holen lr_wrapper ?= r_sender. * Einfüge-Toolbar in Editiertoolbar ändern build_edit_toolbar( ir_wrapper = lr_wrapper ir_control_builder = ). ENDIF. * Control hinzufügen WHEN OTHERS. CHECK fcode(1) <> '$'. add_control_object( fcode = fcode r_sender = r_sender r_receiver = r_receiver r_toolbar = r_toolbar ). ENDCASE. ENDMETHOD. ENDCLASS. ",12502,True,2564.695708247867,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 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 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 = 'PATH'. 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 = 'PATH'. 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. 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 = '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 }| ). 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=>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 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 = 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 ). 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( ). 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 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 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_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, 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. "" Changed by ri_html->add( '' ). ri_html->add( render_item_changed_by( is_item ) ). ri_html->add( '' ). "" 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_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( '
' ). 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. 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. 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. 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 = '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. 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. 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 iv_only_favorites = abap_true ) ). 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 = 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 = 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. 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 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. ENDCLASS. ",12210,True,2586.065794154665,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-committer = |{ is_comment-committer-name } <{ is_comment-committer-email }> { lv_time }|. IF is_comment-author-name IS NOT INITIAL. ls_commit-author = |{ is_comment-author-name } <{ is_comment-author-email }> { lv_time }|. ELSE. ls_commit-author = ls_commit-committer. ENDIF. ls_commit-tree = -sha1. ls_commit-parent = io_stage->get_branch_sha1( ). ls_commit-parent2 = io_stage->get_merge_source( ). 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. IF iv_name CS ` `. lcx_exception=>raise( 'Branch name cannot contain blank spaces' ). ENDIF. * ""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 ",12295,True,2511.4624375727194,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 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 = '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 }| ). 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 = '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 ). 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 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_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_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_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 iv_only_favorites = abap_true ) ). 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. ",12419,True,2628.2876339387685,median "class lcl_test definition for testing duration short risk level harmless. private section. data: anon_log type ref to zif_logger, named_log type ref to zif_logger, reopened_log type ref to zif_logger. class-methods: class_setup. methods: setup, teardown, get_first_message importing log_handle type balloghndl returning value(msg) type char255, get_messages importing log_handle type balloghndl exporting texts type table_of_strings msg_details type bal_tt_msg, format_message importing id like sy-msgid default sy-msgid lang type langu default '-' no like sy-msgno default sy-msgno v1 like sy-msgv1 default sy-msgv1 v2 like sy-msgv2 default sy-msgv2 v3 like sy-msgv3 default sy-msgv3 v4 like sy-msgv4 default sy-msgv4 returning value(msg) type string, can_create_anon_log for testing, can_create_named_log for testing, can_reopen_log for testing, can_create_expiring_log_days for testing, can_create_expiring_log_date for testing, can_open_or_create for testing, can_add_log_context for testing, can_add_to_log for testing, can_add_to_named_log for testing, auto_saves_named_log for testing, auto_saves_reopened_log for testing, can_log_string for testing, can_log_char for testing, can_log_bapiret1 for testing, can_log_bapiret2 for testing, can_log_bapi_coru_return for testing, can_log_bapi_order_return for testing, can_log_rcomp for testing, can_log_bapirettab for testing, can_log_err for testing, can_log_chained_exceptions for testing, can_log_batch_msgs for testing, can_add_msg_context for testing, can_add_callback_sub for testing, can_add_callback_fm for testing, must_use_factory for testing, can_use_and_chain_aliases for testing, return_proper_status for testing, return_proper_length for testing. endclass. ""lcl_Test class lcl_test implementation. method class_setup. zcl_logger=>new( object = 'ABAPUNIT' subobject = 'LOGGER' desc = 'Log saved in database' )->add( 'This message is in the database' ). endmethod. method setup. anon_log = zcl_logger=>new( ). named_log = zcl_logger=>new( object = 'ABAPUNIT' subobject = 'LOGGER' desc = `Hey it's a log` ). reopened_log = zcl_logger=>open( object = 'ABAPUNIT' subobject = 'LOGGER' desc = 'Log saved in database' ). endmethod. method can_create_anon_log. cl_aunit_assert=>assert_bound( act = anon_log msg = 'Cannot Instantiate Anonymous Log' ). endmethod. method can_create_named_log. cl_aunit_assert=>assert_bound( act = named_log msg = 'Cannot Instantiate Named Log' ). endmethod. method can_create_expiring_log_days. data expiring_log type ref to zif_logger. data act_header type bal_s_log. constants days_until_log_can_be_deleted type i value 365. expiring_log = zcl_logger_factory=>create_log( object = 'ABAPUNIT' subobject = 'LOGGER' desc = 'Log that is not deletable and expiring' settings = zcl_logger_factory=>create_settings( )->set_expiry_in_days( days_until_log_can_be_deleted )->set_must_be_kept_until_expiry( abap_true ) ). cl_aunit_assert=>assert_bound( act = expiring_log msg = 'Cannot Instantiate Expiring Log' ). call function 'BAL_LOG_HDR_READ' exporting i_log_handle = expiring_log->handle importing e_s_log = act_header. data lv_exp type d. lv_exp = sy-datum + days_until_log_can_be_deleted. cl_aunit_assert=>assert_equals( exporting exp = lv_exp act = act_header-aldate_del msg = 'Log is not expiring in correct amount of days' ). cl_aunit_assert=>assert_equals( exporting exp = abap_true act = act_header-del_before msg = 'Log should not be deletable before expiry date' ). endmethod. method can_create_expiring_log_date. data expiring_log type ref to zif_logger. data act_header type bal_s_log. constants days_until_log_can_be_deleted type i value 365. data lv_expire type d. lv_expire = sy-datum + days_until_log_can_be_deleted. expiring_log = zcl_logger_factory=>create_log( object = 'ABAPUNIT' subobject = 'LOGGER' desc = 'Log that is not deletable and expiring' settings = zcl_logger_factory=>create_settings( )->set_expiry_date( lv_expire )->set_must_be_kept_until_expiry( abap_true ) ). cl_aunit_assert=>assert_bound( act = expiring_log msg = 'Cannot Instantiate Expiring Log' ). call function 'BAL_LOG_HDR_READ' exporting i_log_handle = expiring_log->handle importing e_s_log = act_header. cl_aunit_assert=>assert_equals( exporting exp = lv_expire act = act_header-aldate_del msg = 'Log is not expiring on correct date' ). cl_aunit_assert=>assert_equals( exporting exp = abap_true act = act_header-del_before msg = 'Log should not be deletable before expiry date' ). endmethod. method can_reopen_log. cl_aunit_assert=>assert_bound( act = reopened_log msg = 'Cannot Reopen Log from DB' ). endmethod. method can_open_or_create. data: created_log type ref to zif_logger, handles type bal_t_logh. call function 'BAL_GLB_MEMORY_REFRESH'. ""Close Logs reopened_log = zcl_logger=>open( object = 'ABAPUNIT' subobject = 'LOGGER' desc = 'Log saved in database' create_if_does_not_exist = abap_true ). created_log = zcl_logger=>open( object = 'ABAPUNIT' subobject = 'LOGGER' desc = 'Log not in database' create_if_does_not_exist = abap_true ). call function 'BAL_GLB_SEARCH_LOG' importing e_t_log_handle = handles. cl_aunit_assert=>assert_equals( exp = 2 act = lines( handles ) msg = 'Did not create nonexistent log from OPEN' ). endmethod. method can_add_log_context. data: log type ref to zif_logger, random_country_data type t005t, act_header type bal_s_log. random_country_data-mandt = sy-mandt. random_country_data-spras = 'D'. random_country_data-land1 = 'DE'. log = zcl_logger=>new( context = random_country_data ). call function 'BAL_LOG_HDR_READ' exporting i_log_handle = log->handle importing e_s_log = act_header. cl_aunit_assert=>assert_equals( exp = 'T005T' act = act_header-context-tabname msg = 'Did not add context to log' ). cl_aunit_assert=>assert_equals( exp = random_country_data act = act_header-context-value msg = 'Did not add context to log' ). endmethod. method can_add_to_log. data: dummy type c. message s001(00) with 'I' 'test' 'the' 'logger.' into dummy. anon_log->add( ). cl_aunit_assert=>assert_equals( exp = 'Itestthelogger.' act = get_first_message( anon_log->handle ) msg = 'Did not log system message properly' ). endmethod. method can_add_to_named_log. data: dummy type c. message s001(00) with 'Testing' 'a' 'named' 'logger.' into dummy. named_log->add( ). cl_aunit_assert=>assert_equals( exp = 'Testinganamedlogger.' act = get_first_message( named_log->handle ) msg = 'Did not write to named log' ). endmethod. method auto_saves_named_log. data: dummy type c, log_numbers type bal_t_logn, msg type string. message s000(sabp_unit) with 'Testing' 'logger' 'that' 'saves.' into dummy. named_log->add( ). msg = format_message( ). call function 'BAL_GLB_MEMORY_REFRESH'. append named_log->db_number to log_numbers. call function 'BAL_DB_LOAD' exporting i_t_lognumber = log_numbers. cl_aunit_assert=>assert_equals( exp = msg act = get_first_message( named_log->handle ) msg = 'Did not write to named log' ). endmethod. method auto_saves_reopened_log. data: log_numbers type bal_t_logn, act_texts type table_of_strings, act_text type string. reopened_log->add( 'This is another message in the database' ). call function 'BAL_GLB_MEMORY_REFRESH'. append reopened_log->db_number to log_numbers. call function 'BAL_DB_LOAD' exporting i_t_lognumber = log_numbers. get_messages( exporting log_handle = reopened_log->handle importing texts = act_texts ). read table act_texts index 1 into act_text. cl_aunit_assert=>assert_equals( exp = 'This message is in the database' act = act_text msg = 'Did not autosave to reopened log' ). read table act_texts index 2 into act_text. cl_aunit_assert=>assert_equals( exp = 'This is another message in the database' act = act_text msg = 'Did not autosave to reopened log' ). endmethod. method can_log_string. data: stringmessage type string value `Logging a string, guys!`. anon_log->add( stringmessage ). cl_aunit_assert=>assert_equals( exp = stringmessage act = get_first_message( anon_log->handle ) msg = 'Did not log system message properly' ). endmethod. method can_log_char. data: charmessage type char70 value 'Logging a char sequence!'. anon_log->add( charmessage ). cl_aunit_assert=>assert_equals( exp = charmessage act = get_first_message( anon_log->handle ) msg = 'Did not log system message properly' ). endmethod. method can_log_bapiret1. data: bapi_msg type bapiret1, msg_handle type balmsghndl, expected_details type bal_s_msg, actual_details type bal_s_msg, actual_text type char200. expected_details-msgty = bapi_msg-type = 'W'. expected_details-msgid = bapi_msg-id = 'BL'. expected_details-msgno = bapi_msg-number = '001'. expected_details-msgv1 = bapi_msg-message_v1 = 'This'. expected_details-msgv2 = bapi_msg-message_v2 = 'is'. expected_details-msgv3 = bapi_msg-message_v3 = 'a'. expected_details-msgv4 = bapi_msg-message_v4 = 'test'. anon_log->add( bapi_msg ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = actual_details e_txt_msg = actual_text. cl_aunit_assert=>assert_not_initial( act = actual_details-time_stmp msg = 'Did not log system message properly' ). expected_details-msg_count = 1. clear actual_details-time_stmp. cl_aunit_assert=>assert_equals( exp = expected_details act = actual_details msg = 'Did not log system message properly' ). cl_aunit_assert=>assert_equals( exp = 'This is a test' act = condense( actual_text ) msg = 'Did not log system message properly' ). endmethod. method can_log_bapiret2. data: bapi_msg type bapiret2, msg_handle type balmsghndl, expected_details type bal_s_msg, actual_details type bal_s_msg, actual_text type char200. expected_details-msgty = bapi_msg-type = 'W'. expected_details-msgid = bapi_msg-id = 'BL'. expected_details-msgno = bapi_msg-number = '001'. expected_details-msgv1 = bapi_msg-message_v1 = 'This'. expected_details-msgv2 = bapi_msg-message_v2 = 'is'. expected_details-msgv3 = bapi_msg-message_v3 = 'a'. expected_details-msgv4 = bapi_msg-message_v4 = 'test'. anon_log->add( bapi_msg ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = actual_details e_txt_msg = actual_text. cl_aunit_assert=>assert_not_initial( act = actual_details-time_stmp msg = 'Did not log system message properly' ). expected_details-msg_count = 1. clear actual_details-time_stmp. cl_aunit_assert=>assert_equals( exp = expected_details act = actual_details msg = 'Did not log system message properly' ). cl_aunit_assert=>assert_equals( exp = 'This is a test' act = condense( actual_text ) msg = 'Did not log system message properly' ). endmethod. method can_log_bapi_coru_return. data: bapi_msg type bapi_coru_return, msg_handle type balmsghndl, expected_details type bal_s_msg, actual_details type bal_s_msg, actual_text type char200. expected_details-msgty = bapi_msg-type = 'W'. expected_details-msgid = bapi_msg-id = 'BL'. expected_details-msgno = bapi_msg-number = '001'. expected_details-msgv1 = bapi_msg-message_v1 = 'This'. expected_details-msgv2 = bapi_msg-message_v2 = 'is'. expected_details-msgv3 = bapi_msg-message_v3 = 'a'. expected_details-msgv4 = bapi_msg-message_v4 = 'test'. anon_log->add( bapi_msg ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = actual_details e_txt_msg = actual_text. cl_aunit_assert=>assert_not_initial( act = actual_details-time_stmp msg = 'Did not log system message properly' ). expected_details-msg_count = 1. clear actual_details-time_stmp. cl_aunit_assert=>assert_equals( exp = expected_details act = actual_details msg = 'Did not log system message properly' ). cl_aunit_assert=>assert_equals( exp = 'This is a test' act = condense( actual_text ) msg = 'Did not log system message properly' ). endmethod. method can_log_bapi_order_return. data: bapi_msg type bapi_order_return, msg_handle type balmsghndl, expected_details type bal_s_msg, actual_details type bal_s_msg, actual_text type char200. expected_details-msgty = bapi_msg-type = 'W'. expected_details-msgid = bapi_msg-id = 'BL'. expected_details-msgno = bapi_msg-number = '001'. expected_details-msgv1 = bapi_msg-message_v1 = 'This'. expected_details-msgv2 = bapi_msg-message_v2 = 'is'. expected_details-msgv3 = bapi_msg-message_v3 = 'a'. expected_details-msgv4 = bapi_msg-message_v4 = 'test'. anon_log->add( bapi_msg ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = actual_details e_txt_msg = actual_text. cl_aunit_assert=>assert_not_initial( act = actual_details-time_stmp msg = 'Did not log system message properly' ). expected_details-msg_count = 1. clear actual_details-time_stmp. cl_aunit_assert=>assert_equals( exp = expected_details act = actual_details msg = 'Did not log system message properly' ). cl_aunit_assert=>assert_equals( exp = 'This is a test' act = condense( actual_text ) msg = 'Did not log system message properly' ). endmethod. method can_log_rcomp. data: rcomp_msg type rcomp, msg_handle type balmsghndl, expected_details type bal_s_msg, actual_details type bal_s_msg, actual_text type char200. expected_details-msgty = rcomp_msg-msgty = 'W'. expected_details-msgid = rcomp_msg-msgid = 'BL'. expected_details-msgno = rcomp_msg-msgno = '001'. expected_details-msgv1 = rcomp_msg-msgv1 = 'This'. expected_details-msgv2 = rcomp_msg-msgv2 = 'is'. expected_details-msgv3 = rcomp_msg-msgv3 = 'a'. expected_details-msgv4 = rcomp_msg-msgv4 = 'test'. anon_log->add( rcomp_msg ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = actual_details e_txt_msg = actual_text. cl_aunit_assert=>assert_not_initial( act = actual_details-time_stmp msg = 'Did not log system message properly' ). expected_details-msg_count = 1. clear actual_details-time_stmp. cl_aunit_assert=>assert_equals( exp = expected_details act = actual_details msg = 'Did not log system message properly' ). cl_aunit_assert=>assert_equals( exp = 'This is a test' act = condense( actual_text ) msg = 'Did not log system message properly' ). endmethod. method can_log_bapirettab. data: bapi_messages type bapirettab, bapi_msg type bapiret2, exp_texts type table_of_strings, exp_text type string, exp_details type bal_tt_msg, exp_detail type bal_s_msg, act_texts type table_of_strings, act_text type string, act_details type bal_tt_msg, act_detail type bal_s_msg. define messages_are. exp_detail-msgty = bapi_msg-type = &1. exp_detail-msgid = bapi_msg-id = &2. exp_detail-msgno = bapi_msg-number = &3. exp_detail-msgv1 = bapi_msg-message_v1 = &4. exp_detail-msgv2 = bapi_msg-message_v2 = &5. exp_detail-msgv3 = bapi_msg-message_v3 = &6. exp_detail-msgv4 = bapi_msg-message_v4 = &7. exp_text = |{ exp_detail-msgv1 } { exp_detail-msgv2 } { exp_detail-msgv3 } { exp_detail-msgv4 }|. APPEND bapi_msg TO bapi_messages. APPEND exp_detail TO exp_details. APPEND exp_text TO exp_texts. end-of-definition. messages_are: 'S' 'BL' '001' 'This' 'is' 'happy' 'message', 'W' 'BL' '001' 'This' 'is' 'warning' 'message', 'E' 'BL' '001' 'This' 'is' 'angry' 'message'. anon_log->add( bapi_messages ). get_messages( exporting log_handle = anon_log->handle importing texts = act_texts msg_details = act_details ). do 3 times. read table act_details into act_detail index sy-index. read table exp_details into exp_detail index sy-index. cl_aunit_assert=>assert_not_initial( act = act_detail-time_stmp msg = 'Did not log system message properly' ). exp_detail-msg_count = 1. clear act_detail-time_stmp. cl_aunit_assert=>assert_equals( exp = exp_detail act = act_detail msg = 'Did not log bapirettab properly' ). read table act_texts into act_text index sy-index. read table exp_texts into exp_text index sy-index. cl_aunit_assert=>assert_equals( exp = exp_text act = condense( act_text ) msg = 'Did not log bapirettab properly' ). enddo. endmethod. method can_log_err. data: impossible_int type i, err type ref to cx_sy_zerodivide, act_txt type char255, exp_txt type char255, long_text type string, msg_handle type balmsghndl. try. impossible_int = 1 / 0. ""Make an error! catch cx_sy_zerodivide into err. anon_log->add( err ). exp_txt = err->if_message~get_text( ). long_text = err->if_message~get_longtext( ). endtry. msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_EXCEPTION_READ' exporting i_s_msg_handle = msg_handle importing e_txt_msg = act_txt. cl_aunit_assert=>assert_equals( exp = exp_txt ""'Division by zero' act = act_txt msg = 'Did not log throwable correctly' ). endmethod. method can_log_chained_exceptions. data: main_exception type ref to lcx_t100, previous_exception type ref to lcx_t100, catched_exception type ref to lcx_t100, msg_handle type balmsghndl, act_texts type table_of_strings, act_text type string. define exceptions_are. create object main_exception exporting previous = previous_exception id = &1 no = &2 msgv1 = &3 msgv2 = &4 msgv3 = &5 msgv4 = &6. previous_exception = main_exception. end-of-definition. ""Given exceptions_are: 'SABP_UNIT' '010' '' '' '' '', 'SABP_UNIT' '030' '' '' '' '', 'SABP_UNIT' '000' 'This' 'is' 'test' 'message'. ""When try. raise exception main_exception. catch lcx_t100 into catched_exception. anon_log->add( catched_exception ). endtry. ""Then get_messages( exporting log_handle = anon_log->handle importing texts = act_texts ). read table act_texts index 1 into act_text. cl_aunit_assert=>assert_equals( exp = format_message( id = 'SABP_UNIT' no = 010 ) "" 'Message 1' act = act_text msg = 'Did not log chained exception correctly' ). read table act_texts index 2 into act_text. cl_aunit_assert=>assert_equals( exp = format_message( id = 'SABP_UNIT' no = 030 ) "" 'Message 2' act = act_text msg = 'Did not log chained exception correctly' ). read table act_texts index 3 into act_text. cl_aunit_assert=>assert_equals( exp = format_message( id = 'SABP_UNIT' no = 000 v1 = 'This' v2 = 'is' v3 = 'test' v4 = 'message' ) "" 'Message: This is test message' act = act_text msg = 'Did not log chained exception correctly' ). endmethod. method can_log_batch_msgs. data: batch_msgs type table of bdcmsgcoll, batch_msg type bdcmsgcoll, act_texts type table_of_strings, act_text type string. define messages_are. batch_msg-msgtyp = &1. batch_msg-msgid = &2. batch_msg-msgnr = &3. batch_msg-msgv1 = &4. batch_msg-msgv2 = &5. batch_msg-msgv3 = &6. batch_msg-msgv4 = &7. APPEND batch_msg TO batch_msgs. end-of-definition. messages_are: 'S' 'SABP_UNIT' '010' '' '' '' '', 'S' 'SABP_UNIT' '030' '' '' '' '', 'S' 'SABP_UNIT' '000' 'This' 'is' 'test' 'message'. anon_log->add( batch_msgs ). get_messages( exporting log_handle = anon_log->handle importing texts = act_texts ). read table act_texts index 1 into act_text. cl_aunit_assert=>assert_equals( exp = format_message( id = 'SABP_UNIT' no = 010 ) "" 'Message 1' act = act_text msg = 'Did not log BDC return messages correctly' ). read table act_texts index 2 into act_text. cl_aunit_assert=>assert_equals( exp = format_message( id = 'SABP_UNIT' no = 030 ) "" 'Message 2' act = act_text msg = 'Did not log BDC return messages correctly' ). read table act_texts index 3 into act_text. cl_aunit_assert=>assert_equals( exp = format_message( id = 'SABP_UNIT' no = 000 v1 = 'This' v2 = 'is' v3 = 'test' v4 = 'message' ) "" 'Message: This is test message' act = act_text msg = 'Did not log BDC return messages correctly' ). endmethod. method can_add_msg_context. data: addl_context type bezei20 value 'Berlin', ""data element from dictionary! msg_handle type balmsghndl, act_details type bal_s_msg. anon_log->add( obj_to_log = 'Here is some text' context = addl_context ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = act_details. cl_aunit_assert=>assert_equals( exp = addl_context act = act_details-context-value msg = 'Did not add context correctly' ). cl_aunit_assert=>assert_equals( exp = 'BEZEI20' act = act_details-context-tabname msg = 'Did not add context correctly' ). endmethod. method can_add_callback_sub. data: msg_handle type balmsghndl, msg_detail type bal_s_msg, exp_callback type bal_s_clbk. anon_log->add( obj_to_log = 'Message with Callback' callback_form = 'FORM' callback_prog = 'PROGRAM' ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = msg_detail. exp_callback-userexitf = 'FORM'. exp_callback-userexitp = 'PROGRAM'. exp_callback-userexitt = ' '. cl_aunit_assert=>assert_equals( exp = exp_callback act = msg_detail-params-callback msg = 'Did not add callback correctly' ). endmethod. method can_add_callback_fm. data: msg_handle type balmsghndl, msg_detail type bal_s_msg, exp_callback type bal_s_clbk. anon_log->add( obj_to_log = 'Message with Callback' callback_fm = 'FUNCTION' ). msg_handle-log_handle = anon_log->handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = msg_detail. exp_callback-userexitf = 'FUNCTION'. exp_callback-userexitp = ' '. exp_callback-userexitt = 'F'. cl_aunit_assert=>assert_equals( exp = exp_callback act = msg_detail-params-callback msg = 'Did not add callback correctly' ). endmethod. method must_use_factory. data: log type ref to object. try. create object log type ('ZCL_LOGGER'). cl_aunit_assert=>fail( 'Did not force creation via factory' ). catch cx_sy_create_object_error. ""PASSED endtry. endmethod. method can_use_and_chain_aliases. data: texts type table_of_strings, text type string, msg_details type bal_tt_msg, msg_detail type bal_s_msg. anon_log->a( 'Severe Abort Error!' )->e( |Here's an error!| ). anon_log->w( 'This is a warning' )->i( `Helpful Information` ). anon_log->s( 'Great' && 'Success' ). get_messages( exporting log_handle = anon_log->handle importing texts = texts msg_details = msg_details ). read table texts index 1 into text. read table msg_details index 1 into msg_detail. cl_aunit_assert=>assert_equals( exp = 'A' act = msg_detail-msgty msg = 'Didn''t log by alias' ). cl_aunit_assert=>assert_equals( exp = 'Severe Abort Error!' act = text msg = 'Didn''t log by alias' ). read table texts index 2 into text. read table msg_details index 2 into msg_detail. cl_aunit_assert=>assert_equals( exp = 'E' act = msg_detail-msgty msg = 'Didn''t log by alias' ). cl_aunit_assert=>assert_equals( exp = 'Here''s an error!' act = text msg = 'Didn''t log by alias' ). read table texts index 3 into text. read table msg_details index 3 into msg_detail. cl_aunit_assert=>assert_equals( exp = 'W' act = msg_detail-msgty msg = 'Didn''t log by alias' ). cl_aunit_assert=>assert_equals( exp = 'This is a warning' act = text msg = 'Didn''t log by alias' ). read table texts index 4 into text. read table msg_details index 4 into msg_detail. cl_aunit_assert=>assert_equals( exp = 'I' act = msg_detail-msgty msg = 'Didn''t log by alias' ). cl_aunit_assert=>assert_equals( exp = 'Helpful Information' act = text msg = 'Didn''t log by alias' ). read table texts index 5 into text. read table msg_details index 5 into msg_detail. cl_aunit_assert=>assert_equals( exp = 'S' act = msg_detail-msgty msg = 'Didn''t log by alias' ). cl_aunit_assert=>assert_equals( exp = 'GreatSuccess' act = text msg = 'Didn''t log by alias' ). endmethod. method get_first_message. data: msg_handle type balmsghndl. msg_handle-log_handle = log_handle. msg_handle-msgnumber = '000001'. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_txt_msg = msg. endmethod. method get_messages. data: handle_as_table type bal_t_logh, message_handles type bal_t_msgh, msg_handle type balmsghndl, msg_detail type bal_s_msg, msg_text type char255. append log_handle to handle_as_table. call function 'BAL_GLB_SEARCH_MSG' exporting i_t_log_handle = handle_as_table importing e_t_msg_handle = message_handles. loop at message_handles into msg_handle. call function 'BAL_LOG_MSG_READ' exporting i_s_msg_handle = msg_handle importing e_s_msg = msg_detail e_txt_msg = msg_text. append msg_detail to msg_details. append msg_text to texts. endloop. endmethod. method format_message. call function 'FORMAT_MESSAGE' exporting id = id lang = 'E' no = no v1 = v1 v2 = v2 v3 = v3 v4 = v4 importing msg = msg exceptions not_found = 1 others = 2. * TODO: raise abap unit endmethod. method teardown. call function 'BAL_GLB_MEMORY_REFRESH'. endmethod. method return_proper_status. cl_aunit_assert=>assert_not_initial( act = anon_log->is_empty( ) msg = 'Not empty at start' ). anon_log->s( 'success' ). anon_log->i( 'info' ). cl_aunit_assert=>assert_initial( act = anon_log->is_empty( ) msg = 'Empty after add' ). cl_aunit_assert=>assert_initial( act = anon_log->has_errors( ) msg = 'Has errors when there were no errors' ). cl_aunit_assert=>assert_initial( act = anon_log->has_warnings( ) msg = 'Has warnings when there were no warnings' ). anon_log->e( 'error' ). anon_log->w( 'warning' ). cl_aunit_assert=>assert_not_initial( act = anon_log->has_errors( ) msg = 'Has no errors when there were errors' ). cl_aunit_assert=>assert_not_initial( act = anon_log->has_warnings( ) msg = 'Has no warnings when there were warnings' ). endmethod. method return_proper_length. cl_aunit_assert=>assert_equals( exp = 0 act = anon_log->length( ) msg = 'Did not return 0 length at start' ). anon_log->s( 'success' ). anon_log->i( 'info' ). anon_log->w( 'warning' ). cl_aunit_assert=>assert_equals( exp = 3 act = anon_log->length( ) msg = 'Did not return right length after add' ). endmethod. endclass. ""lcl_Test ",8177,False,1829.594813692437,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: condense_flow EXPORTING et_spaces TYPE ty_spaces_tt CHANGING ct_flow TYPE swydyflow, 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 zcl_abapgit_objects_program=>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 condense_flow. DATA: lv_spaces LIKE LINE OF et_spaces. FIELD-SYMBOLS: LIKE LINE OF ct_flow. CLEAR et_spaces. LOOP AT ct_flow ASSIGNING . lv_spaces = 0. WHILE NOT -line IS INITIAL AND -line(1) = space. lv_spaces = lv_spaces + 1. -line = -line+1. ENDWHILE. APPEND lv_spaces TO et_spaces. 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. 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' ). 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. 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 iv_program ""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 zcl_abapgit_objects_program=>ty_dynpro_tt, lv_object TYPE seqg3-garg. FIELD-SYMBOLS: TYPE zcl_abapgit_objects_program=>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, subrc: { sy-subrc }, program: { iv_program_name }, language: { mv_language }| ). 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. condense_flow( IMPORTING et_spaces = -spaces CHANGING ct_flow = lt_flow_logic ). -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_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. ",8202,False,1673.1778917887007,median "CLASS zcl_abapgit_objects DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. TYPES: ty_types_tt TYPE STANDARD TABLE OF tadir-object WITH DEFAULT KEY . TYPES: BEGIN OF ty_deserialization, obj TYPE REF TO zif_abapgit_object, xml TYPE REF TO zcl_abapgit_xml_input, package TYPE devclass, item TYPE zif_abapgit_definitions=>ty_item, END OF ty_deserialization . TYPES: ty_deserialization_tt TYPE STANDARD TABLE OF ty_deserialization WITH DEFAULT KEY . 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 RETURNING VALUE(rs_files_and_item) TYPE zcl_abapgit_objects=>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 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 RAISING zcx_abapgit_exception . CLASS-METHODS jump IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_line_number TYPE i 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 has_changed_since IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_timestamp TYPE timestamp RETURNING VALUE(rv_changed) TYPE abap_bool 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_map, item TYPE zif_abapgit_definitions=>ty_item, metadata TYPE zif_abapgit_definitions=>ty_metadata, END OF ty_obj_serializer_map, tty_obj_serializer_map TYPE SORTED TABLE OF ty_obj_serializer_map WITH UNIQUE KEY item. CLASS-DATA gt_obj_serializer_map TYPE tty_obj_serializer_map. CLASS-METHODS files_to_deserialize IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RETURNING VALUE(rt_results) TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS check_duplicates IMPORTING !it_files TYPE zif_abapgit_definitions=>ty_files_tt RAISING zcx_abapgit_exception . CLASS-METHODS prioritize_deser IMPORTING !it_results TYPE zif_abapgit_definitions=>ty_results_tt RETURNING VALUE(rt_results) TYPE zif_abapgit_definitions=>ty_results_tt . CLASS-METHODS class_name IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item RETURNING VALUE(rv_class_name) TYPE string . CLASS-METHODS warning_overwrite_adjust IMPORTING !it_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt CHANGING !ct_results TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS checks_adjust IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo !is_checks TYPE zif_abapgit_definitions=>ty_deserialize_checks CHANGING !ct_results TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS warning_overwrite_find IMPORTING !it_results TYPE zif_abapgit_definitions=>ty_results_tt RETURNING VALUE(rt_overwrite) TYPE zif_abapgit_definitions=>ty_overwrite_tt RAISING zcx_abapgit_exception . CLASS-METHODS warning_package_adjust IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo !it_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt CHANGING !ct_results TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS warning_package_find IMPORTING !it_results TYPE zif_abapgit_definitions=>ty_results_tt !io_repo TYPE REF TO zcl_abapgit_repo RETURNING VALUE(rt_overwrite) TYPE zif_abapgit_definitions=>ty_overwrite_tt RAISING zcx_abapgit_exception . CLASS-METHODS update_package_tree IMPORTING !iv_package TYPE devclass . CLASS-METHODS delete_obj IMPORTING !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 RAISING zcx_abapgit_exception . CLASS-METHODS deserialize_objects IMPORTING it_objects TYPE ty_deserialization_tt iv_ddic TYPE abap_bool DEFAULT abap_false iv_descr TYPE string 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 filter_files_to_deserialize IMPORTING it_results TYPE zif_abapgit_definitions=>ty_results_tt RETURNING VALUE(rt_results) TYPE zif_abapgit_definitions=>ty_results_tt. CLASS-METHODS adjust_namespaces IMPORTING it_results TYPE zif_abapgit_definitions=>ty_results_tt RETURNING VALUE(rt_results) TYPE zif_abapgit_definitions=>ty_results_tt. ENDCLASS. CLASS ZCL_ABAPGIT_OBJECTS IMPLEMENTATION. METHOD adjust_namespaces. FIELD-SYMBOLS: LIKE LINE OF rt_results. rt_results = it_results. LOOP AT rt_results ASSIGNING . REPLACE ALL OCCURRENCES OF '#' IN -obj_name WITH '/'. ENDLOOP. ENDMETHOD. 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. * todo, fallback to looking at transports if rv_user = 'UNKNOWN'? ENDMETHOD. METHOD checks_adjust. warning_overwrite_adjust( EXPORTING it_overwrite = is_checks-overwrite CHANGING ct_results = ct_results ). warning_package_adjust( EXPORTING io_repo = io_repo it_overwrite = is_checks-warning_package CHANGING ct_results = ct_results ). ENDMETHOD. METHOD check_duplicates. DATA: lt_files TYPE zif_abapgit_definitions=>ty_files_tt. lt_files = it_files. SORT lt_files BY path ASCENDING filename ASCENDING. DELETE ADJACENT DUPLICATES FROM lt_files COMPARING path filename. IF lines( lt_files ) <> lines( it_files ). zcx_abapgit_exception=>raise( 'Duplicates' ). ENDIF. 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 . 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. ""#EC NOTEXT 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, lo_remote_version TYPE REF TO zcl_abapgit_xml_input, lv_count TYPE i, li_comparison_result TYPE REF TO zif_abapgit_comparison_result. 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 file does not exist in remote, we don't need to validate IF sy-subrc = 0. CREATE OBJECT lo_remote_version EXPORTING iv_xml = zcl_abapgit_convert=>xstring_to_string_utf8( ls_remote_file-data ). li_comparison_result = ii_object->compare_to_remote_version( lo_remote_version ). li_comparison_result->show_confirmation_dialog( ). IF li_comparison_result->is_result_complete_halt( ) = abap_true. zcx_abapgit_exception=>raise( 'Deserialization aborted by user' ). ENDIF. 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 } not supported, serialize|. ""#EC NOTEXT 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, lo_progress TYPE REF TO zcl_abapgit_progress, lt_tadir LIKE it_tadir, lt_items TYPE zif_abapgit_definitions=>ty_items_tt, lx_error TYPE REF TO zcx_abapgit_exception, lv_text TYPE string. 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 ). CREATE OBJECT lo_progress EXPORTING iv_total = 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 ). LOOP AT lt_tadir ASSIGNING . lo_progress->show( iv_current = sy-tabix iv_text = |Delete { -obj_name }| ) ##NO_TEXT. CLEAR ls_item. ls_item-obj_type = -object. ls_item-obj_name = -obj_name. delete_obj( ls_item ). * make sure to save object deletions COMMIT WORK. ENDLOOP. CATCH zcx_abapgit_exception INTO lx_error. zcl_abapgit_default_transport=>get_instance( )->reset( ). lv_text = lx_error->get_text( ). zcx_abapgit_exception=>raise( lv_text ). ENDTRY. zcl_abapgit_default_transport=>get_instance( )->reset( ). ENDMETHOD. METHOD delete_obj. 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( ). 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. 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 zcl_abapgit_xml_input, lt_results TYPE zif_abapgit_definitions=>ty_results_tt, lt_ddic TYPE TABLE OF ty_deserialization, lt_rest TYPE TABLE OF ty_deserialization, lt_late TYPE TABLE OF ty_deserialization, lo_progress TYPE REF TO zcl_abapgit_progress, lv_path TYPE string, lt_items TYPE zif_abapgit_definitions=>ty_items_tt. DATA: lo_folder_logic TYPE REF TO zcl_abapgit_folder_logic. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_result, LIKE LINE OF lt_late. 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 = files_to_deserialize( io_repo ). checks_adjust( EXPORTING io_repo = io_repo is_checks = is_checks CHANGING ct_results = lt_results ). CREATE OBJECT lo_progress EXPORTING iv_total = lines( lt_results ). lt_items = map_results_to_items( lt_results ). check_objects_locked( iv_language = io_repo->get_dot_abapgit( )->get_master_language( ) it_items = lt_items ). lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ). LOOP AT lt_results ASSIGNING . lo_progress->show( iv_current = sy-tabix iv_text = |Deserialize { -obj_name }| ) ##NO_TEXT. CLEAR ls_item. ls_item-obj_type = -obj_type. ls_item-obj_name = -obj_name. lv_package = lo_folder_logic->path_to_package( iv_top = io_repo->get_package( ) io_dot = io_repo->get_dot_abapgit( ) iv_path = -path ). 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_master_language( ) is_metadata = lo_xml->get_metadata( ) ). compare_remote_to_local( ii_object = li_obj it_remote = lt_remote is_result = ). li_obj->mo_files = lo_files. IF li_obj->get_metadata( )-late_deser = abap_true. APPEND INITIAL LINE TO lt_late ASSIGNING . ELSEIF li_obj->get_metadata( )-ddic = abap_true. APPEND INITIAL LINE TO lt_ddic ASSIGNING . ELSE. APPEND INITIAL LINE TO lt_rest ASSIGNING . ENDIF. -item = ls_item. -obj = li_obj. -xml = lo_xml. -package = lv_package. CLEAR: lv_path, lv_package. ENDLOOP. deserialize_objects( EXPORTING it_objects = lt_ddic iv_ddic = abap_true iv_descr = 'DDIC' CHANGING ct_files = rt_accessed_files ). deserialize_objects( EXPORTING it_objects = lt_rest iv_descr = 'Objects' CHANGING ct_files = rt_accessed_files ). deserialize_objects( EXPORTING it_objects = lt_late iv_descr = 'Late' CHANGING ct_files = rt_accessed_files ). 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( ). ENDMETHOD. METHOD deserialize_checks. DATA: lt_results TYPE zif_abapgit_definitions=>ty_results_tt, li_package TYPE REF TO zif_abapgit_sap_package. lt_results = files_to_deserialize( io_repo ). rs_checks-overwrite = warning_overwrite_find( lt_results ). rs_checks-warning_package = warning_package_find( io_repo = io_repo it_results = lt_results ). IF lines( lt_results ) > 0. li_package = zcl_abapgit_factory=>get_sap_package( io_repo->get_package( ) ). rs_checks-transport-required = li_package->are_changes_recorded_in_tr_req( ). IF NOT rs_checks-transport-required IS INITIAL. rs_checks-transport-type = li_package->get_transport_type( ). ENDIF. ENDIF. ENDMETHOD. METHOD deserialize_objects. DATA: lo_progress TYPE REF TO zcl_abapgit_progress. FIELD-SYMBOLS: LIKE LINE OF it_objects. zcl_abapgit_objects_activation=>clear( ). CREATE OBJECT lo_progress EXPORTING iv_total = lines( it_objects ). LOOP AT it_objects ASSIGNING . lo_progress->show( iv_current = sy-tabix iv_text = |Deserialize { iv_descr } - { -item-obj_name }| ) ##NO_TEXT. -obj->deserialize( iv_package = -package io_xml = -xml ). APPEND LINES OF -obj->mo_files->get_accessed_files( ) TO ct_files. ENDLOOP. zcl_abapgit_objects_activation=>activate( iv_ddic ). 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 files_to_deserialize. rt_results = adjust_namespaces( prioritize_deser( filter_files_to_deserialize( zcl_abapgit_file_status=>status( io_repo ) ) ) ). ENDMETHOD. METHOD filter_files_to_deserialize. rt_results = it_results. DELETE rt_results WHERE match = abap_true. "" Full match SORT rt_results BY obj_type ASCENDING obj_name ASCENDING rstate DESCENDING. "" ensures that non-empty rstate is kept DELETE ADJACENT DUPLICATES FROM rt_results COMPARING obj_type obj_name. DELETE rt_results WHERE obj_type IS INITIAL. DELETE rt_results WHERE lstate = zif_abapgit_definitions=>c_state-added AND rstate IS INITIAL. ENDMETHOD. METHOD has_changed_since. rv_changed = abap_true. "" Assume changed IF is_supported( is_item ) = abap_false. RETURN. "" Will requre serialize which will log the error ENDIF. rv_changed = create_object( is_item = is_item iv_language = zif_abapgit_definitions=>c_english )->has_changed_since( iv_timestamp ). 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_settings=>get_instance( )->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_line_number = iv_line_number ). CATCH zcx_abapgit_exception. li_obj->jump( ). ENDTRY. 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 prioritize_deser. FIELD-SYMBOLS: LIKE LINE OF it_results. * XSLT has to be handled before CLAS/PROG LOOP AT it_results ASSIGNING WHERE obj_type = 'XSLT'. APPEND TO rt_results. ENDLOOP. * PROG before internet services, as the services might use the screens LOOP AT it_results ASSIGNING WHERE obj_type = 'PROG'. APPEND TO rt_results. ENDLOOP. * ISAP has to be handled before ISRP LOOP AT it_results ASSIGNING WHERE obj_type = 'IASP'. APPEND TO rt_results. ENDLOOP. * PINF has to be handled before DEVC for package interface usage LOOP AT it_results ASSIGNING WHERE obj_type = 'PINF'. APPEND TO rt_results. ENDLOOP. * ENHS has to be handled before ENHO LOOP AT it_results ASSIGNING WHERE obj_type = 'ENHS'. APPEND TO rt_results. ENDLOOP. * DDLS has to be handled before DCLS LOOP AT it_results ASSIGNING WHERE obj_type = 'DDLS'. APPEND TO rt_results. ENDLOOP. LOOP AT it_results ASSIGNING WHERE obj_type <> 'IASP' AND obj_type <> 'PROG' AND obj_type <> 'XSLT' AND obj_type <> 'PINF' AND obj_type <> 'ENHS' AND obj_type <> 'DDLS'. APPEND TO rt_results. ENDLOOP. ENDMETHOD. METHOD serialize. DATA: li_obj TYPE REF TO zif_abapgit_object, lo_xml TYPE REF TO zcl_abapgit_xml_output, lo_files TYPE REF TO zcl_abapgit_objects_files. 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 lo_xml. li_obj->serialize( lo_xml ). lo_files->add_xml( io_xml = lo_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( iv_type = zif_abapgit_definitions=>c_type-blob iv_data = -data ). ENDLOOP. ENDMETHOD. METHOD supported_list. DATA: lt_objects TYPE STANDARD TABLE OF ko100, lv_supported TYPE abap_bool, ls_item TYPE zif_abapgit_definitions=>ty_item. FIELD-SYMBOLS LIKE LINE OF lt_objects. 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. lv_supported = zcl_abapgit_objects=>is_supported( is_item = ls_item iv_native_only = abap_true ). IF lv_supported = abap_true. APPEND -object TO rt_types. ENDIF. ENDLOOP. 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. METHOD warning_overwrite_adjust. DATA: lt_overwrite LIKE it_overwrite, ls_overwrite LIKE LINE OF lt_overwrite. FIELD-SYMBOLS: LIKE LINE OF lt_overwrite. * make sure to get the current status, as something might have changed in the meanwhile lt_overwrite = warning_overwrite_find( ct_results ). LOOP AT lt_overwrite ASSIGNING . READ TABLE it_overwrite INTO ls_overwrite WITH KEY obj_type = -obj_type obj_name = -obj_name. IF sy-subrc <> 0 OR ls_overwrite-decision IS INITIAL. zcx_abapgit_exception=>raise( |Overwrite { -obj_type } { -obj_name } undecided| ). ENDIF. IF ls_overwrite-decision = 'N'. DELETE ct_results WHERE obj_type = -obj_type AND obj_name = -obj_name. ASSERT sy-subrc = 0. ENDIF. ENDLOOP. ENDMETHOD. METHOD warning_overwrite_find. DATA: ls_overwrite LIKE LINE OF rt_overwrite. FIELD-SYMBOLS: LIKE LINE OF it_results. LOOP AT it_results ASSIGNING WHERE NOT obj_type IS INITIAL. IF -lstate IS NOT INITIAL AND -lstate <> zif_abapgit_definitions=>c_state-deleted AND NOT ( -lstate = zif_abapgit_definitions=>c_state-added AND -rstate IS INITIAL ). * current object has been modified locally, add to table CLEAR ls_overwrite. MOVE-CORRESPONDING TO ls_overwrite. APPEND ls_overwrite TO rt_overwrite. ENDIF. ENDLOOP. SORT rt_overwrite. DELETE ADJACENT DUPLICATES FROM rt_overwrite. ENDMETHOD. METHOD warning_package_adjust. DATA: lt_overwrite LIKE it_overwrite, ls_overwrite LIKE LINE OF lt_overwrite. FIELD-SYMBOLS: LIKE LINE OF lt_overwrite. * make sure to get the current status, as something might have changed in the meanwhile lt_overwrite = warning_package_find( it_results = ct_results io_repo = io_repo ). LOOP AT lt_overwrite ASSIGNING . READ TABLE it_overwrite INTO ls_overwrite WITH KEY obj_type = -obj_type obj_name = -obj_name. IF sy-subrc <> 0 OR ls_overwrite-decision IS INITIAL. zcx_abapgit_exception=>raise( |Overwrite odd package { -obj_type } { -obj_name } undecided| ). ENDIF. IF ls_overwrite-decision = 'N'. DELETE ct_results WHERE obj_type = -obj_type AND obj_name = -obj_name. ASSERT sy-subrc = 0. ENDIF. ENDLOOP. ENDMETHOD. METHOD warning_package_find. DATA: lv_package TYPE devclass, lt_overwrite_uniqe TYPE HASHED TABLE OF zif_abapgit_definitions=>ty_overwrite WITH UNIQUE KEY obj_type obj_name devclass, ls_overwrite LIKE LINE OF rt_overwrite, ls_tadir TYPE zif_abapgit_definitions=>ty_tadir. DATA: lo_folder_logic TYPE REF TO zcl_abapgit_folder_logic. FIELD-SYMBOLS: LIKE LINE OF it_results. lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ). LOOP AT it_results ASSIGNING . lv_package = lo_folder_logic->path_to_package( iv_top = io_repo->get_package( ) io_dot = io_repo->get_dot_abapgit( ) iv_path = -path ). ls_tadir = zcl_abapgit_factory=>get_tadir( )->read_single( iv_object = -obj_type iv_obj_name = -obj_name ). IF NOT ls_tadir IS INITIAL AND ls_tadir-devclass <> lv_package. * overwriting object from different package than expected CLEAR ls_overwrite. ls_overwrite-obj_type = -obj_type. ls_overwrite-obj_name = -obj_name. ls_overwrite-devclass = ls_tadir-devclass. INSERT ls_overwrite INTO TABLE lt_overwrite_uniqe. ENDIF. ENDLOOP. rt_overwrite = lt_overwrite_uniqe. ENDMETHOD. ENDCLASS. ",8441,False,1858.2450213869727,median "CLASS zxxx_cl_bs_log DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. TYPES: v_message_param_id TYPE n LENGTH 10, s_input_parameters TYPE rsra_s_parameter, t_input_parameters TYPE rsra_t_alert_definition. CONSTANTS: mc_msg_ident TYPE c LENGTH 9 VALUE 'MSG_IDENT', mc_log_number TYPE spo_par VALUE '%LOGNUMBER', mc_dflt_log_object TYPE balobj_d VALUE '/SCWM/WME', mc_log_subobject_log TYPE balobj_d VALUE 'LOG'. CLASS-DATA: gui_docking_container TYPE REF TO cl_gui_docking_container, gui_alv_grid TYPE REF TO cl_gui_alv_grid, sel_message_param_id TYPE v_message_param_id. CLASS-METHODS get_instance RETURNING VALUE(ro_instance) TYPE REF TO zxxx_cl_bs_log. CLASS-METHODS init IMPORTING !iv_object TYPE balobj_d DEFAULT mc_dflt_log_object !iv_subobject TYPE balsubobj !iv_extnumber TYPE balnrext OPTIONAL !it_extnumber_list TYPE stringtab OPTIONAL !iv_lgnum TYPE /scwm/lgnum OPTIONAL !io_sap_log TYPE REF TO /scwm/cl_log OPTIONAL RETURNING VALUE(ro_instance) TYPE REF TO zxxx_cl_bs_log. CLASS-METHODS to_msgde IMPORTING iv_fnam TYPE char50 is_msgde TYPE s_input_parameters OPTIONAL is_data TYPE data OPTIONAL it_data TYPE ANY TABLE OPTIONAL RETURNING VALUE(rt_msgde) TYPE t_input_parameters. METHODS get_protocol RETURNING VALUE(rt_protocol) TYPE bapirettab . METHODS set_sap_log IMPORTING !io_log TYPE REF TO /scwm/cl_log OPTIONAL. METHODS log_message IMPORTING msgde TYPE t_input_parameters OPTIONAL. METHODS log_saplog IMPORTING !io_log TYPE REF TO /scwm/cl_log . METHODS log_exception IMPORTING !io_exception TYPE REF TO cx_root . METHODS log_api_message IMPORTING !io_api_message TYPE REF TO /scwm/if_api_message. METHODS log_dm_message IMPORTING !io_dm_message TYPE REF TO /scwm/cl_dm_message_no OPTIONAL !it_dm_message TYPE /scdl/dm_message_tab. METHODS log_sy_message IMPORTING !is_symsg TYPE symsg. METHODS log_bapiret IMPORTING !it_bapiret TYPE bapirettab . METHODS log_line. METHODS warning IMPORTING !msgtx TYPE char200 OPTIONAL !msgno TYPE symsgno OPTIONAL !msgv1 TYPE any OPTIONAL !msgv2 TYPE any OPTIONAL !msgv3 TYPE any OPTIONAL !msgv4 TYPE any OPTIONAL !msgde TYPE t_input_parameters OPTIONAL. METHODS log_caller . METHODS info IMPORTING !msgtx TYPE char200 OPTIONAL !msgno TYPE symsgno OPTIONAL !msgv1 TYPE any OPTIONAL !msgv2 TYPE any OPTIONAL !msgv3 TYPE any OPTIONAL !msgv4 TYPE any OPTIONAL !msgde TYPE t_input_parameters OPTIONAL. METHODS success IMPORTING !msgtx TYPE char200 OPTIONAL !msgno TYPE symsgno OPTIONAL !msgv1 TYPE any OPTIONAL !msgv2 TYPE any OPTIONAL !msgv3 TYPE any OPTIONAL !msgv4 TYPE any OPTIONAL !msgde TYPE t_input_parameters OPTIONAL. METHODS error IMPORTING !msgtx TYPE char200 OPTIONAL !msgno TYPE symsgno OPTIONAL !msgv1 TYPE any OPTIONAL !msgv2 TYPE any OPTIONAL !msgv3 TYPE any OPTIONAL !msgv4 TYPE any OPTIONAL !msgde TYPE t_input_parameters OPTIONAL. METHODS save IMPORTING !iv_finalize_log TYPE abap_bool DEFAULT abap_true. PROTECTED SECTION. TYPES: t_log_stack TYPE TABLE OF REF TO zxxx_cl_bs_log WITH DEFAULT KEY. CLASS-DATA: instance TYPE REF TO zxxx_cl_bs_log, log_stack TYPE t_log_stack, "" LIFO: Last log initiated is first to be saved has_error TYPE abap_bool, save_error TYPE abap_bool. DATA log_header TYPE bal_s_log . DATA log_handle TYPE balloghndl . DATA message_text TYPE char200 . DATA message_type TYPE symsgty . DATA content_type TYPE i . DATA message_class TYPE symsgid . DATA message_params TYPE bal_s_parm . DATA message_number TYPE symsgno . DATA message_var1 TYPE symsgv . DATA message_var2 TYPE symsgv . DATA message_var3 TYPE symsgv . DATA message_var4 TYPE symsgv . DATA message_priority TYPE balprobcl . DATA message_context TYPE bal_s_cont . DATA message_detail TYPE /scwm/tt_msg_details. DATA message_detail_input TYPE t_input_parameters. DATA message_param_id TYPE v_message_param_id. DATA lgnum TYPE /scwm/lgnum . DATA validity_in_days TYPE i VALUE 180 ##NO_TEXT. DATA log_protocol TYPE bapirettab . DATA log_counter TYPE i . DATA sap_log TYPE REF TO /scwm/cl_log . DATA process_start TYPE timestampl. DATA process_end TYPE timestampl. DATA caller TYPE c LENGTH 200. CONSTANTS log_type_error TYPE symsgty VALUE 'E' ##NO_TEXT. CONSTANTS log_type_warning TYPE symsgty VALUE 'W' ##NO_TEXT. CONSTANTS log_type_success TYPE symsgty VALUE 'S' ##NO_TEXT. CONSTANTS log_type_info TYPE symsgty VALUE 'I' ##NO_TEXT. CONSTANTS message_text_id TYPE symsgid VALUE 'BL' ##NO_TEXT. CONSTANTS message_text_no TYPE symsgno VALUE '001' ##NO_TEXT. CONSTANTS log_process_create TYPE char4 VALUE 'CREA' ##NO_TEXT. CONSTANTS log_process_init TYPE char4 VALUE 'INIT' ##NO_TEXT. CONSTANTS log_process_save TYPE char4 VALUE 'SAVE' ##NO_TEXT. CONSTANTS log_process_exception TYPE char4 VALUE 'EXCP' ##NO_TEXT. METHODS add_msg_to_log_protocol IMPORTING !is_msg_handle TYPE balmsghndl . METHODS build_extnumber IMPORTING extnumber TYPE balnrext OPTIONAL extnumber_list TYPE stringtab OPTIONAL CHANGING log_header TYPE bal_s_log. METHODS error_handling IMPORTING !iv_process TYPE char4 !iv_subrc TYPE sysubrc OPTIONAL !io_exception TYPE REF TO cx_root OPTIONAL . METHODS set_priority . METHODS set_content IMPORTING !msgtx TYPE char200 !msgno TYPE symsgno !msgv1 TYPE any !msgv2 TYPE any !msgv3 TYPE any !msgv4 TYPE any . METHODS create_message IMPORTING !msgtx TYPE char200 OPTIONAL !msgno TYPE symsgno OPTIONAL !msgv1 TYPE any OPTIONAL !msgv2 TYPE any OPTIONAL !msgv3 TYPE any OPTIONAL !msgv4 TYPE any OPTIONAL !msgde TYPE t_input_parameters OPTIONAL. METHODS add_msg_by_message_text . METHODS add_msg_by_message_object . METHODS add_timestamp RETURNING VALUE(rv_time) TYPE symsgv . METHODS build_validity CHANGING log_header TYPE bal_s_log. METHODS set_context. METHODS log_duration. METHODS det_caller. METHODS save_log. METHODS add_message_detail. METHODS save_message_detail IMPORTING it_new_lognumbers TYPE bal_t_lgnm. ENDCLASS. CLASS zxxx_cl_bs_log IMPLEMENTATION. METHOD add_message_detail. CHECK message_detail_input IS NOT INITIAL. "" Add message identifier, example SBAL_CALLBACK message_params-callback-userexitp = 'ZXXX_R_BS_LOG_CALLBACK'. message_params-callback-userexitf = 'ON_CLICK_MSG_DETAIL'. message_params-callback-userexitt = ' '. message_param_id = message_param_id + 1. APPEND VALUE #( parname = mc_msg_ident parvalue = message_param_id ) TO message_params-t_par. APPEND VALUE #( v_id = message_param_id t_input_parameter = message_detail_input ) TO message_detail. CLEAR: message_detail_input. ENDMETHOD. METHOD add_msg_by_message_object. IF sap_log IS BOUND. sap_log->add_message( ip_msgty = message_type ip_msgid = message_class ip_msgno = message_number ip_msgv1 = message_var1 ip_msgv2 = message_var2 ip_msgv3 = message_var3 ip_msgv4 = message_var4 ). ENDIF. DATA(ls_msg) = VALUE bal_s_msg( msgty = message_type probclass = message_priority context = message_context params = message_params msgid = message_class msgno = message_number msgv1 = message_var1 msgv2 = message_var2 msgv3 = message_var3 msgv4 = message_var4 ). DATA(ls_msg_handle) = VALUE balmsghndl( ). CALL FUNCTION 'BAL_LOG_MSG_ADD' EXPORTING i_log_handle = log_handle i_s_msg = ls_msg IMPORTING e_s_msg_handle = ls_msg_handle EXCEPTIONS log_not_found = 1 msg_inconsistent = 2 log_is_full = 3 OTHERS = 4. IF sy-subrc <> 0. CALL METHOD error_handling EXPORTING iv_process = log_process_create iv_subrc = sy-subrc. ELSE. CALL METHOD add_msg_to_log_protocol EXPORTING is_msg_handle = ls_msg_handle. ENDIF. ENDMETHOD. METHOD add_msg_by_message_text. IF sap_log IS BOUND. sap_log->add_message( ip_msgty = message_type ip_msg = CONV #( message_text ) ). ENDIF. DATA(ls_msg_handle) = VALUE balmsghndl( ). CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT' EXPORTING i_log_handle = log_handle i_msgty = message_type i_probclass = message_priority i_s_context = message_context i_text = message_text i_s_params = message_params IMPORTING e_s_msg_handle = ls_msg_handle EXCEPTIONS log_not_found = 1 msg_inconsistent = 2 log_is_full = 3 OTHERS = 4. IF sy-subrc <> 0. CALL METHOD error_handling EXPORTING iv_process = log_process_create iv_subrc = sy-subrc. ELSE. CALL METHOD add_msg_to_log_protocol EXPORTING is_msg_handle = ls_msg_handle. ENDIF. ENDMETHOD. METHOD add_msg_to_log_protocol. DATA(ls_msg) = VALUE bal_s_msg( ). CALL FUNCTION 'BAL_LOG_MSG_READ' EXPORTING i_s_msg_handle = is_msg_handle IMPORTING e_s_msg = ls_msg EXCEPTIONS log_not_found = 1 msg_not_found = 2 OTHERS = 3. IF sy-subrc = 0. DATA(ls_bapiret2) = CORRESPONDING bapiret2( ls_msg MAPPING id = msgid type = msgty number = msgno message_v1 = msgv1 message_v2 = msgv2 message_v3 = msgv3 message_v4 = msgv4 ). CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL' EXPORTING id = ls_msg-msgid number = ls_msg-msgno textformat = 'RTF' message_v1 = ls_msg-msgv1 message_v2 = ls_msg-msgv2 message_v3 = ls_msg-msgv3 message_v4 = ls_msg-msgv4 IMPORTING message = ls_bapiret2-message. APPEND ls_bapiret2 TO log_protocol. ENDIF. ENDMETHOD. METHOD add_timestamp. DATA: lv_timestamp TYPE timestampl. GET TIME STAMP FIELD lv_timestamp. rv_time = |{ lv_timestamp }|. "" DD.MM.YYYY, hh:mm:ss.ms rv_time = |{ rv_time+6(2) }.{ rv_time+4(2) }.{ rv_time(4) }, | & |{ rv_time+8(2) }:{ rv_time+10(2) }:{ rv_time+12(2) }{ rv_time+14 }|. ENDMETHOD. METHOD build_extnumber. DATA(lt_extnumber_list) = VALUE stringtab( ). IF extnumber IS NOT INITIAL. APPEND extnumber TO lt_extnumber_list. ELSEIF extnumber_list IS NOT INITIAL. lt_extnumber_list = extnumber_list. ENDIF. IF lt_extnumber_list IS NOT INITIAL. LOOP AT lt_extnumber_list ASSIGNING FIELD-SYMBOL(). CASE sy-tabix. WHEN 1. log_header-extnumber = |{ }|. WHEN OTHERS. log_header-extnumber = |{ log_header-extnumber } { }|. ENDCASE. ENDLOOP. ELSE. SELECT SINGLE * FROM balsubt INTO @DATA(ls_balsubt) WHERE spras EQ @sy-langu AND object EQ @log_header-object AND subobject EQ @log_header-subobject. log_header-extnumber = ls_balsubt-subobjtxt. ENDIF. ENDMETHOD. METHOD build_validity. DATA: ls_log_act TYPE /scwm/log_act. DO 2 TIMES. CASE sy-index. WHEN 1. "" Note: Configure Z-Subobject of Object "" /SCWM/WME in Transaction/SCWM/ACTLOG CALL FUNCTION '/SCWM/LOG_ACT_READ_SINGLE' EXPORTING iv_lgnum = lgnum iv_subobject = log_header-subobject IMPORTING es_log_act = ls_log_act EXCEPTIONS not_found = 1 OTHERS = 2. WHEN 2. ls_log_act-lgnum = lgnum. ls_log_act-subobject = log_header-subobject. ls_log_act-validity = validity_in_days. ENDCASE. IF sy-subrc = 0 AND ls_log_act-validity > 0. "" Append valid expiration date CALL FUNCTION '/SCWM/APP_LOG_EXPIRY_DATE_DET' EXPORTING is_log_act = ls_log_act CHANGING cs_log = log_header. EXIT. ENDIF. ENDDO. ENDMETHOD. METHOD create_message. CALL METHOD set_content EXPORTING msgtx = msgtx msgno = msgno msgv1 = msgv1 msgv2 = msgv2 msgv3 = msgv3 msgv4 = msgv4. message_detail_input = msgde. CALL METHOD set_context. CALL METHOD set_priority. CALL METHOD add_message_detail. ADD 1 TO log_counter. CASE content_type. WHEN 1. CALL METHOD add_msg_by_message_text. WHEN 2. CALL METHOD add_msg_by_message_object. ENDCASE. CLEAR: message_params. ENDMETHOD. METHOD det_caller. CHECK caller CO ' _0'. CALL METHOD zxxx_cl_bs_session=>get_callstack IMPORTING ev_function = DATA(lv_function) ev_method = DATA(lv_method) ev_class = DATA(lv_class) ev_report = DATA(lv_report). IF lv_function IS NOT INITIAL. caller = lv_function. ELSEIF lv_class IS NOT INITIAL AND lv_method IS NOT INITIAL. CONCATENATE lv_class '=>' lv_method INTO caller. ELSEIF lv_report IS NOT INITIAL. caller = lv_report. ELSE. RETURN. ENDIF. ENDMETHOD. METHOD error. message_type = log_type_error. CALL METHOD create_message EXPORTING msgtx = msgtx msgno = msgno msgv1 = msgv1 msgv2 = msgv2 msgv3 = msgv3 msgv4 = msgv4 msgde = msgde. ENDMETHOD. METHOD error_handling. "" Stellt sicher, dass Fehlerhandling pro Fehler nur "" einmal fehlschlagen kann und keine Endlosschleife "" entsteht. CHECK has_error EQ abap_false AND save_error EQ abap_false. has_error = abap_true. *** Eingangsdaten sichern DATA(lv_msg_object) = log_header-object. DATA(lv_msg_subobj) = log_header-subobject. DATA(lv_msg_extnum) = log_header-extnumber. DATA(lv_msg_alddel) = log_header-aldate_del. DATA(lv_msg_class) = message_class. DATA(lv_msg_typ) = message_type. DATA(lv_msg_txt) = message_text. DATA(lv_msg_nr) = message_number. DATA(lv_msg_v1) = message_var1. DATA(lv_msg_v2) = message_var2. DATA(lv_msg_v3) = message_var3. DATA(lv_msg_v4) = message_var4. "" Versuch zum alten Log Fehlernachricht bzgl. "" fehlgeschlagenem Logging hinzuzufügen. MESSAGE e001(zxxx_log) INTO DATA(lv_msg). log_message( ). *** Bestehendes Log abschließen und neues für Fehlerbehandlung erzeugen save( ). init( iv_object = mc_dflt_log_object iv_subobject = 'LOG' iv_extnumber = 'Logging: Error Handling' iv_lgnum = lgnum ). MESSAGE e000(zxxx_log) WITH iv_process INTO lv_msg. log_message( ). *** Allgemeine Log-Daten loggen DATA(lv_msg_txt_gen) = VALUE char200( ). lv_msg_txt_gen = |; OBJECT: { lv_msg_object }; SUBOBJ: { lv_msg_subobj }| && |; EXTNUM: { lv_msg_extnum }; ALDDEL: { lv_msg_alddel }|. error( msgtx = lv_msg_txt_gen ). CASE iv_process. WHEN log_process_init. CASE iv_subrc. WHEN 1. MESSAGE e006(zxxx_log) WITH iv_subrc INTO lv_msg. WHEN OTHERS. MESSAGE e007(zxxx_log) WITH iv_subrc INTO lv_msg. ENDCASE. WHEN log_process_save. CASE iv_subrc. WHEN 1. MESSAGE e008(zxxx_log) WITH iv_subrc INTO lv_msg. WHEN 2. MESSAGE e009(zxxx_log) WITH iv_subrc INTO lv_msg. WHEN 3. MESSAGE e010(zxxx_log) WITH iv_subrc INTO lv_msg. WHEN OTHERS. MESSAGE e011(zxxx_log) WITH iv_subrc INTO lv_msg. ENDCASE. WHEN OTHERS. CASE sy-subrc. WHEN 1. MESSAGE e008(zxxx_log) WITH iv_subrc INTO lv_msg. WHEN 2. MESSAGE e012(zxxx_log) WITH iv_subrc INTO lv_msg. WHEN 3. MESSAGE e013(zxxx_log) WITH iv_subrc INTO lv_msg. WHEN OTHERS. MESSAGE e014(zxxx_log) WITH iv_subrc INTO lv_msg. ENDCASE. ENDCASE. log_message( ). *** Prozessbedingte Log-Daten loggen CASE iv_process. WHEN log_process_init. "" Nichts Besonderes zum Loggen WHEN log_process_create. IF message_text CN ' _0'. MESSAGE e015(zxxx_log) WITH lv_msg_typ INTO lv_msg. log_message( ). CALL METHOD error EXPORTING msgtx = lv_msg_txt. ELSEIF message_number CN ' _0'. MESSAGE e003(zxxx_log) WITH lv_msg_nr lv_msg_class INTO lv_msg. log_message( ). MESSAGE e004(zxxx_log) WITH lv_msg_v1 lv_msg_v2 lv_msg_v3 lv_msg_v4 INTO lv_msg. log_message( ). ELSE. MESSAGE e002(zxxx_log) INTO lv_msg. log_message( ). ENDIF. WHEN log_process_exception. DATA(lo_exc_descr) = NEW cl_instance_description( the_subject = io_exception ). MESSAGE e005(zxxx_log) WITH lo_exc_descr->class_name INTO lv_msg. log_message( ). WHEN log_process_save. ENDCASE. "" Ermögliche Speichern des Fehlerlogs save_error = abap_true. "" Log für Fehlerbehandlung speichern save_log( ). "" Fehlerhandling kann jetzt wieder aufgerufen werden has_error = abap_false. save_error = abap_false. ENDMETHOD. METHOD get_instance. IF log_stack IS INITIAL. "" Please initialize a log instance by calling method INIT first. RAISE EXCEPTION TYPE zcx_log_instance_missing. ENDIF. IF log_stack IS INITIAL. IF instance IS NOT BOUND. instance = NEW zxxx_cl_bs_log( ). APPEND instance TO log_stack. ENDIF. ELSE. instance = log_stack[ lines( log_stack ) ]. ENDIF. ro_instance = instance. ENDMETHOD. METHOD get_protocol. IF instance IS NOT BOUND. "" Please initialize a log instance by calling method INIT first. RAISE EXCEPTION TYPE zcx_log_instance_missing. ENDIF. rt_protocol = log_protocol. ENDMETHOD. METHOD info. message_type = log_type_info. CALL METHOD create_message EXPORTING msgtx = msgtx msgno = msgno msgv1 = msgv1 msgv2 = msgv2 msgv3 = msgv3 msgv4 = msgv4 msgde = msgde. ENDMETHOD. METHOD init. instance = NEW zxxx_cl_bs_log( ). APPEND instance TO log_stack. GET TIME STAMP FIELD instance->process_start. instance->lgnum = iv_lgnum. instance->log_header-object = iv_object. instance->log_header-subobject = iv_subobject. instance->log_header-aluser = sy-uname. instance->log_header-aldate = sy-datum. instance->log_header-altime = sy-uzeit. instance->set_sap_log( io_sap_log ). CALL METHOD instance->build_extnumber EXPORTING extnumber = iv_extnumber extnumber_list = it_extnumber_list CHANGING log_header = instance->log_header. CALL METHOD instance->build_validity CHANGING log_header = instance->log_header. CALL FUNCTION 'BAL_LOG_CREATE' EXPORTING i_s_log = instance->log_header IMPORTING e_log_handle = instance->log_handle EXCEPTIONS log_header_inconsistent = 1 OTHERS = 2. IF sy-subrc <> 0 AND has_error EQ abap_false. CALL METHOD instance->error_handling EXPORTING iv_process = log_process_init iv_subrc = sy-subrc. ENDIF. CLEAR: instance->caller. CALL METHOD instance->det_caller. CALL METHOD instance->log_caller. ro_instance = instance. ENDMETHOD. METHOD set_sap_log. IF io_log IS BOUND. sap_log = io_log. ELSE. CLEAR: sap_log. ENDIF. ENDMETHOD. METHOD log_api_message. io_api_message->get_messages( IMPORTING et_bapiret = DATA(lt_bapiret) ). log_bapiret( lt_bapiret ). ENDMETHOD. METHOD log_bapiret. DATA: lv_msg_txt TYPE c LENGTH 200. FIELD-SYMBOLS: TYPE bapiret2. "" Fehler loggen LOOP AT it_bapiret ASSIGNING . CLEAR lv_msg_txt. lv_msg_txt = -message. CASE -type. WHEN log_type_error. CALL METHOD error EXPORTING msgtx = lv_msg_txt. WHEN log_type_warning. CALL METHOD warning EXPORTING msgtx = lv_msg_txt. WHEN log_type_success. CALL METHOD success EXPORTING msgtx = lv_msg_txt. WHEN log_type_info. CALL METHOD info EXPORTING msgtx = lv_msg_txt. ENDCASE. ENDLOOP. ENDMETHOD. METHOD log_caller. DATA: lv_function TYPE dbglevent, lv_method TYPE dbglevent, lv_class TYPE dbgsrepid, lv_report TYPE dbgsrepid, lv_msg_txt TYPE c LENGTH 200. "" Returns one of the following return codes: "" 0 - Everything's fine "" 1 - Log could not be found "" 2 - Message is inconsistent "" 3 - Log is full "" 4 - Other messages (not specified by SAP) "" 5 - Message text is empty det_caller( ). message_type = log_type_success. lv_msg_txt = |***** { caller } at { add_timestamp( ) } *****|. CALL METHOD create_message EXPORTING msgtx = lv_msg_txt. ENDMETHOD. METHOD log_dm_message. IF io_dm_message IS BOUND. DATA(lt_dm_message) = io_dm_message->get_messages( ). ELSEIF it_dm_message IS NOT INITIAL. lt_dm_message = it_dm_message. ELSE. RETURN. ENDIF. LOOP AT lt_dm_message ASSIGNING FIELD-SYMBOL(). log_sy_message( is_symsg = CORRESPONDING #( ) ). ENDLOOP. ENDMETHOD. METHOD log_duration. IF process_end IS NOT INITIAL AND process_start IS NOT INITIAL. TRY. DATA(lv_duration) = cl_abap_tstmp=>subtract( tstmp1 = process_end tstmp2 = process_start ) * 1000. message_type = log_type_success. CALL METHOD create_message EXPORTING msgtx = |Process runtime: { lv_duration } ms|. CATCH cx_root. ENDTRY. ENDIF. ENDMETHOD. METHOD log_exception. message_type = log_type_error. "" OTR-Text zu der Ausnahmeklasse ermitteln CALL METHOD io_exception->get_text RECEIVING result = message_text. "" Name der Ausnahmeklasse ermitteln DATA(lo_exc_descr) = NEW cl_instance_description( io_exception ). CLEAR: message_params. message_params-altext = 'SBAL_EXCEPTION_01'. APPEND VALUE #( parname = 'EXCEPTION' parvalue = lo_exc_descr->class_name ) TO message_params-t_par. CALL METHOD create_message EXPORTING msgtx = message_text msgno = message_number msgv1 = message_var1 msgv2 = message_var2 msgv3 = message_var3 msgv4 = message_var4. ENDMETHOD. METHOD log_line. message_type = log_type_success. CALL METHOD create_message EXPORTING msgtx = repeat( val = '-' occ = 255 ). ENDMETHOD. METHOD log_message. message_class = sy-msgid. message_type = sy-msgty. CALL METHOD create_message EXPORTING msgno = sy-msgno msgv1 = sy-msgv1 msgv2 = sy-msgv2 msgv3 = sy-msgv3 msgv4 = sy-msgv4 msgde = msgde. ENDMETHOD. METHOD log_saplog. CHECK io_log IS BOUND. CALL METHOD io_log->get_prot RECEIVING et_protocol = DATA(lt_protocol). CALL METHOD log_bapiret EXPORTING it_bapiret = lt_protocol. ENDMETHOD. METHOD log_sy_message. message_class = is_symsg-msgid. CASE is_symsg-msgty. WHEN log_type_info. info( msgno = is_symsg-msgno msgv1 = is_symsg-msgv1 msgv2 = is_symsg-msgv2 msgv3 = is_symsg-msgv3 msgv4 = is_symsg-msgv4 ). WHEN log_type_success. success( msgno = is_symsg-msgno msgv1 = is_symsg-msgv1 msgv2 = is_symsg-msgv2 msgv3 = is_symsg-msgv3 msgv4 = is_symsg-msgv4 ). WHEN log_type_warning. warning( msgno = is_symsg-msgno msgv1 = is_symsg-msgv1 msgv2 = is_symsg-msgv2 msgv3 = is_symsg-msgv3 msgv4 = is_symsg-msgv4 ). WHEN log_type_error. error( msgno = is_symsg-msgno msgv1 = is_symsg-msgv1 msgv2 = is_symsg-msgv2 msgv3 = is_symsg-msgv3 msgv4 = is_symsg-msgv4 ). ENDCASE. ENDMETHOD. METHOD save. IF ( has_error EQ abap_false OR save_error EQ abap_true ) AND log_counter > 0. IF iv_finalize_log EQ abap_true. GET TIME STAMP FIELD process_end. CALL METHOD log_duration( ). CALL METHOD log_line( ). ENDIF. save_log( ). ELSE. CALL FUNCTION 'BAL_LOG_DELETE' EXPORTING i_log_handle = log_handle EXCEPTIONS log_not_found = 1 OTHERS = 2. ENDIF. IF iv_finalize_log EQ abap_true. DELETE TABLE log_stack FROM instance. CLEAR: instance, log_header, log_handle. ENDIF. ENDMETHOD. METHOD save_log. DATA(lt_log_handles) = VALUE bal_t_logh( ( log_handle ) ). DATA(lt_new_lognumbers) = VALUE bal_t_lgnm( ). CALL FUNCTION 'BAL_DB_SAVE' EXPORTING i_t_log_handle = lt_log_handles i_save_all = abap_false i_2th_connection = abap_true i_2th_connect_commit = abap_true IMPORTING e_new_lognumbers = lt_new_lognumbers EXCEPTIONS log_not_found = 1 save_not_allowed = 2 numbering_error = 3 OTHERS = 4. CASE sy-subrc. WHEN 0. save_message_detail( lt_new_lognumbers ). WHEN OTHERS. CALL FUNCTION 'BAL_LOG_DELETE' EXPORTING i_log_handle = log_handle EXCEPTIONS log_not_found = 1 OTHERS = 2. CLEAR: log_header, log_handle. CALL METHOD error_handling EXPORTING iv_process = log_process_save iv_subrc = sy-subrc. ENDCASE. ENDMETHOD. METHOD save_message_detail. CHECK it_new_lognumbers IS NOT INITIAL. ASSIGN it_new_lognumbers[ lines( it_new_lognumbers ) ] TO FIELD-SYMBOL(). IF message_detail IS NOT INITIAL AND IS ASSIGNED. CALL FUNCTION '/SCWM/DLV_EXPORT_LOG' EXPORTING iv_lognumber = -lognumber it_msg_details = message_detail. CLEAR: message_detail. ENDIF. ENDMETHOD. METHOD set_content. DATA: lv_msg_var TYPE string. IF msgtx IS NOT INITIAL. message_text = msgtx. DO 4 TIMES. CLEAR: lv_msg_var. CASE sy-index. WHEN 1. lv_msg_var = msgv1. WHEN 2. lv_msg_var = msgv2. WHEN 3. lv_msg_var = msgv3. WHEN 4. lv_msg_var = msgv4. ENDCASE. IF lv_msg_var IS NOT INITIAL. REPLACE FIRST OCCURRENCE OF '&' IN message_text WITH lv_msg_var. ELSE. EXIT. ENDIF. ENDDO. content_type = 1. ELSEIF msgno CN ' _'. message_number = msgno. message_var1 = CONV #( msgv1 ). message_var2 = CONV #( msgv2 ). message_var3 = CONV #( msgv3 ). message_var4 = CONV #( msgv4 ). content_type = 2. ELSE. RETURN. ENDIF. ENDMETHOD. METHOD set_context. zxxx_cl_bs_session=>get_context( IMPORTING ev_program = DATA(lv_program) ev_blockname = DATA(lv_include) ev_line = DATA(lv_line) ). DATA(ls_log_context) = VALUE zxxx_s_log_context( program = lv_program include = lv_include line = lv_line ). message_context-value = ls_log_context. message_context-tabname = 'ZXXX_S_LOG_CONTEXT'. ENDMETHOD. METHOD set_priority. CASE message_type. WHEN log_type_info. message_priority = '4'. "" Zusatzinformationen WHEN log_type_success. message_priority = '3'. "" Mittel WHEN log_type_warning. message_priority = '2'. "" Wichtig WHEN log_type_error. message_priority = '1'. "" Sehr wichtig ENDCASE. ENDMETHOD. METHOD success. message_type = log_type_success. CALL METHOD create_message EXPORTING msgtx = msgtx msgno = msgno msgv1 = msgv1 msgv2 = msgv2 msgv3 = msgv3 msgv4 = msgv4 msgde = msgde. ENDMETHOD. METHOD to_msgde. DATA: lo_struct_descr TYPE REF TO cl_abap_structdescr, lo_table_descr TYPE REF TO cl_abap_tabledescr. IF is_msgde IS NOT INITIAL. APPEND is_msgde TO rt_msgde. ELSEIF is_data IS NOT INITIAL. lo_struct_descr ?= cl_abap_typedescr=>describe_by_data( is_data ). LOOP AT lo_struct_descr->get_components( ) ASSIGNING FIELD-SYMBOL(). ASSIGN COMPONENT -name OF STRUCTURE is_data TO FIELD-SYMBOL(). CHECK IS ASSIGNED. APPEND VALUE #( fnam = -name low = ) TO rt_msgde. ENDLOOP. ELSEIF it_data IS NOT INITIAL. lo_table_descr ?= cl_abap_typedescr=>describe_by_data( it_data ). DATA(lo_data_descr) = lo_table_descr->get_table_line_type( ). LOOP AT it_data ASSIGNING FIELD-SYMBOL(). CASE lo_data_descr->kind. WHEN cl_abap_typedescr=>kind_elem. APPEND VALUE #( fnam = iv_fnam low = ) TO rt_msgde. WHEN cl_abap_typedescr=>kind_struct. lo_struct_descr ?= lo_data_descr. LOOP AT lo_struct_descr->get_components( ) ASSIGNING . ASSIGN COMPONENT -name OF STRUCTURE TO . CHECK IS ASSIGNED. APPEND VALUE #( fnam = -name low = ) TO rt_msgde. ENDLOOP. WHEN OTHERS. EXIT. ENDCASE. ENDLOOP. ELSE. RETURN. ENDIF. ENDMETHOD. METHOD warning. message_type = log_type_warning. CALL METHOD create_message EXPORTING msgtx = msgtx msgno = msgno msgv1 = msgv1 msgv2 = msgv2 msgv3 = msgv3 msgv4 = msgv4 msgde = msgde. ENDMETHOD. ENDCLASS. ",8448,False,1748.7196908996639,median "/* Feathers Copyright 2012-2015 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 left to right * in multiple rows. Constrained to the suggested width, the tiled rows * layout will change in height as the number of items increases or * decreases. * * @see ../../../help/tiled-rows-layout.html How to use TiledRowsLayout with Feathers containers */ public class TiledRowsLayout 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 rows without gaps. * * @see #paging */ public static const PAGING_NONE:String = ""none""; /** * Constructor. */ public function TiledRowsLayout() { } /** * @private */ protected var _discoveredItemsCache:Vector. = new []; /** * Quickly sets both horizontalGap and verticalGap * to the same value. The gap getter always returns the * value of horizontalGap, but the value of * verticalGap may be different. * * @default 0 * * @see #horizontalGap * @see #verticalGap */ public function get gap():Number { return this._horizontalGap; } /** * @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 _requestedColumnCount:int = 0; /** * Requests that the layout uses a specific number of columns in a row, * if possible. Set to 0 to calculate the maximum of * columns that will fit in the available space. * *

If the view port's explicit or maximum width is not large enough * to fit the requested number of columns, it will use fewer. If the * view port doesn't have an explicit width and the maximum width is * equal to Number.POSITIVE_INFINITY, the width will be * calculated automatically to fit the exact number of requested * columns.

* *

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 _requestedRowCount:int = 0; /** * Requests that the layout uses a specific number of rows, 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 _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 TiledRowsLayout.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 TiledRowsLayout.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 TiledRowsLayout.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 TiledRowsLayout.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 height of the rows is larger than the height * of the view port, the layout will be split into pages where each * page is filled with the maximum number of rows that may be displayed * without cutting off any items. * * @default TiledRowsLayout.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; this.dispatchEventWith(Event.CHANGE); } /** * @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 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 if(this._requestedColumnCount > 0) { horizontalTileCount = this._requestedColumnCount; availableWidth = this._paddingLeft + this._paddingRight + ((tileWidth + this._horizontalGap) * horizontalTileCount) - this._horizontalGap; } else { //put everything in one row horizontalTileCount = itemCount; } 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 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 { //using the horizontal tile count, calculate how many rows will //be required for the total number of items. verticalTileCount = Math.ceil(itemCount / horizontalTileCount); } 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 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 pageStartX:Number = startX; 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 && itemIndex % horizontalTileCount == 0) { positionX = pageStartX; positionY += tileHeight + this._verticalGap; } 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 = pageStartX = startX + availableWidth * pageIndex; positionY = startY; } else if(this._paging == PAGING_VERTICAL) { positionY = 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++; } } positionX += tileWidth + this._horizontalGap; 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 ? (discoveredItems.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 = totalPageWidth; if(availableWidth === availableWidth && //!isNaN this._paging == PAGING_HORIZONTAL) { totalWidth = Math.ceil(itemCount / perPage) * availableWidth; } var totalHeight:Number = positionY + tileHeight + this._paddingBottom; if(availableHeight === availableHeight) //!isNaN { if(this._paging == PAGING_HORIZONTAL) { totalHeight = availableHeight; } else if(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; 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 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 if(this._requestedColumnCount > 0) { horizontalTileCount = this._requestedColumnCount; availableWidth = this._paddingLeft + this._paddingRight + ((tileWidth + this._horizontalGap) * horizontalTileCount) - this._horizontalGap; } else { horizontalTileCount = itemCount; } 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 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 = Math.ceil(itemCount / horizontalTileCount); } 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 totalPageWidth:Number = horizontalTileCount * (tileWidth + this._horizontalGap) - this._horizontalGap + this._paddingLeft + this._paddingRight; 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 pageStartX:Number = startX; var positionX:Number = startX; var positionY:Number = startY; for(var i:int = 0; i < itemCount; i++) { if(i != 0 && i % horizontalTileCount == 0) { positionX = pageStartX; positionY += tileHeight + this._verticalGap; } 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 = pageStartX = startX + availableWidth * pageIndex; positionY = startY; } else if(this._paging == PAGING_VERTICAL) { positionY = startY + availableHeight * pageIndex; } } } var totalWidth:Number = totalPageWidth; if(availableWidth === availableWidth && //!isNaN this._paging == PAGING_HORIZONTAL) { totalWidth = Math.ceil(itemCount / perPage) * availableWidth; } var totalHeight:Number = positionY + tileHeight + this._paddingBottom; if(availableHeight === availableHeight) //!isNaN { if(this._paging == PAGING_HORIZONTAL) { totalHeight = availableHeight; } else if(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; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } 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 += -perPage + horizontalTileCount + columnOffset; } else if(partialPageSize > 0) { partialPageSize = partialPageSize - this._paddingLeft - leftSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } columnOffset = Math.floor(partialPageSize / (tileWidth + this._horizontalGap)); minimum += columnOffset; } if(minimum < 0) { minimum = 0; columnOffset = 0; } if(minimum + minimumItemCount >= itemCount) { var resultPushIndex:int = result.length; //an optimized path when we're on or near the last page minimum = itemCount - minimumItemCount; for(var i:int = minimum; i < itemCount; i++) { result[resultPushIndex] = i; resultPushIndex++; } } else { var rowIndex:int = 0; var columnIndex:int = (horizontalTileCount + columnOffset) % horizontalTileCount; var pageStart:int = int(minimum / perPage) * perPage; i = minimum; var resultLength:int = 0; do { if(i < itemCount) { result[resultLength] = i; resultLength++; } rowIndex++; if(rowIndex == verticalTileCount) { rowIndex = 0; columnIndex++; if(columnIndex == horizontalTileCount) { columnIndex = 0; pageStart += perPage; } i = pageStart + columnIndex - horizontalTileCount; } i += horizontalTileCount; } while(resultLength < minimumItemCount && pageStart < itemCount) } } /** * @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; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } var perPage:int = horizontalTileCount * verticalTileCount; var minimumItemCount:int = perPage + 2 * horizontalTileCount; 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._verticalAlign == VERTICAL_ALIGN_MIDDLE) { topSideOffset = bottomSideOffset = Math.round((height - this._paddingTop - this._paddingBottom - totalColumnHeight) / 2); } else if(this._verticalAlign == 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 / (tileHeight + this._verticalGap)) - 1; minimum += horizontalTileCount * rowOffset; } else if(partialPageSize > 0) { partialPageSize = partialPageSize - this._paddingTop - topSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } rowOffset = Math.floor(partialPageSize / (tileHeight + this._verticalGap)); minimum += horizontalTileCount * rowOffset; } if(minimum < 0) { minimum = 0; rowOffset = 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 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 horizontalTileCount:int = (width - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); if(horizontalTileCount < 1) { horizontalTileCount = 1; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } var verticalTileCount:int = Math.ceil((height + this._verticalGap) / (tileHeight + this._verticalGap)) + 1; var minimumItemCount:int = verticalTileCount * horizontalTileCount; if(minimumItemCount > itemCount) { minimumItemCount = itemCount; } var rowIndexOffset:int = 0; var totalRowHeight:Number = Math.ceil(itemCount / horizontalTileCount) * (tileHeight + this._verticalGap) - this._verticalGap; if(totalRowHeight < height) { if(this._verticalAlign == VERTICAL_ALIGN_BOTTOM) { rowIndexOffset = Math.ceil((height - totalRowHeight) / (tileHeight + this._verticalGap)); } else if(this._verticalAlign == VERTICAL_ALIGN_MIDDLE) { rowIndexOffset = Math.ceil((height - totalRowHeight) / (tileHeight + this._verticalGap) / 2); } } var rowIndex:int = -rowIndexOffset + Math.floor((scrollY - this._paddingTop + this._verticalGap) / (tileHeight + this._verticalGap)); var minimum:int = rowIndex * horizontalTileCount; 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(); } } /** * @inheritDoc */ public 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 horizontalTileCount:int = (width - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); if(horizontalTileCount < 1) { horizontalTileCount = 1; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } if(this._paging != PAGING_NONE) { var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 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 resultY:Number = this._paddingTop + ((tileHeight + this._verticalGap) * int(index / horizontalTileCount)); if(nearest) { var bottomPosition:Number = resultY - (height - tileHeight); if(scrollY >= bottomPosition && scrollY <= resultY) { //keep the current scroll position because the item is already //fully visible resultY = scrollY; } else { var topDifference:Number = Math.abs(resultY - scrollY); var bottomDifference:Number = Math.abs(bottomPosition - scrollY); if(bottomDifference < topDifference) { resultY = bottomPosition; } } } else { resultY -= Math.round((height - tileHeight) / 2); } result.x = 0; result.y = resultY; } return result; } } } ",16375,True,2973.0728458530716,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 check_prog_changed_since IMPORTING iv_program TYPE programm iv_timestamp TYPE timestamp iv_skip_gui TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rv_changed) TYPE abap_bool. 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, 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: condense_flow EXPORTING et_spaces TYPE ty_spaces_tt CHANGING ct_flow TYPE swydyflow, 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 zcl_abapgit_objects_program=>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) FIELD-SYMBOLS: TYPE rsmpe_pfk, TYPE rsmpe_act, TYPE rsmpe_men. IF cs_adm IS NOT INITIAL. RETURN. ENDIF. LOOP AT is_cua-act ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO '0123456789'. cs_adm-actcode = -code. ENDIF. ENDLOOP. LOOP AT is_cua-men ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO '0123456789'. cs_adm-mencode = -code. ENDIF. ENDLOOP. LOOP AT is_cua-pfk ASSIGNING . IF -code+6(14) IS INITIAL AND -code(6) CO '0123456789'. cs_adm-pfkcode = -code. ENDIF. ENDLOOP. ENDMETHOD. METHOD check_prog_changed_since. DATA: lv_date TYPE dats, lv_time TYPE tims, lt_screens TYPE STANDARD TABLE OF d020s, lt_eudb TYPE STANDARD TABLE OF eudb. FIELD-SYMBOLS: LIKE LINE OF lt_screens, LIKE LINE OF lt_eudb. SELECT SINGLE udat utime FROM reposrc "" Program INTO (lv_date, lv_time) WHERE progname = iv_program AND r3state = 'A'. rv_changed = check_timestamp( iv_timestamp = iv_timestamp iv_date = lv_date iv_time = lv_time ). IF rv_changed = abap_true. RETURN. ENDIF. SELECT SINGLE udat utime FROM repotext "" Program text pool INTO (lv_date, lv_time) WHERE progname = iv_program AND r3state = 'A'. IF sy-subrc = 0. "" Text not found ? Assuming no changes, see #404 rv_changed = check_timestamp( iv_timestamp = iv_timestamp iv_date = lv_date iv_time = lv_time ). IF rv_changed = abap_true. RETURN. ENDIF. ENDIF. IF iv_skip_gui = abap_true. RETURN. ENDIF. SELECT dgen tgen FROM d020s "" Screens INTO CORRESPONDING FIELDS OF TABLE lt_screens WHERE prog = iv_program ORDER BY PRIMARY KEY ##TOO_MANY_ITAB_FIELDS. ""#EC CI_SUBRC LOOP AT lt_screens ASSIGNING . rv_changed = check_timestamp( iv_timestamp = iv_timestamp iv_date = -dgen iv_time = -tgen ). IF rv_changed = abap_true. RETURN. ENDIF. ENDLOOP. SELECT vdatum vzeit FROM eudb "" GUI INTO CORRESPONDING FIELDS OF TABLE lt_eudb WHERE relid = 'CU' AND name = iv_program AND srtf2 = 0 ORDER BY PRIMARY KEY ##TOO_MANY_ITAB_FIELDS. ""#EC CI_SUBRC LOOP AT lt_eudb ASSIGNING . rv_changed = check_timestamp( iv_timestamp = iv_timestamp iv_date = -vdatum iv_time = -vzeit ). IF rv_changed = abap_true. RETURN. ENDIF. ENDLOOP. ENDMETHOD. METHOD condense_flow. DATA: lv_spaces LIKE LINE OF et_spaces. FIELD-SYMBOLS: LIKE LINE OF ct_flow. CLEAR et_spaces. LOOP AT ct_flow ASSIGNING . lv_spaces = 0. WHILE NOT -line IS INITIAL AND -line(1) = space. lv_spaces = lv_spaces + 1. -line = -line+1. ENDWHILE. APPEND lv_spaces TO et_spaces. 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' ). ENDIF. zcl_abapgit_objects_activation=>add( iv_type = 'CUAD' iv_name = iv_program_name ). ENDMETHOD. METHOD deserialize_dynpros. DATA: lv_name TYPE dwinactiv-obj_name, ls_dynpro LIKE LINE OF it_dynpros. * 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. ls_dynpro-flow_logic = uncondense_flow( it_flow = ls_dynpro-flow_logic it_spaces = ls_dynpro-spaces ). 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( |error from RPY_DYNPRO_INSERT: { sy-subrc }| ). 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 = 'INSERT' EXCEPTIONS cancelled = 1 permission_failure = 2 unknown_objectclass = 3 OTHERS = 4. IF sy-subrc = 1. zcx_abapgit_exception=>raise( 'Cancelled' ). ELSEIF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from RS_CORR_INSERT' ). 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' ). ELSE. zcx_abapgit_exception=>raise( 'PROG, error updating' ). 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' ). 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. 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' ). 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 iv_program ""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 zcl_abapgit_objects_program=>ty_dynpro_tt, lv_object TYPE seqg3-garg. FIELD-SYMBOLS: TYPE zcl_abapgit_objects_program=>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. 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. CONSTANTS lc_rpyty_force_off TYPE char01 VALUE '/' ##NO_TEXT. 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. 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. 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 screen_list' ). 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. 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. * 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. 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. condense_flow( IMPORTING et_spaces = -spaces CHANGING ct_flow = lt_flow_logic ). -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_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' ). 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. ",8052,False,1635.0102105167582,median "*/--------------------------------------------------------------------------------\\ *| This file is part of Mockup loader | *| | *| The MIT License (MIT) | *| | *| Copyright (c) 2015 SBCG Team (www.sbcg.com.ua), Alexander Tsybulsky | *| | *| 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. | *\\--------------------------------------------------------------------------------/ *| project homepage: https://github.com/sbcgua/mockup_loader | *\\--------------------------------------------------------------------------------/ ********************************************************************** * MACRO ********************************************************************** define test_parse. clear dummy. read table lo_struc_descr->components into ls_component with key name = '&1'. o->parse_field( exporting is_component = ls_component i_data = &2 importing e_field = dummy-&1 ). end-of-definition. define test_parse_positive. clear lo_ex. try. test_parse &1 &2. catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = dummy-&1 exp = &3 msg = 'Parse field positive:' && &2 ). end-of-definition. define test_parse_negative. clear lo_ex. try. test_parse &1 &2. catch zcx_mockup_loader_error into lo_ex. endtry. cl_abap_unit_assert=>assert_not_initial( act = lo_ex msg = 'Parse field negative:' && &2 ). cl_abap_unit_assert=>assert_equals( exp = &3 act = lo_ex->code ). 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. endif. append e_dummy_struc to e_dummy_tab. end-of-definition. 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. ********************************************************************** * DEPENDENCIES CHECK ********************************************************************** class ltcl_dependencies_version definition final for testing duration short risk level harmless. private section. methods check_text2tab_version for testing. endclass. class ltcl_dependencies_version implementation. method check_text2tab_version. constants lc_required_ver type string value zif_mockup_loader=>c_required_text2tab_ver. if abap_false = zcl_text2tab_parser=>check_version_fits( lc_required_ver ). cl_abap_unit_assert=>fail( |data parser version ({ zif_text2tab_constants=>version }) is lower than required ({ lc_required_ver })| ). ""#EC NOTEXT endif. endmethod. endclass. ********************************************************************** * Test Class definition ********************************************************************** class ltcl_test_mockup_loader definition for testing duration short risk level harmless. public section. types: begin of ty_dummy, mandt type mandt, tdate type datum, tchar type c length 8, traw type thraw1, tstring type string, talpha type veri_alpha, tdecimal type dmbtr, tnumber type n length 4, tinteger type i, end of ty_dummy, tt_dummy type table of ty_dummy with default key. types: begin of ty_dummy_corresponding, tdate type datum, tchar type c length 8, _another type i, end of ty_dummy_corresponding, tt_dummy_corresponding type standard table of ty_dummy_corresponding with default key. types: begin of ty_deep_line, docid type i, lineid type i, text type string, end of ty_deep_line, tt_deep_line type standard table of ty_deep_line with key docid lineid, begin of ty_deep_head, docid type i, lines type tt_deep_line, first_line type ty_deep_line, end of ty_deep_head, tt_deep_head type standard table of ty_deep_head with key docid. 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. data o type ref to zcl_mockup_loader. ""class under test class-methods class_setup. methods setup. methods read_zip for testing. methods integrated_test for testing. methods source_redirect_test for testing. methods utf16_encoding for testing. methods parse_data for testing. methods load_blob for testing raising zcx_mockup_loader_error. methods load_data_to_ref for testing. methods load_deep for testing raising zcx_mockup_loader_error. methods load_deep_negative for testing. methods load_corresponding for testing raising zcx_mockup_loader_error. methods load_corresponding_w_filter for testing raising zcx_mockup_loader_error. methods load_w_renames for testing raising zcx_mockup_loader_error. methods assert_version for testing. 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_string type string. methods create_default returning value(r_o) type ref to zcl_mockup_loader raising zcx_mockup_loader_error. endclass. * Friends class zcl_mockup_loader definition local friends ltcl_test_mockup_loader. ********************************************************************** * Implementation ********************************************************************** class ltcl_test_mockup_loader implementation. ********************************************************************** * Setup methods ********************************************************************** method class_setup. data l_type_tmp type zif_mockup_loader=>ty_src_type. get parameter id 'ZMOCKUP_LOADER_STYPE' field l_type_tmp. if l_type_tmp is not initial. cl_abap_unit_assert=>fail( quit = 2 ""cancel-class msg = 'Load source is redirected,' && ' please reset with ZMOCKUP_LOADER_SWITCH_SOURCE before running the test' ). ""#EC NOTEXT endif. endmethod. method create_default. r_o = zcl_mockup_loader=>create( i_type = 'MIME' i_path = 'ZMOCKUP_LOADER_UNIT_TEST' i_amt_format = '' "" default i_encoding = zif_mockup_loader_constants=>encoding_utf8 ). "" utf8 endmethod. method setup. data lo_ex type ref to zcx_mockup_loader_error. try. o = create_default( ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. endmethod. ********************************************************************** * Dummy data generation ********************************************************************** method get_dummy_data. data l_string type string. if i_strict = abap_true. l_string = 'MANDT\\tTDATE\\tTCHAR\\tTRAW\\tTSTRING\\tTALPHA\\tTDECIMAL\\tTNUMBER\\tTINTEGER\\n' && '\\t01.01.2015\\tTrololo1\\t8A\\tString1\\t100000\\t1234567,81\\t2015\\t1111\\n' && '\\t02.01.2016\\tTrololo2\\t8B\\tString2\\t200000\\t1234567,82\\t2016\\t2222\\n' && '\\t03.01.2016\\tTrololo3\\t8C\\tString3\\t300000\\t1234567,83\\t2015\\t3333\\n' . 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' . 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 append_dummy '20150101' 'Trololo1' 'String1' '1234567.81' 2015 '8A' 1111 '0000100000'. append_dummy '20160102' 'Trololo2' 'String2' '1234567.82' 2016 '8B' 2222 '0000200000'. append_dummy '20160103' 'Trololo3' 'String3' '1234567.83' 2015 '8C' 3333 '0000300000'. read table e_dummy_tab into e_dummy_struc index 1. e_dummy_string = l_string. endmethod. ********************************************************************** * Simple integrated test - most basic usage of the class ********************************************************************** method integrated_test. data: dummy_act type ty_dummy, dummy_exp type ty_dummy, dummy_tab_act type tt_dummy, dummy_tab_exp type tt_dummy, lo_ex type ref to zcx_mockup_loader_error. get_dummy_data( importing e_dummy_struc = dummy_exp e_dummy_tab = dummy_tab_exp ). "" Strict ******************************************************** try. o->load_data( exporting i_obj = 'testdir/testfile_complete' i_strict = abap_true importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). o->load_data( exporting i_obj = 'testdir/testfile_complete' i_strict = abap_true importing e_container = dummy_act ). cl_abap_unit_assert=>assert_equals( act = dummy_act exp = dummy_exp ). o->load_data( "" No MANDT field in file exporting i_obj = 'testdir/testfile_no_mandt' i_strict = abap_true importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. "" NOT Strict **************************************************** get_dummy_data( exporting i_strict = abap_false importing e_dummy_tab = dummy_tab_exp ). try. o->load_data( exporting i_obj = 'testdir/testfile_no_strict' i_strict = abap_false importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. "" With where **************************************************** get_dummy_data( importing e_dummy_tab = dummy_tab_exp ). read table dummy_tab_exp into dummy_exp with key tnumber = '2016'. delete dummy_tab_exp where tnumber <> '2016'. try. o->load_data( exporting i_obj = 'testdir/testfile_complete' i_where = 'TNUMBER = 2016' importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). o->load_data( exporting i_obj = 'testdir/testfile_complete' i_where = 'TNUMBER = 2016' importing e_container = dummy_act ). cl_abap_unit_assert=>assert_equals( act = dummy_act exp = dummy_exp ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. "" No container *************************************************** try. o->load_data( i_obj = 'testdir/testfile_complete' ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'NC'. endmethod. ********************************************************************** * Source redirection via SET/GET parameters test ********************************************************************** method source_redirect_test. constants: lc_getset_type type memoryid value 'ZMOCKUP_LOADER_STYPE', lc_getset_mime type memoryid value 'ZMOCKUP_LOADER_SMIME', lc_getset_file type memoryid value 'ZMOCKUP_LOADER_SPATH'. data: lx_ut type ref to cx_aunit_fail, l_mime_bak type c length 40, l_file_bak type c length 40. data: lo_ex type ref to zcx_mockup_loader_error, l_type type zif_mockup_loader=>ty_src_type, l_path type c length 40. "" ""DANGEROUS"" TEST AS MODIFIES SET/GET PARAMS define _bak_params. get parameter id lc_getset_file field l_file_bak. get parameter id lc_getset_mime field l_mime_bak. end-of-definition. define _restore_params. clear l_type. set parameter id lc_getset_type field l_type. set parameter id lc_getset_file field l_file_bak. set parameter id lc_getset_mime field l_mime_bak. end-of-definition. cl_abap_unit_assert=>assert_false( o->zif_mockup_loader~is_redirected( ) ). "" MIME _bak_params. l_type = 'MIME'. set parameter id lc_getset_type field l_type. l_path = 'ZMOCKUP_LOADER_WRONG_OBJECT'. set parameter id lc_getset_mime field l_path. clear lo_ex. try. o = create_default( ). cl_abap_unit_assert=>assert_true( o->zif_mockup_loader~is_redirected( ) ). catch zcx_mockup_loader_error into lo_ex. endtry. _restore_params. assert_excode 'RE'. "" FILE _bak_params. l_type = 'FILE'. set parameter id lc_getset_type field l_type. l_path = 'ZMOCKUP_LOADER_WRONG_OBJECT'. set parameter id lc_getset_file field l_path. l_path = 'ZMOCKUP_LOADER_UNIT_TEST'. set parameter id lc_getset_mime field l_path. "" replace the mock which was in setup clear lo_ex. try. o = create_default( ). cl_abap_unit_assert=>assert_true( o->zif_mockup_loader~is_redirected( ) ). catch zcx_mockup_loader_error into lo_ex. endtry. _restore_params. assert_excode 'RE'. "" FILE, BUT FOR ANOTHER MIME _bak_params. l_type = 'FILE'. set parameter id lc_getset_type field l_type. l_path = 'ZMOCKUP_LOADER_WRONG_OBJECT'. set parameter id lc_getset_file field l_path. l_path = 'ZMOCKUP_LOADER_NOT_EXISTING'. set parameter id lc_getset_mime field l_path. "" replace the mock which was in setup clear lo_ex. try. o = create_default( ). cl_abap_unit_assert=>assert_false( o->zif_mockup_loader~is_redirected( ) ). catch zcx_mockup_loader_error into lo_ex. endtry. _restore_params. cl_abap_unit_assert=>assert_initial( lo_ex ). cl_abap_unit_assert=>assert_false( o->zif_mockup_loader~is_redirected( ) ). endmethod. ********************************************************************** * Check Unicode encoding parsing ********************************************************************** method utf16_encoding. data: dummy_tab_act type tt_dummy, dummy_tab_exp type tt_dummy, lo_ex type ref to zcx_mockup_loader_error. get_dummy_data( importing e_dummy_tab = dummy_tab_exp ). try. o->set_params( i_amt_format = '' i_encoding = zif_mockup_loader_constants=>encoding_utf16 ). "" UTF16 o->load_data( exporting i_obj = 'testdir/testfile_complete_utf16' importing e_container = dummy_tab_act ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). endmethod. ********************************************************************** * Test of data parser - dummy data is supplied to the tested method ********************************************************************** method parse_data. data: dummy_val type c length 40, 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, l_string type string, lo_ex type ref to zcx_mockup_loader_error. "" Strict parsing ********************************* get_dummy_data( importing e_dummy_struc = dummy_exp e_dummy_tab = dummy_tab_exp e_dummy_string = l_string ). try. o->parse_data( exporting i_rawdata = l_string i_strict = abap_true importing e_container = dummy_act ). o->parse_data( exporting i_rawdata = l_string i_strict = abap_true importing e_container = dummy_tab_act ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = dummy_act exp = dummy_exp ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). "" Parse to sorted and hashed tables *************** try. o->parse_data( exporting i_rawdata = l_string i_strict = abap_true importing e_container = dummy_stab ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = dummy_stab exp = dummy_tab_exp ). try. o->parse_data( exporting i_strict = abap_true i_rawdata = l_string importing e_container = dummy_htab ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = dummy_htab exp = dummy_tab_exp ). "" NOT STRICT parsing ****************************** get_dummy_data( exporting i_strict = abap_false importing e_dummy_tab = dummy_tab_exp e_dummy_string = l_string ). try. o->parse_data( exporting i_rawdata = l_string i_strict = abap_false importing e_container = dummy_tab_act ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). "" Catch parser errors, e.g. unknown field clear lo_ex. get_dummy_data( importing e_dummy_string = l_string ). replace first occurrence of 'TDATE' in l_string with 'UNKNOWN_FIELD'. try. o->parse_data( exporting i_rawdata = l_string i_strict = abap_true importing e_container = dummy_tab_act ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'XE'. "" Parse to field (not table or structure) ************* clear lo_ex. get_dummy_data( importing e_dummy_string = l_string ). try. o->parse_data( exporting i_rawdata = l_string i_strict = abap_true importing e_container = dummy_val ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'DT'. "" Parse empty file ************************************ clear lo_ex. clear l_string. try. o->parse_data( exporting i_rawdata = l_string i_strict = abap_true importing e_container = dummy_tab_act ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'XE'. "" parser error endmethod. ********************************************************************** * ZIP file read test - gets data from SMW0 ZMOCKUP_LOADER_UNIT_TEST ********************************************************************** method read_zip. data: l_str type string, lo_ex type ref to zcx_mockup_loader_error. cl_abap_unit_assert=>assert_not_initial( act = lines( o->mo_zip->files ) ). "" Positive *************************************** try. l_str = o->read_zip( i_name = 'testdir/testfile_complete.txt' ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. cl_abap_unit_assert=>assert_not_initial( act = l_str ). "" NEGATIVE - wrong file name ********************** clear lo_ex. try. l_str = o->read_zip( i_name = 'testdir/wrong_filename.xyz' ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'ZF'. "" NEGATIVE - wrong code page ********************** clear lo_ex. try. l_str = o->read_zip( i_name = 'testdir/testfile_complete_utf16.txt' ). catch zcx_mockup_loader_error into lo_ex. endtry. assert_excode 'CP'. endmethod. ********************************************************************** * LOAD_RAW - test load only method e.g. for XMLs ********************************************************************** method load_blob. data: lo_ex type ref to zcx_mockup_loader_error, l_str_exp type string, l_xstr_act type xstring, l_str_act type string, lo_conv type ref to cl_abap_conv_in_ce. l_str_exp = 'mydata'. "" .XML lo_conv = cl_abap_conv_in_ce=>create( encoding = zif_mockup_loader_constants=>encoding_utf8 ). l_xstr_act = o->load_blob( 'testdir/test_raw.xml' ). lo_conv->convert( exporting input = l_xstr_act importing data = l_str_act ). cl_abap_unit_assert=>assert_equals( act = l_str_act exp = l_str_exp ). "" .TXT l_xstr_act = o->load_blob( 'testdir/test_raw.txt' ). lo_conv->convert( exporting input = l_xstr_act importing data = l_str_act ). cl_abap_unit_assert=>assert_equals( act = l_str_act exp = l_str_exp ). "" Missing file try . o->load_blob( 'testdir/no-file-like-this' ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>assert_equals( act = lo_ex->code exp = 'ZF' ). endtry. "" Case insensitive path lo_conv = cl_abap_conv_in_ce=>create( encoding = zif_mockup_loader_constants=>encoding_utf8 ). l_xstr_act = o->load_blob( 'TESTDIR/test_raw.xml' ). lo_conv->convert( exporting input = l_xstr_act importing data = l_str_act ). cl_abap_unit_assert=>assert_equals( act = l_str_act exp = l_str_exp ). endmethod. method load_data_to_ref. data: dummy_tab_act type tt_dummy, dummy_tab_exp type tt_dummy, lo_ex type ref to zcx_mockup_loader_error. data lr_data type ref to data. create data lr_data type tt_dummy. field-symbols type tt_dummy. get_dummy_data( importing e_dummy_tab = dummy_tab_exp ). try. o->load_data( exporting i_obj = 'testdir/testfile_complete' importing e_container = lr_data ). assign lr_data->* to . cl_abap_unit_assert=>assert_equals( act = exp = dummy_tab_exp ). catch zcx_mockup_loader_error into lo_ex. cl_abap_unit_assert=>fail( lo_ex->get_text( ) ). endtry. endmethod. "" load_data_to_ref. method assert_version. data lx type ref to zcx_mockup_loader_error. try . zcl_mockup_loader=>assert_version( zif_mockup_loader=>version ). catch zcx_mockup_loader_error into lx. endtry. cl_abap_unit_assert=>assert_not_bound( lx ). try . zcl_mockup_loader=>assert_version( 'v999.999.999' ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_char_cp( act = lx->msg exp = '*loader version*' ). endtry. cl_abap_unit_assert=>assert_bound( lx ). endmethod. method load_deep. "" DATA data lt_docs_exp type tt_deep_head. field-symbols like line of lt_docs_exp. field-symbols like line of -lines. append initial line to lt_docs_exp assigning . -docid = 1. -first_line-docid = 1. -first_line-lineid = 1. -first_line-text = 'Hello'. append initial line to -lines assigning . -docid = 1. -lineid = 1. -text = 'Hello'. append initial line to -lines assigning . -docid = 1. -lineid = 2. -text = 'Mockup'. append initial line to lt_docs_exp assigning . -docid = 2. -first_line-docid = 2. -first_line-lineid = 1. -first_line-text = 'Loader'. append initial line to -lines assigning . -docid = 2. -lineid = 1. -text = 'Loader'. append initial line to lt_docs_exp assigning . -docid = 3. append initial line to lt_docs_exp assigning . -docid = 4. -first_line-docid = 99. -first_line-lineid = 1. -first_line-text = '!!!'. append initial line to -lines assigning . -docid = 99. -lineid = 1. -text = '!!!'. append initial line to lt_docs_exp assigning . -docid = 5. "" TEST data lt_docs_act like lt_docs_exp. o->load_data( exporting i_obj = 'testdir/deep_head' i_deep = abap_true importing e_container = lt_docs_act ). cl_abap_unit_assert=>assert_equals( act = lt_docs_act exp = lt_docs_exp ). endmethod. method load_deep_negative. data lt_docs_act type tt_deep_head. data lx type ref to zcx_mockup_loader_error. try . o->load_data( exporting i_obj = 'testdir/deep_head_with_wrong_path' i_deep = abap_true importing e_container = lt_docs_act ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'XE' ). endtry. try . o->load_data( exporting i_obj = 'testdir/deep_head_with_wrong_field' i_deep = abap_true importing e_container = lt_docs_act ). cl_abap_unit_assert=>fail( ). catch zcx_mockup_loader_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'XE' ). endtry. endmethod. method load_corresponding. data: dummy_tab_act type tt_dummy_corresponding, dummy_tab_exp type tt_dummy_corresponding, dummy_tab_exp_full type tt_dummy. field-symbols like line of dummy_tab_exp_full. field-symbols like line of dummy_tab_exp. get_dummy_data( importing e_dummy_tab = dummy_tab_exp_full ). loop at dummy_tab_exp_full assigning . append initial line to dummy_tab_exp assigning . move-corresponding to . endloop. o->load_data( exporting i_obj = 'testdir/testfile_complete' i_strict = abap_false i_corresponding = abap_true importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). delete dummy_tab_exp where tchar <> 'Trololo3'. clear dummy_tab_act. o->load_data( exporting i_obj = 'testdir/testfile_complete' i_strict = abap_false i_corresponding = abap_true i_where = 'tchar = Trololo3' importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). endmethod. method load_corresponding_w_filter. data: dummy_tab_act type tt_dummy_corresponding, dummy_tab_exp type tt_dummy_corresponding, dummy_tab_exp_full type tt_dummy. field-symbols like line of dummy_tab_exp_full. field-symbols like line of dummy_tab_exp. get_dummy_data( importing e_dummy_tab = dummy_tab_exp_full ). loop at dummy_tab_exp_full assigning . check -tnumber = '2015'. append initial line to dummy_tab_exp assigning . move-corresponding to . endloop. o->load_data( exporting i_obj = 'testdir/testfile_complete' i_strict = abap_false i_corresponding = abap_true i_where = 'tnumber = 2015' importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). data lt_filter type zif_mockup_loader=>tt_filter. data lt_range type range of ty_dummy-tnumber. "" Filter table field-symbols like line of lt_filter. append initial line to lt_filter assigning . -name = 'TNUMBER'. -type = 'R'. get reference of lt_range into -valref. field-symbols like line of lt_range. append initial line to lt_range assigning . -sign = 'I'. -option = 'EQ'. -low = '2015'. clear dummy_tab_act. o->load_data( exporting i_obj = 'testdir/testfile_complete' i_strict = abap_false i_corresponding = abap_true i_where = lt_filter importing e_container = dummy_tab_act ). cl_abap_unit_assert=>assert_equals( act = dummy_tab_act exp = dummy_tab_exp ). endmethod. method load_w_renames. types: begin of lty_dummy_w_renames, tdate type datum, ychar type c length 8, end of lty_dummy_w_renames. data: dummy_act type lty_dummy_w_renames, dummy_exp type lty_dummy_w_renames. o->load_data( exporting i_obj = 'testdir/testfile_complete' i_strict = abap_false i_rename_fields = 'tchar:ychar' i_corresponding = abap_true importing e_container = dummy_act ). dummy_exp-tdate = '20150101'. dummy_exp-ychar = 'Trololo1'. cl_abap_unit_assert=>assert_equals( act = dummy_act exp = dummy_exp ). endmethod. endclass. ",8017,False,1648.7191366512425,median "CLASS zcl_aff_test_types DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. TYPES: ""! $hiddenabc unknown_annotation TYPE string. TYPES: ""!

title

""! description ""!

Title

description_not_found TYPE string. TYPES: ""!

Type With Long Description

""! This is a type with a very very long description. ""! To ensure that the generated schema can be inserted into an include without loss of information, ""! the length of the description should not be longer then 253 characters. ""! So please shorten your description. Description should not replace a lexicon. type_with_long_description TYPE i. TYPES: ""! Default type does not match constant type ""! $default {@link zcl_aff_test_types.data:co_test.test} default_link TYPE i. CONSTANTS: BEGIN OF co_test, test TYPE string VALUE ' ', END OF co_test. TYPES: BEGIN OF struc_link_wrong_type, default_link TYPE default_link, END OF struc_link_wrong_type. TYPES: ""! in ST val(I()) only allow integers ""! $values {@link zcl_aff_test_types.data:co_enum} enum TYPE i. CONSTANTS: BEGIN OF co_enum, test TYPE string VALUE ' ', test2 TYPE string VALUE 'A', END OF co_enum. * type to test name mapping from format_version to formatVersion TYPES: ""!

Constant With Field Format Version

""! Constant with field format_version BEGIN OF ty_format_version, ""!

ABAP File Format Version

""! The ABAP file format version format_version TYPE string, ""!

Other Field

""! Other field field1 TYPE i, END OF ty_format_version. * numerical text field TYPES: ""!

Numerical Text Field

""! A numerical text field of length 4 num_text TYPE n LENGTH 4. TYPES: ""!

Structure With Numerical Text Field

""! Structure with a numerical text field of length 4 BEGIN OF struc_with_num_text, numerical_text1 TYPE num_text, numerical_text2 TYPE num_text, ""! $showAlways numerical_text3 TYPE num_text, numerical_text4 TYPE num_text, END OF struc_with_num_text. * numerical text field with title and description which need to be escaped in the json schema * "" needs to be escaped (/"") * \\ needs to be escaped (\\\\) TYPES: ""!

Test title ""\\

""! Test description ""\\ num_text1 TYPE n LENGTH 4. * integer TYPES: ""!

myInteger

""! A simple Integer integer TYPE i. * string TYPES: ""!

myStringName

""! This is a string ""! $maxLength 3 mystring TYPE string. * date TYPES: ""!

Date

""! This is a date my_date TYPE d. * simple structure TYPES: ""!

mySimpleStructure

""! This is a simple structure BEGIN OF my_structure, ""!

First Element

""! This is the first element ""! $minLength 4 my_first_element TYPE mystring, ""!

Second Element

""! This is the second element my_second_element TYPE i, END OF my_structure. * simple table: TYPES: ""!

A Standard Table

""! A standard table of myString my_standard_table TYPE STANDARD TABLE OF mystring WITH DEFAULT KEY. TYPES: ""!

A Hashed Table

""! A hashed table of my_structure my_hashed_table TYPE HASHED TABLE OF my_structure WITH UNIQUE KEY my_first_element. * structure with different table types TYPES: ""!

A Sorted Table

""! A sorted table of my_structure with unique key my_sorted_table_unique TYPE SORTED TABLE OF my_structure WITH UNIQUE KEY my_second_element. TYPES: ""!

A Sorted Table

""! A sorted table of my_structure with non unique key my_sorted_table_n_unique TYPE SORTED TABLE OF my_structure WITH NON-UNIQUE KEY my_second_element. TYPES: ""!

A Structure With Tables

""! A structure with different table types BEGIN OF my_structure_with_tables, ""!

First Table

""! First table first_table TYPE my_sorted_table_unique, ""!

Second Table

""! Second table second_table TYPE my_sorted_table_n_unique, END OF my_structure_with_tables. * simple structure TYPES: ""!

mySimpleStructure

""! This is a $ simple st$ructure BEGIN OF my_structure2, ""!

First Element

""! This is the first element ""! $required my_first_element TYPE mystring, ""!

Second Element

""! This is the second element my_second_element TYPE i, END OF my_structure2. * nested Structure TYPES: ""!

Nested Structure

""! This is a nested structure BEGIN OF my_nested_structure, ""!

myElementComponente

""! This is a string element my_element TYPE string, END OF my_nested_structure, ""!

myStructure

""! This is a complex structure BEGIN OF my_structure3, ""!

nestedStruc

""! This is the nested structure nested_struc TYPE my_nested_structure, ""!

My Element

""! This is my element ""! $required my_element TYPE string, END OF my_structure3. * type with enum values: TYPES: ""!

myCategory

""! This is an enum ""! $values { @link zcl_aff_test_types.data:enum_values } category TYPE n LENGTH 2. CONSTANTS: ""!

Interface Category

""! Interface category BEGIN OF enum_values, ""!

generalCategory

""! General interface general TYPE category VALUE '00', ""! Interface definition of a classic BAdI classic_badi TYPE category VALUE '01', END OF enum_values ##NEEDED. * type with enum values without initial: TYPES: ""!

Enum

""! This is an enum ""! $values { @link zcl_aff_test_types.data:enum_values_no_initial } category_no_initial TYPE n LENGTH 2. CONSTANTS: ""!

Interface Category

""! Interface category BEGIN OF enum_values_no_initial, ""!

Component 1

""! Component 1 component_1 TYPE category_no_initial VALUE '01', ""!

Component 2

""! Component 2 component_2 TYPE category_no_initial VALUE '02', END OF enum_values_no_initial ##NEEDED. TYPES: ""!

Structure with Different Enum Types

""! Structure with different enum types BEGIN OF structure_with_different_enum, enum_without_all TYPE category_no_initial, ""! $default {@link zcl_aff_test_types.data:enum_values_no_initial.component_2 } enum_with_default TYPE category_no_initial, ""! $required enum_with_required TYPE category_no_initial, END OF structure_with_different_enum. ""!

ABAP Language Version

""! ABAP language version ""! $values {@link zcl_aff_test_types.data:co_abap_language_version} TYPES language_version TYPE c LENGTH 1. CONSTANTS: ""!

ABAP Language Version

""! ABAP language version BEGIN OF co_abap_language_version, ""!

Standard

""! Standard standard TYPE language_version VALUE ' ', ""!

ABAP Cloud Development

""! ABAP cloud development cloud_development TYPE language_version VALUE '5', END OF co_abap_language_version. TYPES: ""!

Header

""! The header for an ABAP main object BEGIN OF header, ""!

Description

""! Description of the ABAP object description TYPE string, ""!

Original Language

""! Original language of the ABAP object original_language TYPE sy-langu, ""!

ABAP Language Version

""! ABAP language version abap_language_version TYPE language_version, END OF header. * complex structure with enum_values TYPES: ""!

Class Properties

""! Class properties BEGIN OF ty_class_properties, header TYPE header, ""!

Class Category

""! Class category ""! $values {@link zcl_aff_test_types.data:co_class_category} class_category TYPE n LENGTH 2, END OF ty_class_properties. CONSTANTS: ""!

Class Category

""! Class category BEGIN OF co_class_category, ""!

General

""! General general TYPE n LENGTH 2 VALUE '00', ""!

Exit Class

""! Exit class exit_class TYPE n LENGTH 2 VALUE '01', END OF co_class_category. * deep nested structure TYPES: ""!

outerStructure

""! ABAP Doc Comment TYPES list first level BEGIN OF list, ""!

Outer Element 1

""! ABAP Doc field1 ""! $showAlways field1 TYPE i, ""!

Outer Element 2

""! ABAP Doc field2 ""! $required field2 TYPE c LENGTH 2, ""!

middleStructure

""! ABAP Doc list second level ""! $required BEGIN OF list1, ""!

Middle Element

""! ABAP Doc second level ""! $required element_of_list1 TYPE i, ""!

innerStructure

""! ABAP Doc third level BEGIN OF list2, ""!

Inner Element

""! ABAP Doc third level ""! $required element_of_list2 TYPE string, END OF list2, END OF list1, ""!

Outer Element 3

""! ABAP Doc field3 ""! $required field3 TYPE c LENGTH 2, END OF list. * nested structure with table TYPES: ""!

outerStructure

""! ABAP Doc Comment TYPES list first level BEGIN OF outer_struc, ""!

Outer Element 1

""! ABAP Doc field1 first level field1 TYPE i, ""!

Inner Structure 1

""! Inner structure BEGIN OF inner_struc, ""!

Inner Element

""! ABAP Doc element second level ""! $required element_of_inner_struc TYPE i, ""!

inner Table

""! ABAP Doc element second level ""! $required inner_table_var TYPE STANDARD TABLE OF string WITH NON-UNIQUE DEFAULT KEY, END OF inner_struc, ""!

Outer Element 2

""! ABAP Doc field2 first level ""! $required field2 TYPE c LENGTH 2, END OF outer_struc. * nested structure with table and enum value TYPES: ""!

Title of aff_test_type

""! Description of aff_test_type BEGIN OF aff_test_type, ""!

Title of Field1

""! Description of field1 field1 TYPE i, ""!

Title of inner_struc

""! Description of inner_struc ""! $showAlways BEGIN OF inner_struc, ""!

Title of inner_element

""! Description of inner_element ""! $required inner_element TYPE i, ""!

Title of inner_table

""! Description of inner_table inner_table TYPE STANDARD TABLE OF string WITH NON-UNIQUE DEFAULT KEY, END OF inner_struc, ""!

Title of field2

""! Description of field2 ""! $required field2 TYPE c LENGTH 2, ""!

Title of field_with_values

""! Description of field_with_values ""! $values {@link zcl_aff_test_types.data:co_class_category} field_with_values TYPE n LENGTH 2, END OF aff_test_type. * nested table TYPES: ""!

Inner Table

""! This is the inner Table nested_table TYPE STANDARD TABLE OF string WITH DEFAULT KEY, ""!

Outer Table

""! This is the outer table first_table TYPE STANDARD TABLE OF nested_table WITH DEFAULT KEY. * type with enum values, but wrong link: TYPES: ""!

myCategory

""! This is an enum ""! $values { @link zcl_aff_test_types.data:enum_values_wrong } category_wrong TYPE n LENGTH 2. * structure with component to wrong enum_values link TYPES: ""!

Structure with Wrong Link

""! This is a structure with wrong enum_values link BEGIN OF structure_with_wrong_link, ""!

First Element

""! First element element_one TYPE string, ""!

Second Element

""! Second element element_two TYPE category_wrong, END OF structure_with_wrong_link. * structure with enum value whose link can be found outside TYPES: ""!

String Table

""! Abap Doc of the table string_table TYPE STANDARD TABLE OF string WITH DEFAULT KEY. TYPES: ""!

Inner Structure

""! Abap Doc of the structure BEGIN OF inner_struc, ""!

Field

""! Field field TYPE i, END OF inner_struc. TYPES: ""!

Structure With ABAP Doc Outside

""! Structure with ABAP Doc outside BEGIN OF structure_with_doc_outside, ""!

Table1

""! Table1 ""! $required table1 TYPE string_table, ""!

Structure

""! Structure structure TYPE inner_struc, ""!

Table2

""! Table2 table2 TYPE string_table, END OF structure_with_doc_outside. * Types for number annotations TYPES: ""!

Integer Outside

""! Integer outside ""! $minimum: -25 integer_outside TYPE i. TYPES: ""!

Structure With Number Types

""! This is a structure with different number types BEGIN OF structure_with_numbers, ""!

Integer With Maximum

""! Integer with maximum ""! $maximum: 10 integer TYPE i, ""!

Float With Minimum And Exclusive Maximum

""! Float with minimum and exclusive maximum ""! $exclusiveMaximum:100.9 ""! $minimum: -0.42 float TYPE decfloat16, ""!

Packed Number With Given Multiple

""! Packed number with given multiple ""! $multipleOf: 0.1 ""! $exclusiveMinimum: 0 ""! $maximum: 99999.90 packed_with_multiple TYPE p LENGTH 4 DECIMALS 2, ""!

Packed Number With No Given Multiple

""! Packed number with no given multiple ""! $exclusiveMinimum: 0 packed_without_multiple TYPE p LENGTH 4 DECIMALS 1, ""!

Integer Defined Outside

""! Integer defined outside and ABAP Doc number annotation outside integer_out TYPE integer_outside, ""!

Integer Defined Outside

""! Integer defined outside but with ABAP Doc number annotation here ""! $maximum: 42 integer_out_with_doc TYPE integer_outside, END OF structure_with_numbers. * Types for default annotations TYPES: ""!

Structure With Default

""! Structure to test default checks in simple transformation BEGIN OF structure_different_default, ""!

Four Byte Integer

""! Four byte integer ""! $default '5' four_byte_int TYPE i, ""!

Eight Byte Integer

""! Eight byte integer ""! $default '55' eight_byte_int TYPE int8, ""!

Binary Floating Point Number

""! Binary floating point number ""! $default '4.3' bin_float TYPE f, ""!

Byte Like

""! Byte like ""! $default 'FFFF' byte_like TYPE x LENGTH 2, ""!

Byte Like2

""! Byte like2 ""! $default 'FF00FF' byte_like2 TYPE xstring, ""!

Decimal Floating Point Number

""! Decimal floating point number with 16 places ""! $default '25.26' decimal_float_16 TYPE decfloat16, ""!

Decimal Floating Point Number

""! Decimal floating point number with 34 places ""! $default '123.05' decimal_float_34 TYPE decfloat34, ""!

Packed Number

""! Packed number ""! $default '123.45' packed_number TYPE p LENGTH 3 DECIMALS 2, ""!

Numeric Text Field

""! Numeric text field ""! $default '1067' numeric_text TYPE n LENGTH 4, ""!

Character Text

""! Character text ""! $default 'abcde' character_text TYPE c LENGTH 5, ""!

String Text

""! String text ""! $default 'Default text' string_text TYPE string, ""!

Date

""! Date ""! $default '19720401' date_field TYPE d, ""!

Time

""! Time ""! $default '201500' time_field TYPE t, ""!

Date Time

""! Date time: No support ""! $default '9999-12-31T23:59:59.9999999' date_time_field TYPE utclong, ""!

Boolean

""! Boolean with default abap_true ""! $default 'abap_true' bool_true TYPE abap_bool, ""!

Boolean

""! Boolean with default abap_false ""! $default 'abap_false' bool_false TYPE abap_bool, ""!

Enum Type

""! Enum type ""! $default {@link zcl_aff_test_types.data:co_class_category.exit_class } ""! $values {@link zcl_aff_test_types.data:co_class_category } enum_type TYPE n LENGTH 2, END OF structure_different_default. TYPES: ""!

Structure With Default

""! Structure with default BEGIN OF structure_with_default_problem, ""!

Integer

""! Integer ""! $default: '5' ""! $required integer TYPE i, ""!

String Element

""! String element with default value ""! $default: 'DefaultString' ""! $showAlways string_element TYPE string, ""!

Enum Value

""! Enum value with default ""! $default {@link zcl_aff_test_types.data:co_class_category.exit_class } ""! $values {@link zcl_aff_test_types.data:co_class_category } ""! $required enum_required TYPE n LENGTH 2, ""!

Enum Value

""! Enum value with default ""! $default {@link zcl_aff_test_types.data:co_class_category.exit_class } ""! $values {@link zcl_aff_test_types.data:co_class_category } ""! $showAlways enum_show_always TYPE n LENGTH 2, END OF structure_with_default_problem. TYPES: ""!

Inner Structure

""! Inner structure BEGIN OF inner_struc_with_default, ""!

Inner Component

""! Inner component ""! $default 'Default Value' inner_component TYPE string, END OF inner_struc_with_default, ""!

Middle Structure

""! Middle structure BEGIN OF middle_struc_with_default, ""!

Middle Component

""! Middle component ""! $default 'abcd' middle_component TYPE c LENGTH 4, ""!

Inner Structure

""! Inner structure inner_struc TYPE inner_struc_with_default, END OF middle_struc_with_default, ""!

Nested Structure

""! Nested structure BEGIN OF nested_struc_with_default, ""!

Outer Component

""! Outer component ""! $default '10' outer_component TYPE i, ""!

Middle Structure

""! Middle structure middle_struc TYPE middle_struc_with_default, END OF nested_struc_with_default. * component with wrong default links TYPES: ""!

Structure With Wrong Default

""! Structure with wrong default BEGIN OF structure_with_wrong_default, ""!

First Element

""! First element ""! $default {@link zcl_aff_test_types.data:enum_values.wrong_component } element_one TYPE category, ""!

Second Element

""! Second element ""! $default {@link wrong_link } element_two TYPE category, END OF structure_with_wrong_default. * Types for callbackClass annotation * string with callbackClass TYPES: ""!

String With Callback

""! This is a String with a CallbackClass ""! $maxLength 3 ""! $callbackClass { @link zcl_aff_test_types } simple_callback TYPE string. * table with callback, components are strings TYPES: ""!

my_table

""! A standard table of strings with CallbackClass ""! $callbackClass { @link zcl_aff_test_types } ""! $required table_callback TYPE STANDARD TABLE OF mystring WITH DEFAULT KEY. * table with callback, components are tables TYPES: ""!

my_table_of_table

""! A standard table of my_table ""! $callbackClass { @link zcl_aff_test_types } table_call_of_table TYPE STANDARD TABLE OF my_standard_table WITH DEFAULT KEY. * simple structure with callback TYPES: ""!

Structure With Callback

""! Structure with callback ""! $callbackClass { @link zcl_aff_test_types } BEGIN OF structure_callback, ""!

First Element

""! This is the first element element_name TYPE i, END OF structure_callback. * table of my_structure_with_callback TYPES: ""!

my_table

""! A standard table of my_structure_with_callback table_of_struc_with_callback TYPE STANDARD TABLE OF structure_callback WITH DEFAULT KEY. * simple structure with component my_table_with_callback TYPES: ""!

mySimpleStructure

""! This is a simple structure BEGIN OF struc_of_table_with_callback, ""!

First Element

""! This is the first element ""! $required element_table_callback TYPE table_callback, ""!

Second Element

""! This is the second element my_second_element TYPE i, END OF struc_of_table_with_callback. * simple structure with component my_structure_with_callback TYPES: ""!

mySimpleStructure

""! This is a simple structure BEGIN OF struc_in_struc_with_callback, ""!

First Element

""! This is the first element my_first_element TYPE string, ""!

Second Element

""! This is the second element ""! $required element_structure_callback TYPE structure_callback, ""!

Third Element

""! This is the third element my_third_element TYPE i, END OF struc_in_struc_with_callback. * simple structure with component callback TYPES: ""!

Simple Structure

""! This is a simple structure BEGIN OF structure_with_elem_callback, ""!

First Element

""! This is the first element ""! $minLength 2 ""! $required ""! $callbackClass { @link zcl_aff_test_types } element_callback TYPE mystring, ""!

Second Element

""! This is the second element my_second_element TYPE i, END OF structure_with_elem_callback. * simple structure with wrong callbackclass link TYPES: ""!

Structure With Wrong Callback

""! Structure with wrong callback BEGIN OF structure_with_wrong_callback, ""!

First Element

""! This is the first element ""! $minLength 2 ""! $callbackClass { @link cl_aff_notest_types_for_writer } ""! $required my_first_element TYPE mystring, ""!

Second Element

""! This is the second element ""! $callbackClass { wrong_link } ""! $maximum 4 my_second_element TYPE i, END OF structure_with_wrong_callback. * Types with missing titles and description TYPES: element_no_title_descr TYPE string. TYPES: BEGIN OF inner_struc_no_title_descr, ""!

Inner Field

""! Inner field inner_field TYPE i, END OF inner_struc_no_title_descr. TYPES: table_no_title_descr TYPE STANDARD TABLE OF string WITH EMPTY KEY. TYPES: BEGIN OF structure_no_title_descr, ""! Only description field1 TYPE string, ""!

Only Title

inner_struc TYPE inner_struc_no_title_descr, inner_table TYPE table_no_title_descr, END OF structure_no_title_descr. TYPES: BEGIN OF ty_include_type, ""!

First Element In Include

""! $required first_element TYPE string, second_element TYPE my_structure, ""!

Third Element In Include

""! Third element in include ""! $default '10' third_element TYPE i, END OF ty_include_type. TYPES: ""!

Structure With Include

""! Structure with include BEGIN OF structure_with_include. INCLUDE TYPE ty_include_type. TYPES: ""! Other element ""! $required other_element TYPE i, ""!

Other structure

""! Other Structure other_structure TYPE my_structure, END OF structure_with_include. CONSTANTS: BEGIN OF co_overwritten_values, ""!

Option 1

""! Option 1 ""! $enumValue 'AAAA' first_value TYPE c LENGTH 2 VALUE 'AA', ""!

Option 2

""! Option 2 ""! $enumValue 'BBBB' second_value TYPE c LENGTH 2 VALUE 'BB', END OF co_overwritten_values. TYPES: ""!

Structure With Overwritten Enum Values

""! Structure with overwritten enum values BEGIN OF struc_with_own_enum_values, ""!

Enum Component

""! Enum component ""! $required ""! $values {@link zcl_aff_test_types.data:co_overwritten_values } enum_component TYPE c LENGTH 2, END OF struc_with_own_enum_values. CLASS-DATA subschema TYPE string_table. CLASS-DATA expected_var TYPE REF TO data. CLASS-METHODS get_subschema RETURNING VALUE(subschema) TYPE string_table. CLASS-METHODS serialize IMPORTING writer TYPE REF TO if_sxml_writer simple_callback TYPE simple_callback OPTIONAL structure_callback TYPE structure_callback OPTIONAL table_callback TYPE table_callback OPTIONAL element_callback TYPE string OPTIONAL element_structure_callback TYPE structure_callback OPTIONAL element_table_callback TYPE table_callback OPTIONAL. CLASS-METHODS deserialize IMPORTING reader TYPE REF TO if_sxml_reader EXPORTING simple_callback TYPE simple_callback structure_callback TYPE structure_callback table_callback TYPE table_callback element_callback TYPE string element_structure_callback TYPE structure_callback element_table_callback TYPE table_callback RAISING cx_sxml_error. CLASS-METHODS set_expected IMPORTING expected_variable TYPE any. PROTECTED SECTION. PRIVATE SECTION. CLASS-METHODS jump_to_end IMPORTING reader TYPE REF TO if_sxml_reader RAISING cx_sxml_parse_error. ENDCLASS. CLASS zcl_aff_test_types IMPLEMENTATION. METHOD get_subschema. subschema = zcl_aff_test_types=>subschema. ENDMETHOD. METHOD serialize. IF ( simple_callback IS SUPPLIED ). writer->write_value( 'callbackClass was called' ) ##NO_TEXT. ELSEIF ( structure_callback IS SUPPLIED ). writer->open_element( name = 'str' ). writer->write_attribute( name = 'name' value = 'elementName' ) ##NO_TEXT. writer->write_value( 'callbackClass was called' ) ##NO_TEXT. writer->close_element( ). ELSEIF ( table_callback IS SUPPLIED ). writer->open_element( name = 'str' ). writer->write_value( 'callbackClass was called' ) ##NO_TEXT. writer->close_element( ). ELSEIF ( element_callback IS SUPPLIED ). writer->write_attribute( name = 'name' value = 'elementCallback' ) ##NO_TEXT. writer->write_value( 'callbackClass was called' ) ##NO_TEXT. ELSEIF ( element_structure_callback IS SUPPLIED ). writer->write_attribute( name = 'name' value = 'elementStructureCallback' ) ##NO_TEXT. writer->open_element( name = 'str' ). writer->write_attribute( name = 'name' value = 'elementName' ). writer->write_value( 'callbackClass was called' ) ##NO_TEXT. writer->close_element( ). ELSEIF ( element_table_callback IS SUPPLIED ). writer->write_attribute( name = 'name' value = 'elementTableCallback' ) ##NO_TEXT. writer->open_element( name = 'str' ). writer->write_value( 'callbackClass was called' ) ##NO_TEXT. writer->close_element( ). ENDIF. ENDMETHOD. METHOD deserialize. FIELD-SYMBOLS: TYPE data. reader->next_node( ). ASSIGN expected_var->* TO . IF ( simple_callback IS SUPPLIED ). simple_callback = . ELSEIF ( structure_callback IS SUPPLIED ). structure_callback = . jump_to_end( reader ). ELSEIF ( table_callback IS SUPPLIED ). table_callback = . jump_to_end( reader ). ELSEIF ( element_callback IS SUPPLIED ). element_callback = . ELSEIF ( element_structure_callback IS SUPPLIED ). element_structure_callback = . jump_to_end( reader ). ELSEIF ( element_table_callback IS SUPPLIED ). element_table_callback = . jump_to_end( reader ). ENDIF. ENDMETHOD. METHOD jump_to_end. DATA(type_start) = reader->name. DATA exit TYPE abap_boolean VALUE abap_false. IF reader->node_type = if_sxml_node=>co_nt_element_close. exit = abap_true. ENDIF. WHILE exit = abap_false. reader->next_node( ). IF reader->node_type = if_sxml_node=>co_nt_element_close AND reader->name = type_start. exit = abap_true. ENDIF. ENDWHILE. ENDMETHOD. METHOD set_expected. GET REFERENCE OF expected_variable INTO expected_var. ENDMETHOD. ENDCLASS. ",8020,False,1847.6062644073932,median "* See https://github.com/se38/abapFaker ******************************************************************************** * The MIT License (MIT) * * Copyright (c) 2018 abapFaker Contributors * * 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. ******************************************************************************** CLASS zcl_faker_person_en_us DEFINITION PUBLIC INHERITING FROM zcl_faker_person_default FINAL CREATE PUBLIC . PUBLIC SECTION. METHODS constructor IMPORTING i_faker TYPE REF TO zcl_faker. PRIVATE SECTION. ENDCLASS. CLASS zcl_faker_person_en_us IMPLEMENTATION. METHOD constructor. super->constructor( i_faker ). _first_names_male = VALUE #( ( |Aaron| ) ( |Adam| ) ( |Adrian| ) ( |Alan| ) ( |Albert| ) ( |Alec| ) ( |Alejandro| ) ( |Alex| ) ( |Alexander| ) ( |Alexis| ) ( |Alfred| ) ( |Allen| ) ( |Alvin| ) ( |Andre| ) ( |Andres| ) ( |Andrew| ) ( |Angel| ) ( |Anthony| ) ( |Antonio| ) ( |Arthur| ) ( |Austin| ) ( |Barry| ) ( |Benjamin| ) ( |Bernard| ) ( |Bill| ) ( |Billy| ) ( |Blake| ) ( |Bob| ) ( |Bobby| ) ( |Brad| ) ( |Bradley| ) ( |Brady| ) ( |Brandon| ) ( |Brendan| ) ( |Brent| ) ( |Brett| ) ( |Brian| ) ( |Bruce| ) ( |Bryan| ) ( |Bryce| ) ( |Caleb| ) ( |Calvin| ) ( |Cameron| ) ( |Carl| ) ( |Carlos| ) ( |Casey| ) ( |Cesar| ) ( |Chad| ) ( |Charles| ) ( |Chase| ) ( |Chris| ) ( |Christian| ) ( |Christopher| ) ( |Clarence| ) ( |Clayton| ) ( |Clifford| ) ( |Clinton| ) ( |Cody| ) ( |Cole| ) ( |Colin| ) ( |Collin| ) ( |Colton| ) ( |Connor| ) ( |Corey| ) ( |Cory| ) ( |Craig| ) ( |Cristian| ) ( |Curtis| ) ( |Dakota| ) ( |Dale| ) ( |Dalton| ) ( |Damon| ) ( |Dan| ) ( |Daniel| ) ( |Danny| ) ( |Darin| ) ( |Darius| ) ( |Darrell| ) ( |Darren| ) ( |Darryl| ) ( |Daryl| ) ( |Dave| ) ( |David| ) ( |Dean| ) ( |Dennis| ) ( |Derek| ) ( |Derrick| ) ( |Devin| ) ( |Devon| ) ( |Dillon| ) ( |Dominic| ) ( |Don| ) ( |Donald| ) ( |Douglas| ) ( |Drew| ) ( |Duane| ) ( |Dustin| ) ( |Dwayne| ) ( |Dylan| ) ( |Earl| ) ( |Eddie| ) ( |Edgar| ) ( |Eduardo| ) ( |Edward| ) ( |Edwin| ) ( |Elijah| ) ( |Eric| ) ( |Erik| ) ( |Ernest| ) ( |Ethan| ) ( |Eugene| ) ( |Evan| ) ( |Fernando| ) ( |Francis| ) ( |Francisco| ) ( |Frank| ) ( |Franklin| ) ( |Fred| ) ( |Frederick| ) ( |Gabriel| ) ( |Garrett| ) ( |Gary| ) ( |Gavin| ) ( |Gene| ) ( |Geoffrey| ) ( |George| ) ( |Gerald| ) ( |Gilbert| ) ( |Glen| ) ( |Glenn| ) ( |Gordon| ) ( |Grant| ) ( |Greg| ) ( |Gregg| ) ( |Gregory| ) ( |Guy| ) ( |Harold| ) ( |Harry| ) ( |Hayden| ) ( |Hector| ) ( |Henry| ) ( |Herbert| ) ( |Howard| ) ( |Hunter| ) ( |Ian| ) ( |Isaac| ) ( |Isaiah| ) ( |Ivan| ) ( |Jack| ) ( |Jackson| ) ( |Jacob| ) ( |Jaime| ) ( |Jake| ) ( |James| ) ( |Jamie| ) ( |Jared| ) ( |Jason| ) ( |Javier| ) ( |Jay| ) ( |Jeff| ) ( |Jeffery| ) ( |Jeffrey| ) ( |Jeremiah| ) ( |Jeremy| ) ( |Jermaine| ) ( |Jerome| ) ( |Jerry| ) ( |Jesse| ) ( |Jesus| ) ( |Jim| ) ( |Jimmy| ) ( |Joe| ) ( |Joel| ) ( |John| ) ( |Johnathan| ) ( |Johnny| ) ( |Jon| ) ( |Jonathan| ) ( |Jonathon| ) ( |Jordan| ) ( |Jorge| ) ( |Jose| ) ( |Joseph| ) ( |Joshua| ) ( |Juan| ) ( |Julian| ) ( |Justin| ) ( |Karl| ) ( |Keith| ) ( |Kelly| ) ( |Kenneth| ) ( |Kent| ) ( |Kerry| ) ( |Kevin| ) ( |Kirk| ) ( |Kristopher| ) ( |Kurt| ) ( |Kyle| ) ( |Lance| ) ( |Larry| ) ( |Lawrence| ) ( |Lee| ) ( |Leon| ) ( |Leonard| ) ( |Leroy| ) ( |Leslie| ) ( |Levi| ) ( |Logan| ) ( |Lonnie| ) ( |Louis| ) ( |Lucas| ) ( |Luis| ) ( |Luke| ) ( |Malik| ) ( |Manuel| ) ( |Marc| ) ( |Marco| ) ( |Marcus| ) ( |Mario| ) ( |Mark| ) ( |Martin| ) ( |Marvin| ) ( |Mason| ) ( |Mathew| ) ( |Matthew| ) ( |Maurice| ) ( |Max| ) ( |Maxwell| ) ( |Melvin| ) ( |Michael| ) ( |Micheal| ) ( |Miguel| ) ( |Mike| ) ( |Mitchell| ) ( |Nathan| ) ( |Nathaniel| ) ( |Neil| ) ( |Nicholas| ) ( |Nicolas| ) ( |Noah| ) ( |Norman| ) ( |Omar| ) ( |Oscar| ) ( |Parker| ) ( |Patrick| ) ( |Paul| ) ( |Pedro| ) ( |Perry| ) ( |Peter| ) ( |Philip| ) ( |Phillip| ) ( |Preston| ) ( |Ralph| ) ( |Randall| ) ( |Randy| ) ( |Ray| ) ( |Raymond| ) ( |Reginald| ) ( |Ricardo| ) ( |Richard| ) ( |Rick| ) ( |Rickey| ) ( |Ricky| ) ( |Riley| ) ( |Robert| ) ( |Roberto| ) ( |Rodney| ) ( |Roger| ) ( |Ronald| ) ( |Ronnie| ) ( |Ross| ) ( |Roy| ) ( |Ruben| ) ( |Russell| ) ( |Ryan| ) ( |Samuel| ) ( |Scott| ) ( |Sean| ) ( |Sergio| ) ( |Seth| ) ( |Shane| ) ( |Shannon| ) ( |Shaun| ) ( |Shawn| ) ( |Spencer| ) ( |Stanley| ) ( |Stephen| ) ( |Steve| ) ( |Steven| ) ( |Stuart| ) ( |Tanner| ) ( |Taylor| ) ( |Terrance| ) ( |Terrence| ) ( |Terry| ) ( |Theodore| ) ( |Thomas| ) ( |Tim| ) ( |Timothy| ) ( |Todd| ) ( |Tom| ) ( |Tommy| ) ( |Tony| ) ( |Tracy| ) ( |Travis| ) ( |Trevor| ) ( |Tristan| ) ( |Troy| ) ( |Tyler| ) ( |Tyrone| ) ( |Vernon| ) ( |Victor| ) ( |Vincent| ) ( |Walter| ) ( |Warren| ) ( |Wayne| ) ( |Wesley| ) ( |William| ) ( |Willie| ) ( |Wyatt| ) ( |Xavier| ) ( |Zachary| ) ). _first_names_female = VALUE #( ( |April| ) ( |Abigail| ) ( |Adriana| ) ( |Adrienne| ) ( |Aimee| ) ( |Alejandra| ) ( |Alexa| ) ( |Alexandra| ) ( |Alexandria| ) ( |Alexis| ) ( |Alice| ) ( |Alicia| ) ( |Alisha| ) ( |Alison| ) ( |Allison| ) ( |Alyssa| ) ( |Amanda| ) ( |Amber| ) ( |Amy| ) ( |Ana| ) ( |Andrea| ) ( |Angel| ) ( |Angela| ) ( |Angelica| ) ( |Angie| ) ( |Anita| ) ( |Ann| ) ( |Anna| ) ( |Anne| ) ( |Annette| ) ( |Ariana| ) ( |Ariel| ) ( |Ashlee| ) ( |Ashley| ) ( |Audrey| ) ( |Autumn| ) ( |Bailey| ) ( |Barbara| ) ( |Becky| ) ( |Belinda| ) ( |Beth| ) ( |Bethany| ) ( |Betty| ) ( |Beverly| ) ( |Bianca| ) ( |Bonnie| ) ( |Brandi| ) ( |Brandy| ) ( |Breanna| ) ( |Brenda| ) ( |Briana| ) ( |Brianna| ) ( |Bridget| ) ( |Brittany| ) ( |Brittney| ) ( |Brooke| ) ( |Caitlin| ) ( |Caitlyn| ) ( |Candace| ) ( |Candice| ) ( |Carla| ) ( |Carly| ) ( |Carmen| ) ( |Carol| ) ( |Caroline| ) ( |Carolyn| ) ( |Carrie| ) ( |Casey| ) ( |Cassandra| ) ( |Cassidy| ) ( |Cassie| ) ( |Catherine| ) ( |Cathy| ) ( |Charlene| ) ( |Charlotte| ) ( |Chelsea| ) ( |Chelsey| ) ( |Cheryl| ) ( |Cheyenne| ) ( |Chloe| ) ( |Christie| ) ( |Christina| ) ( |Christine| ) ( |Christy| ) ( |Cindy| ) ( |Claire| ) ( |Claudia| ) ( |Colleen| ) ( |Connie| ) ( |Courtney| ) ( |Cristina| ) ( |Crystal| ) ( |Cynthia| ) ( |Daisy| ) ( |Dana| ) ( |Danielle| ) ( |Darlene| ) ( |Dawn| ) ( |Deanna| ) ( |Debbie| ) ( |Deborah| ) ( |Debra| ) ( |Denise| ) ( |Desiree| ) ( |Destiny| ) ( |Diamond| ) ( |Diana| ) ( |Diane| ) ( |Dominique| ) ( |Donna| ) ( |Doris| ) ( |Dorothy| ) ( |Ebony| ) ( |Eileen| ) ( |Elaine| ) ( |Elizabeth| ) ( |Ellen| ) ( |Emily| ) ( |Emma| ) ( |Erica| ) ( |Erika| ) ( |Erin| ) ( |Evelyn| ) ( |Faith| ) ( |Felicia| ) ( |Frances| ) ( |Gabriela| ) ( |Gabriella| ) ( |Gabrielle| ) ( |Gail| ) ( |Gina| ) ( |Glenda| ) ( |Gloria| ) ( |Grace| ) ( |Gwendolyn| ) ( |Hailey| ) ( |Haley| ) ( |Hannah| ) ( |Hayley| ) ( |Heather| ) ( |Heidi| ) ( |Helen| ) ( |Holly| ) ( |Isabel| ) ( |Isabella| ) ( |Jackie| ) ( |Jaclyn| ) ( |Jacqueline| ) ( |Jade| ) ( |Jaime| ) ( |Jamie| ) ( |Jane| ) ( |Janet| ) ( |Janice| ) ( |Jasmin| ) ( |Jasmine| ) ( |Jean| ) ( |Jeanette| ) ( |Jeanne| ) ( |Jenna| ) ( |Jennifer| ) ( |Jenny| ) ( |Jessica| ) ( |Jill| ) ( |Jillian| ) ( |Jo| ) ( |Joan| ) ( |Joann| ) ( |Joanna| ) ( |Joanne| ) ( |Jocelyn| ) ( |Jodi| ) ( |Jody| ) ( |Jordan| ) ( |Joy| ) ( |Joyce| ) ( |Judith| ) ( |Judy| ) ( |Julia| ) ( |Julie| ) ( |Kaitlin| ) ( |Kaitlyn| ) ( |Kara| ) ( |Karen| ) ( |Kari| ) ( |Karina| ) ( |Karla| ) ( |Katelyn| ) ( |Katherine| ) ( |Kathleen| ) ( |Kathryn| ) ( |Kathy| ) ( |Katie| ) ( |Katrina| ) ( |Kayla| ) ( |Kaylee| ) ( |Kelli| ) ( |Kellie| ) ( |Kelly| ) ( |Kelsey| ) ( |Kendra| ) ( |Kerri| ) ( |Kerry| ) ( |Kiara| ) ( |Kim| ) ( |Kimberly| ) ( |Kirsten| ) ( |Krista| ) ( |Kristen| ) ( |Kristi| ) ( |Kristie| ) ( |Kristin| ) ( |Kristina| ) ( |Kristine| ) ( |Kristy| ) ( |Krystal| ) ( |Kylie| ) ( |Lacey| ) ( |Latasha| ) ( |Latoya| ) ( |Laura| ) ( |Lauren| ) ( |Laurie| ) ( |Leah| ) ( |Leslie| ) ( |Linda| ) ( |Lindsay| ) ( |Lindsey| ) ( |Lisa| ) ( |Loretta| ) ( |Lori| ) ( |Lorraine| ) ( |Lydia| ) ( |Lynn| ) ( |Mackenzie| ) ( |Madeline| ) ( |Madison| ) ( |Makayla| ) ( |Mallory| ) ( |Mandy| ) ( |Marcia| ) ( |Margaret| ) ( |Maria| ) ( |Mariah| ) ( |Marie| ) ( |Marilyn| ) ( |Marisa| ) ( |Marissa| ) ( |Martha| ) ( |Mary| ) ( |Maureen| ) ( |Mckenzie| ) ( |Meagan| ) ( |Megan| ) ( |Meghan| ) ( |Melanie| ) ( |Melinda| ) ( |Melissa| ) ( |Melody| ) ( |Mercedes| ) ( |Meredith| ) ( |Mia| ) ( |Michaela| ) ( |Michele| ) ( |Michelle| ) ( |Mikayla| ) ( |Mindy| ) ( |Miranda| ) ( |Misty| ) ( |Molly| ) ( |Monica| ) ( |Monique| ) ( |Morgan| ) ( |Nancy| ) ( |Natalie| ) ( |Natasha| ) ( |Nichole| ) ( |Nicole| ) ( |Nina| ) ( |Norma| ) ( |Olivia| ) ( |Paige| ) ( |Pam| ) ( |Pamela| ) ( |Patricia| ) ( |Patty| ) ( |Paula| ) ( |Peggy| ) ( |Penny| ) ( |Phyllis| ) ( |Priscilla| ) ( |Rachael| ) ( |Rachel| ) ( |Raven| ) ( |Rebecca| ) ( |Rebekah| ) ( |Regina| ) ( |Renee| ) ( |Rhonda| ) ( |Rita| ) ( |Roberta| ) ( |Robin| ) ( |Robyn| ) ( |Rose| ) ( |Ruth| ) ( |Sabrina| ) ( |Sally| ) ( |Samantha| ) ( |Sandra| ) ( |Sandy| ) ( |Sara| ) ( |Sarah| ) ( |Savannah| ) ( |Selena| ) ( |Shannon| ) ( |Shari| ) ( |Sharon| ) ( |Shawna| ) ( |Sheena| ) ( |Sheila| ) ( |Shelby| ) ( |Shelia| ) ( |Shelley| ) ( |Shelly| ) ( |Sheri| ) ( |Sherri| ) ( |Sherry| ) ( |Sheryl| ) ( |Shirley| ) ( |Sierra| ) ( |Sonia| ) ( |Sonya| ) ( |Sophia| ) ( |Stacey| ) ( |Stacie| ) ( |Stacy| ) ( |Stefanie| ) ( |Stephanie| ) ( |Sue| ) ( |Summer| ) ( |Susan| ) ( |Suzanne| ) ( |Sydney| ) ( |Sylvia| ) ( |Tabitha| ) ( |Tamara| ) ( |Tami| ) ( |Tammie| ) ( |Tammy| ) ( |Tanya| ) ( |Tara| ) ( |Tasha| ) ( |Taylor| ) ( |Teresa| ) ( |Terri| ) ( |Terry| ) ( |Theresa| ) ( |Tiffany| ) ( |Tina| ) ( |Toni| ) ( |Tonya| ) ( |Tracey| ) ( |Traci| ) ( |Tracie| ) ( |Tracy| ) ( |Tricia| ) ( |Valerie| ) ( |Vanessa| ) ( |Veronica| ) ( |Vicki| ) ( |Vickie| ) ( |Victoria| ) ( |Virginia| ) ( |Wanda| ) ( |Wendy| ) ( |Whitney| ) ( |Yesenia| ) ( |Yolanda| ) ( |Yvette| ) ( |Yvonne| ) ( |Zoe| ) ). _last_names = VALUE #( ( |Smith| ) ( |Johnson| ) ( |Williams| ) ( |Brown| ) ( |Jones| ) ( |Miller| ) ( |Davis| ) ( |Garcia| ) ( |Rodriguez| ) ( |Wilson| ) ( |Martinez| ) ( |Anderson| ) ( |Taylor| ) ( |Thomas| ) ( |Hernandez| ) ( |Moore| ) ( |Martin| ) ( |Jackson| ) ( |Thompson| ) ( |White| ) ( |Lopez| ) ( |Lee| ) ( |Gonzalez| ) ( |Harris| ) ( |Clark| ) ( |Lewis| ) ( |Robinson| ) ( |Walker| ) ( |Perez| ) ( |Hall| ) ( |Young| ) ( |Allen| ) ( |Sanchez| ) ( |Wright| ) ( |King| ) ( |Scott| ) ( |Green| ) ( |Baker| ) ( |Adams| ) ( |Nelson| ) ( |Hill| ) ( |Ramirez| ) ( |Campbell| ) ( |Mitchell| ) ( |Roberts| ) ( |Carter| ) ( |Phillips| ) ( |Evans| ) ( |Turner| ) ( |Torres| ) ( |Parker| ) ( |Collins| ) ( |Edwards| ) ( |Stewart| ) ( |Flores| ) ( |Morris| ) ( |Nguyen| ) ( |Murphy| ) ( |Rivera| ) ( |Cook| ) ( |Rogers| ) ( |Morgan| ) ( |Peterson| ) ( |Cooper| ) ( |Reed| ) ( |Bailey| ) ( |Bell| ) ( |Gomez| ) ( |Kelly| ) ( |Howard| ) ( |Ward| ) ( |Cox| ) ( |Diaz| ) ( |Richardson| ) ( |Wood| ) ( |Watson| ) ( |Brooks| ) ( |Bennett| ) ( |Gray| ) ( |James| ) ( |Reyes| ) ( |Cruz| ) ( |Hughes| ) ( |Price| ) ( |Myers| ) ( |Long| ) ( |Foster| ) ( |Sanders| ) ( |Ross| ) ( |Morales| ) ( |Powell| ) ( |Sullivan| ) ( |Russell| ) ( |Ortiz| ) ( |Jenkins| ) ( |Gutierrez| ) ( |Perry| ) ( |Butler| ) ( |Barnes| ) ( |Fisher| ) ( |Henderson| ) ( |Coleman| ) ( |Simmons| ) ( |Patterson| ) ( |Jordan| ) ( |Reynolds| ) ( |Hamilton| ) ( |Graham| ) ( |Kim| ) ( |Gonzales| ) ( |Alexander| ) ( |Ramos| ) ( |Wallace| ) ( |Griffin| ) ( |West| ) ( |Cole| ) ( |Hayes| ) ( |Chavez| ) ( |Gibson| ) ( |Bryant| ) ( |Ellis| ) ( |Stevens| ) ( |Murray| ) ( |Ford| ) ( |Marshall| ) ( |Owens| ) ( |Mcdonald| ) ( |Harrison| ) ( |Ruiz| ) ( |Kennedy| ) ( |Wells| ) ( |Alvarez| ) ( |Woods| ) ( |Mendoza| ) ( |Castillo| ) ( |Olson| ) ( |Webb| ) ( |Washington| ) ( |Tucker| ) ( |Freeman| ) ( |Burns| ) ( |Henry| ) ( |Vasquez| ) ( |Snyder| ) ( |Simpson| ) ( |Crawford| ) ( |Jimenez| ) ( |Porter| ) ( |Mason| ) ( |Shaw| ) ( |Gordon| ) ( |Wagner| ) ( |Hunter| ) ( |Romero| ) ( |Hicks| ) ( |Dixon| ) ( |Hunt| ) ( |Palmer| ) ( |Robertson| ) ( |Black| ) ( |Holmes| ) ( |Stone| ) ( |Meyer| ) ( |Boyd| ) ( |Mills| ) ( |Warren| ) ( |Fox| ) ( |Rose| ) ( |Rice| ) ( |Moreno| ) ( |Schmidt| ) ( |Patel| ) ( |Ferguson| ) ( |Nichols| ) ( |Herrera| ) ( |Medina| ) ( |Ryan| ) ( |Fernandez| ) ( |Weaver| ) ( |Daniels| ) ( |Stephens| ) ( |Gardner| ) ( |Payne| ) ( |Kelley| ) ( |Dunn| ) ( |Pierce| ) ( |Arnold| ) ( |Tran| ) ( |Spencer| ) ( |Peters| ) ( |Hawkins| ) ( |Grant| ) ( |Hansen| ) ( |Castro| ) ( |Hoffman| ) ( |Hart| ) ( |Elliott| ) ( |Cunningham| ) ( |Knight| ) ( |Bradley| ) ( |Carroll| ) ( |Hudson| ) ( |Duncan| ) ( |Armstrong| ) ( |Berry| ) ( |Andrews| ) ( |Johnston| ) ( |Ray| ) ( |Lane| ) ( |Riley| ) ( |Carpenter| ) ( |Perkins| ) ( |Aguilar| ) ( |Silva| ) ( |Richards| ) ( |Willis| ) ( |Matthews| ) ( |Chapman| ) ( |Lawrence| ) ( |Garza| ) ( |Vargas| ) ( |Watkins| ) ( |Wheeler| ) ( |Larson| ) ( |Carlson| ) ( |Harper| ) ( |George| ) ( |Greene| ) ( |Burke| ) ( |Guzman| ) ( |Morrison| ) ( |Munoz| ) ( |Jacobs| ) ( |Obrien| ) ( |Lawson| ) ( |Franklin| ) ( |Lynch| ) ( |Bishop| ) ( |Carr| ) ( |Salazar| ) ( |Austin| ) ( |Mendez| ) ( |Gilbert| ) ( |Jensen| ) ( |Williamson| ) ( |Montgomery| ) ( |Harvey| ) ( |Oliver| ) ( |Howell| ) ( |Dean| ) ( |Hanson| ) ( |Weber| ) ( |Garrett| ) ( |Sims| ) ( |Burton| ) ( |Fuller| ) ( |Soto| ) ( |Mccoy| ) ( |Welch| ) ( |Chen| ) ( |Schultz| ) ( |Walters| ) ( |Reid| ) ( |Fields| ) ( |Walsh| ) ( |Little| ) ( |Fowler| ) ( |Bowman| ) ( |Davidson| ) ( |May| ) ( |Day| ) ( |Schneider| ) ( |Newman| ) ( |Brewer| ) ( |Lucas| ) ( |Holland| ) ( |Wong| ) ( |Banks| ) ( |Santos| ) ( |Curtis| ) ( |Pearson| ) ( |Delgado| ) ( |Valdez| ) ( |Pena| ) ( |Rios| ) ( |Douglas| ) ( |Sandoval| ) ( |Barrett| ) ( |Hopkins| ) ( |Keller| ) ( |Guerrero| ) ( |Stanley| ) ( |Bates| ) ( |Alvarado| ) ( |Beck| ) ( |Ortega| ) ( |Wade| ) ( |Estrada| ) ( |Contreras| ) ( |Barnett| ) ( |Caldwell| ) ( |Santiago| ) ( |Lambert| ) ( |Powers| ) ( |Chambers| ) ( |Nunez| ) ( |Craig| ) ( |Leonard| ) ( |Lowe| ) ( |Rhodes| ) ( |Byrd| ) ( |Gregory| ) ( |Shelton| ) ( |Frazier| ) ( |Becker| ) ( |Maldonado| ) ( |Fleming| ) ( |Vega| ) ( |Sutton| ) ( |Cohen| ) ( |Jennings| ) ( |Parks| ) ( |Mcdaniel| ) ( |Watts| ) ( |Barker| ) ( |Norris| ) ( |Vaughn| ) ( |Vazquez| ) ( |Holt| ) ( |Schwartz| ) ( |Steele| ) ( |Benson| ) ( |Neal| ) ( |Dominguez| ) ( |Horton| ) ( |Terry| ) ( |Wolfe| ) ( |Hale| ) ( |Lyons| ) ( |Graves| ) ( |Haynes| ) ( |Miles| ) ( |Park| ) ( |Warner| ) ( |Padilla| ) ( |Bush| ) ( |Thornton| ) ( |Mccarthy| ) ( |Mann| ) ( |Zimmerman| ) ( |Erickson| ) ( |Fletcher| ) ( |Mckinney| ) ( |Page| ) ( |Dawson| ) ( |Joseph| ) ( |Marquez| ) ( |Reeves| ) ( |Klein| ) ( |Espinoza| ) ( |Baldwin| ) ( |Moran| ) ( |Love| ) ( |Robbins| ) ( |Higgins| ) ( |Ball| ) ( |Cortez| ) ( |Le| ) ( |Griffith| ) ( |Bowen| ) ( |Sharp| ) ( |Cummings| ) ( |Ramsey| ) ( |Hardy| ) ( |Swanson| ) ( |Barber| ) ( |Acosta| ) ( |Luna| ) ( |Chandler| ) ( |Daniel| ) ( |Blair| ) ( |Cross| ) ( |Simon| ) ( |Dennis| ) ( |Oconnor| ) ( |Quinn| ) ( |Gross| ) ( |Navarro| ) ( |Moss| ) ( |Fitzgerald| ) ( |Doyle| ) ( |Mclaughlin| ) ( |Rojas| ) ( |Rodgers| ) ( |Stevenson| ) ( |Singh| ) ( |Yang| ) ( |Figueroa| ) ( |Harmon| ) ( |Newton| ) ( |Paul| ) ( |Manning| ) ( |Garner| ) ( |Mcgee| ) ( |Reese| ) ( |Francis| ) ( |Burgess| ) ( |Adkins| ) ( |Goodman| ) ( |Curry| ) ( |Brady| ) ( |Christensen| ) ( |Potter| ) ( |Walton| ) ( |Goodwin| ) ( |Mullins| ) ( |Molina| ) ( |Webster| ) ( |Fischer| ) ( |Campos| ) ( |Avila| ) ( |Sherman| ) ( |Todd| ) ( |Chang| ) ( |Blake| ) ( |Malone| ) ( |Wolf| ) ( |Hodges| ) ( |Juarez| ) ( |Gill| ) ( |Farmer| ) ( |Hines| ) ( |Gallagher| ) ( |Duran| ) ( |Hubbard| ) ( |Cannon| ) ( |Miranda| ) ( |Wang| ) ( |Saunders| ) ( |Tate| ) ( |Mack| ) ( |Hammond| ) ( |Carrillo| ) ( |Townsend| ) ( |Wise| ) ( |Ingram| ) ( |Barton| ) ( |Mejia| ) ( |Ayala| ) ( |Schroeder| ) ( |Hampton| ) ( |Rowe| ) ( |Parsons| ) ( |Frank| ) ( |Waters| ) ( |Strickland| ) ( |Osborne| ) ( |Maxwell| ) ( |Chan| ) ( |Deleon| ) ( |Norman| ) ( |Harrington| ) ( |Casey| ) ( |Patton| ) ( |Logan| ) ( |Bowers| ) ( |Mueller| ) ( |Glover| ) ( |Floyd| ) ( |Hartman| ) ( |Buchanan| ) ( |Cobb| ) ( |French| ) ( |Kramer| ) ( |Mccormick| ) ( |Clarke| ) ( |Tyler| ) ( |Gibbs| ) ( |Moody| ) ( |Conner| ) ( |Sparks| ) ( |Mcguire| ) ( |Leon| ) ( |Bauer| ) ( |Norton| ) ( |Pope| ) ( |Flynn| ) ( |Hogan| ) ( |Robles| ) ( |Salinas| ) ( |Yates| ) ( |Lindsey| ) ( |Lloyd| ) ( |Marsh| ) ( |Mcbride| ) ( |Owen| ) ( |Solis| ) ( |Pham| ) ( |Lang| ) ( |Pratt| ) ( |Lara| ) ( |Brock| ) ( |Ballard| ) ( |Trujillo| ) ( |Shaffer| ) ( |Drake| ) ( |Roman| ) ( |Aguirre| ) ( |Morton| ) ( |Stokes| ) ( |Lamb| ) ( |Pacheco| ) ( |Patrick| ) ( |Cochran| ) ( |Shepherd| ) ( |Cain| ) ( |Burnett| ) ( |Hess| ) ( |Li| ) ( |Cervantes| ) ( |Olsen| ) ( |Briggs| ) ( |Ochoa| ) ( |Cabrera| ) ( |Velasquez| ) ( |Montoya| ) ( |Roth| ) ( |Meyers| ) ( |Cardenas| ) ( |Fuentes| ) ( |Weiss| ) ( |Wilkins| ) ( |Hoover| ) ( |Nicholson| ) ( |Underwood| ) ( |Short| ) ( |Carson| ) ( |Morrow| ) ( |Colon| ) ( |Holloway| ) ( |Summers| ) ( |Bryan| ) ( |Petersen| ) ( |Mckenzie| ) ( |Serrano| ) ( |Wilcox| ) ( |Carey| ) ( |Clayton| ) ( |Poole| ) ( |Calderon| ) ( |Gallegos| ) ( |Greer| ) ( |Rivas| ) ( |Guerra| ) ( |Decker| ) ( |Collier| ) ( |Wall| ) ( |Whitaker| ) ( |Bass| ) ( |Flowers| ) ( |Davenport| ) ( |Conley| ) ( |Houston| ) ( |Huff| ) ( |Copeland| ) ( |Hood| ) ( |Monroe| ) ( |Massey| ) ( |Roberson| ) ( |Combs| ) ( |Franco| ) ( |Larsen| ) ( |Pittman| ) ( |Randall| ) ( |Skinner| ) ( |Wilkinson| ) ( |Kirby| ) ( |Cameron| ) ( |Bridges| ) ( |Anthony| ) ( |Richard| ) ( |Kirk| ) ( |Bruce| ) ( |Singleton| ) ( |Mathis| ) ( |Bradford| ) ( |Boone| ) ( |Abbott| ) ( |Charles| ) ( |Allison| ) ( |Sweeney| ) ( |Atkinson| ) ( |Horn| ) ( |Jefferson| ) ( |Rosales| ) ( |York| ) ( |Christian| ) ( |Phelps| ) ( |Farrell| ) ( |Castaneda| ) ( |Nash| ) ( |Dickerson| ) ( |Bond| ) ( |Wyatt| ) ( |Foley| ) ( |Chase| ) ( |Gates| ) ( |Vincent| ) ( |Mathews| ) ( |Hodge| ) ( |Garrison| ) ( |Trevino| ) ( |Villarreal| ) ( |Heath| ) ( |Dalton| ) ( |Valencia| ) ( |Callahan| ) ( |Hensley| ) ( |Atkins| ) ( |Huffman| ) ( |Roy| ) ( |Boyer| ) ( |Shields| ) ( |Lin| ) ( |Hancock| ) ( |Grimes| ) ( |Glenn| ) ( |Cline| ) ( |Delacruz| ) ( |Camacho| ) ( |Dillon| ) ( |Parrish| ) ( |Oneill| ) ( |Melton| ) ( |Booth| ) ( |Kane| ) ( |Berg| ) ( |Harrell| ) ( |Pitts| ) ( |Savage| ) ( |Wiggins| ) ( |Brennan| ) ( |Salas| ) ( |Marks| ) ( |Russo| ) ( |Sawyer| ) ( |Baxter| ) ( |Golden| ) ( |Hutchinson| ) ( |Liu| ) ( |Walter| ) ( |Mcdowell| ) ( |Wiley| ) ( |Rich| ) ( |Humphrey| ) ( |Johns| ) ( |Koch| ) ( |Suarez| ) ( |Hobbs| ) ( |Beard| ) ( |Gilmore| ) ( |Ibarra| ) ( |Keith| ) ( |Macias| ) ( |Khan| ) ( |Andrade| ) ( |Ware| ) ( |Stephenson| ) ( |Henson| ) ( |Wilkerson| ) ( |Dyer| ) ( |Mcclure| ) ( |Blackwell| ) ( |Mercado| ) ( |Tanner| ) ( |Eaton| ) ( |Clay| ) ( |Barron| ) ( |Beasley| ) ( |Oneal| ) ( |Small| ) ( |Preston| ) ( |Wu| ) ( |Zamora| ) ( |Macdonald| ) ( |Vance| ) ( |Snow| ) ( |Mcclain| ) ( |Stafford| ) ( |Orozco| ) ( |Barry| ) ( |English| ) ( |Shannon| ) ( |Kline| ) ( |Jacobson| ) ( |Woodard| ) ( |Huang| ) ( |Kemp| ) ( |Mosley| ) ( |Prince| ) ( |Merritt| ) ( |Hurst| ) ( |Villanueva| ) ( |Roach| ) ( |Nolan| ) ( |Lam| ) ( |Yoder| ) ( |Mccullough| ) ( |Lester| ) ( |Santana| ) ( |Valenzuela| ) ( |Winters| ) ( |Barrera| ) ( |Orr| ) ( |Leach| ) ( |Berger| ) ( |Mckee| ) ( |Strong| ) ( |Conway| ) ( |Stein| ) ( |Whitehead| ) ( |Bullock| ) ( |Escobar| ) ( |Knox| ) ( |Meadows| ) ( |Solomon| ) ( |Velez| ) ( |Odonnell| ) ( |Kerr| ) ( |Stout| ) ( |Blankenship| ) ( |Browning| ) ( |Kent| ) ( |Lozano| ) ( |Bartlett| ) ( |Pruitt| ) ( |Buck| ) ( |Barr| ) ( |Gaines| ) ( |Durham| ) ( |Gentry| ) ( |Mcintyre| ) ( |Sloan| ) ( |Rocha| ) ( |Melendez| ) ( |Herman| ) ( |Sexton| ) ( |Moon| ) ( |Hendricks| ) ( |Rangel| ) ( |Stark| ) ( |Lowery| ) ( |Hardin| ) ( |Hull| ) ( |Sellers| ) ( |Ellison| ) ( |Calhoun| ) ( |Gillespie| ) ( |Mora| ) ( |Knapp| ) ( |Mccall| ) ( |Morse| ) ( |Dorsey| ) ( |Weeks| ) ( |Nielsen| ) ( |Livingston| ) ( |Leblanc| ) ( |Mclean| ) ( |Bradshaw| ) ( |Glass| ) ( |Middleton| ) ( |Buckley| ) ( |Schaefer| ) ( |Frost| ) ( |Howe| ) ( |House| ) ( |Mcintosh| ) ( |Ho| ) ( |Pennington| ) ( |Reilly| ) ( |Hebert| ) ( |Mcfarland| ) ( |Hickman| ) ( |Noble| ) ( |Spears| ) ( |Conrad| ) ( |Arias| ) ( |Galvan| ) ( |Velazquez| ) ( |Huynh| ) ( |Frederick| ) ( |Randolph| ) ( |Cantu| ) ( |Fitzpatrick| ) ( |Mahoney| ) ( |Peck| ) ( |Villa| ) ( |Michael| ) ( |Donovan| ) ( |Mcconnell| ) ( |Walls| ) ( |Boyle| ) ( |Mayer| ) ( |Zuniga| ) ( |Giles| ) ( |Pineda| ) ( |Pace| ) ( |Hurley| ) ( |Mays| ) ( |Mcmillan| ) ( |Crosby| ) ( |Ayers| ) ( |Case| ) ( |Bentley| ) ( |Shepard| ) ( |Everett| ) ( |Pugh| ) ( |David| ) ( |Mcmahon| ) ( |Dunlap| ) ( |Bender| ) ( |Hahn| ) ( |Harding| ) ( |Acevedo| ) ( |Raymond| ) ( |Blackburn| ) ( |Duffy| ) ( |Landry| ) ( |Dougherty| ) ( |Bautista| ) ( |Shah| ) ( |Potts| ) ( |Arroyo| ) ( |Valentine| ) ( |Meza| ) ( |Gould| ) ( |Vaughan| ) ( |Fry| ) ( |Rush| ) ( |Avery| ) ( |Herring| ) ( |Dodson| ) ( |Clements| ) ( |Sampson| ) ( |Tapia| ) ( |Bean| ) ( |Lynn| ) ( |Crane| ) ( |Farley| ) ( |Cisneros| ) ( |Benton| ) ( |Ashley| ) ( |Mckay| ) ( |Finley| ) ( |Best| ) ( |Blevins| ) ( |Friedman| ) ( |Moses| ) ( |Sosa| ) ( |Blanchard| ) ( |Huber| ) ( |Frye| ) ( |Krueger| ) ( |Bernard| ) ( |Rosario| ) ( |Rubio| ) ( |Mullen| ) ( |Benjamin| ) ( |Haley| ) ( |Chung| ) ( |Moyer| ) ( |Choi| ) ( |Horne| ) ( |Yu| ) ( |Woodward| ) ( |Ali| ) ( |Nixon| ) ( |Hayden| ) ( |Rivers| ) ( |Estes| ) ( |Mccarty| ) ( |Richmond| ) ( |Stuart| ) ( |Maynard| ) ( |Brandt| ) ( |Oconnell| ) ( |Hanna| ) ( |Sanford| ) ( |Sheppard| ) ( |Church| ) ( |Burch| ) ( |Levy| ) ( |Rasmussen| ) ( |Coffey| ) ( |Ponce| ) ( |Faulkner| ) ( |Donaldson| ) ( |Schmitt| ) ( |Novak| ) ( |Costa| ) ( |Montes| ) ( |Booker| ) ( |Cordova| ) ( |Waller| ) ( |Arellano| ) ( |Maddox| ) ( |Mata| ) ( |Bonilla| ) ( |Stanton| ) ( |Compton| ) ( |Kaufman| ) ( |Dudley| ) ( |Mcpherson| ) ( |Beltran| ) ( |Dickson| ) ( |Mccann| ) ( |Villegas| ) ( |Proctor| ) ( |Hester| ) ( |Cantrell| ) ( |Daugherty| ) ( |Cherry| ) ( |Bray| ) ( |Davila| ) ( |Rowland| ) ( |Madden| ) ( |Levine| ) ( |Spence| ) ( |Good| ) ( |Irwin| ) ( |Werner| ) ( |Krause| ) ( |Petty| ) ( |Whitney| ) ( |Baird| ) ( |Hooper| ) ( |Pollard| ) ( |Zavala| ) ( |Jarvis| ) ( |Holden| ) ( |Hendrix| ) ( |Haas| ) ( |Mcgrath| ) ( |Bird| ) ( |Lucero| ) ( |Terrell| ) ( |Riggs| ) ( |Joyce| ) ( |Rollins| ) ( |Mercer| ) ( |Galloway| ) ( |Duke| ) ( |Odom| ) ( |Andersen| ) ( |Downs| ) ( |Hatfield| ) ( |Benitez| ) ( |Archer| ) ( |Huerta| ) ( |Travis| ) ( |Mcneil| ) ( |Hinton| ) ( |Zhang| ) ( |Hays| ) ( |Mayo| ) ( |Fritz| ) ( |Branch| ) ( |Mooney| ) ( |Ewing| ) ( |Ritter| ) ( |Esparza| ) ( |Frey| ) ( |Braun| ) ( |Gay| ) ( |Riddle| ) ( |Haney| ) ( |Kaiser| ) ( |Holder| ) ( |Chaney| ) ( |Mcknight| ) ( |Gamble| ) ( |Vang| ) ( |Cooley| ) ( |Carney| ) ( |Cowan| ) ( |Forbes| ) ( |Ferrell| ) ( |Davies| ) ( |Barajas| ) ( |Shea| ) ( |Osborn| ) ( |Bright| ) ( |Cuevas| ) ( |Bolton| ) ( |Murillo| ) ( |Lutz| ) ( |Duarte| ) ( |Kidd| ) ( |Key| ) ( |Cooke| ) ). _name_formats = value #( ( `{{person-first_name}} {{person-last_name}}` ) ( `{{person-first_name}} {{person-last_name}}` ) ( `{{person-first_name}} {{person-initial}}. {{person-last_name}}` ) ( `{{person-first_name}} {{person-initial}}. {{person-last_name}}` ) ( `{{person-first_name}} {{person-initial}}. {{person-last_name}}` ) ( `{{person-first_name}} {{person-initial}}. {{person-last_name}}` ) ( `{{person-first_name}} {{person-initial}}. {{person-last_name}}` ) ( `{{person-initial}}.{{person-initial}}. {{person-last_name}}` ) ). ENDMETHOD. ENDCLASS. ",12521,True,3686.460244387094,median "*&---------------------------------------------------------------------* *& Include Z_MONSTER_ADL_IO1 *&---------------------------------------------------------------------* * Local Class Implementations *--------------------------------------------------------------------* CLASS lcl_application IMPLEMENTATION. *--------------------------------------------------------------------* * Listing 10.01: Generic Template for Calling ALV Reports *--------------------------------------------------------------------* * Jeffrey is a PURPLE Monster *--------------------------------------------------------------------* METHOD main.""Of Monster Atrocity Due List * Local Variables DATA: ld_repid TYPE sy-repid. ""It is bad news to pass system variables as parameters ld_repid = sy-repid. mo_model = NEW #( ). ""Hard Coded here - would use configuration or similar in ""real life DATA(context_data_list) = VALUE wdr_simple_name_value_list( ( name = 'UI_TECHNOLOGY' value = 'CL_SALV_TABLE' ) ). zcl_ocp_factory=>return_object_given( EXPORTING it_context_data = context_data_list CHANGING co_object = mo_view ). mo_controller = NEW #( io_model = mo_model io_view = mo_view ). mo_model->data_retrieval( ). mo_model->prepare_data_for_ouput( ). IF sy-batch IS INITIAL. *--------------------------------------------------------------------* * Listing 10.35: - Calling a SALV report whilst creating a container * automatically *--------------------------------------------------------------------* * Program flow is as follows:- * ZCL_BC_VIEW_SALV_TABLE->CREATE_CONTAINER_PREPARE_DATA * Function ZSALV_CSQT_CREATE_CONTAINER * ZSALV_CSQT_CREATE_CONTAINER->FILL_CONTAINER_CONTENT * ZCL_BC_VIEW_SALV_TABLE->PREPARE_DISPLAY_DATA * --> INITIALISE (Generic) * --> Application Specific Changes (Generic) * --> Display (Generic) mo_view->create_container_prep_display( EXPORTING id_report_name = ld_repid if_start_in_edit_mode = go_selections->p_edit id_edit_control_field = mo_model->md_edit_control_field it_editable_fields = mo_model->mt_editable_fields it_technicals = mo_model->mt_technicals it_hidden = mo_model->mt_hidden it_hotspots = mo_model->mt_hotspots it_checkboxes = mo_model->mt_checkboxes it_subtotal_fields = mo_model->mt_subtotal_fields it_field_texts = mo_model->mt_field_texts it_sort_criteria = mo_model->mt_sort_criteria it_user_commands = mo_model->mt_user_commands CHANGING ct_data_table = mo_model->mt_output_data ). ELSE. * If this is running in the background there is no way * in the world we want/need a container, as there is no * chance for the user to press any user command buttons or * edit the data, as there is no user, and no screen for the * container to live on for that matter mo_view->prepare_display_data( EXPORTING id_report_name = ld_repid it_technicals = mo_model->mt_technicals it_hidden = mo_model->mt_hidden it_hotspots = mo_model->mt_hotspots it_checkboxes = mo_model->mt_checkboxes it_subtotal_fields = mo_model->mt_subtotal_fields it_field_texts = mo_model->mt_field_texts it_sort_criteria = mo_model->mt_sort_criteria it_user_commands = mo_model->mt_user_commands CHANGING ct_data_table = mo_model->mt_output_data ). ENDIF.""Are we running in the background? IF go_selections->p_email IS NOT INITIAL. mo_controller->send_email( ). ENDIF. ENDMETHOD. ""main ENDCLASS. ""lcl_application IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_selections IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_selections IMPLEMENTATION. METHOD constructor. s_date = is_date. s_cstl = is_cstl. p_vari = ip_vari. p_edit = ip_edit. p_send = ip_send. p_email = ip_email. ENDMETHOD. ""constructor ENDCLASS.""Local Selections *----------------------------------------------------------------------* * CLASS lcl_persistency_layer IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_persistency_layer IMPLEMENTATION. METHOD get_data. *--------------------------------------------------------------------* * EXPORTING et_output_data TYPE g_tt_output_data. *--------------------------------------------------------------------* SELECT * ##too_many_itab_fields ""in the world FROM z4c_monster_atrocity_due_list INTO CORRESPONDING FIELDS OF TABLE @rt_output_data. ENDMETHOD. ""get_data ENDCLASS. ""lcl_persistency_layer IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_model IMPLEMENTATION *----------------------------------------------------------------------* * When creating the model for real we do not fill the import parameter * and thus the data is read for real * When creating the model within a unit test, we pass in a reference to * the fake database access class *----------------------------------------------------------------------* CLASS lcl_model IMPLEMENTATION. METHOD constructor. super->constructor( ). IF io_access_class IS SUPPLIED. mo_persistency_layer = io_access_class. ELSE. mo_persistency_layer = NEW #( ). ENDIF. fill_user_commands( ). fill_technical_fields( ). fill_hidden_fields( ). fill_hotspot_fields( ). fill_subtotal_fields( ). fill_field_texts( ). fill_editable_fields( ). fill_checkbox_fields( ). set_edit_control_field( ). ENDMETHOD. ""constructor METHOD data_retrieval. mt_output_data[] = mo_persistency_layer->get_data( ). ENDMETHOD. ""data_retrieval *--------------------------------------------------------------------* * METHOD prepare_data_for_output *--------------------------------------------------------------------* * Get text names of objects, mapping, etc etc *--------------------------------------------------------------------* METHOD prepare_data_for_ouput ##NEEDED. ENDMETHOD. ""prepare_data_for_ouput METHOD fill_user_commands. *--------------------------------------------------------------------* * Listing 10.27 - Method in the Model Class to Define User Commands *--------------------------------------------------------------------* CLEAR mt_user_commands. INSERT VALUE #( function = 'ZALLOCATE' icon = icon_deceased_patient butn_type = 0 ""Normal Button text = 'Allocate Monster'(001) ) INTO TABLE mt_user_commands. ENDMETHOD. ""fill_user_commands METHOD fill_editable_fields. APPEND 'TASK_DESCRIPTION' TO mt_editable_fields.""Can be edited if job not yet in progress ENDMETHOD. ""fill_editable_fields METHOD fill_hidden_fields ##NEEDED. ""No Hidden Fields ENDMETHOD. ""fill_hidden_fields METHOD fill_technical_fields. APPEND 'MANDT' TO mt_technicals. ENDMETHOD. ""fill_technical_fields METHOD fill_hotspot_fields ##NEEDED. ""No Hotspots ENDMETHOD. ""fill_hotspot_fields METHOD fill_subtotal_fields ##NEEDED. ""No Subtotals ENDMETHOD. ""fill_subtotal_fields METHOD fill_field_texts ##NEEDED. * No Need to Rename Anything ENDMETHOD. ""fill_field_texts METHOD fill_checkbox_fields. APPEND 'CHECK' TO mt_checkboxes. ENDMETHOD. ""fill_checkbox_fields METHOD user_command. CASE id_user_command. WHEN '&IC1'. READ TABLE mt_output_data ASSIGNING FIELD-SYMBOL() INDEX id_row. IF sy-subrc NE 0. RETURN. ENDIF. CASE id_column. WHEN 'CHECK'. IF -check = abap_false. -check = abap_true. ELSE. -check = abap_false. ENDIF. RAISE EVENT data_changed. WHEN OTHERS. RETURN. ENDCASE.""What column was selected for drill down? WHEN 'ZALLOCATE'. LOOP AT mt_output_data ASSIGNING WHERE check = abap_true. allocate_monster( ). ENDLOOP. WHEN OTHERS. RETURN. ENDCASE.""What user command was chosen? ENDMETHOD.""User Command / Model METHOD allocate_monster. *--------------------------------------------------------------------* * IMPORTING is_output_data TYPE g_typ_alv_output_data *--------------------------------------------------------------------* * Local Variables DATA: lt_options TYPE STANDARD TABLE OF spopli, ls_options LIKE LINE OF lt_options, ls_titles TYPE spop5, ld_answer TYPE char01, ld_default_choice TYPE sy-lilli, ld_actual_choice TYPE sy-tabix. ""This user command should be in the CONTROLLER which would get the input dara from the model and then ""use the view to ask the user the question ls_options-varoption = 'Bolts-Through-Neck'(002). APPEND ls_options TO lt_options. ls_options-varoption = 'Creeping Terror'(003). APPEND ls_options TO lt_options. ls_options-varoption = 'Creature from the Black Lagoon'(004). APPEND ls_options TO lt_options. ls_options-varoption = 'Killer Klown'(005). APPEND ls_options TO lt_options. ls_options-varoption = 'Thing with Two Heads'(006). APPEND ls_options TO lt_options. ld_default_choice = 1. ls_titles-titel = 'Choose Monster'(007). ls_titles-textline1 = 'Which Monster shall do This Deed, This Deed so Vile?'(008). CALL FUNCTION 'POPUP_TO_DECIDE_LIST' EXPORTING cursorline = ld_default_choice textline1 = ls_titles-textline1 titel = ls_titles-titel IMPORTING answer = ld_answer TABLES t_spopli = lt_options[] EXCEPTIONS not_enough_answers = 1 too_much_answers = 2 too_much_marks = 3 OTHERS = 4. IF sy-subrc <> 0. RETURN. ENDIF. CASE ld_answer. WHEN '1' OR '2' OR '3' OR '4' OR '5'. ld_actual_choice = ld_answer. WHEN OTHERS. RETURN. ENDCASE. DATA: ls_monitor TYPE z4t_deliveries. ls_monitor = CORRESPONDING #( is_output_data ). READ TABLE lt_options INTO ls_options INDEX ld_actual_choice. ASSERT sy-subrc EQ 0. ls_monitor-monster_name = ls_options-varoption. ls_monitor-current_status = 'A'.""Atrocity Ready to be Committed DATA(lo_uuid_generator) = cl_uuid_factory=>create_system_uuid( ). TRY. ls_monitor-db_key = lo_uuid_generator->create_uuid_x16( ). CATCH cx_uuid_error INTO DATA(uuid_error). DATA(ld_message) = uuid_error->get_text( ). MESSAGE ld_message TYPE 'I'. RETURN. ENDTRY. ls_monitor-delivery_number = sy-datum+2(2) && sy-datum+4(2) && sy-datum+6(2) && sy-uzeit(2) && sy-uzeit+2(2). *-------------------------------------------------------------------------------------------------------------* * TO-DO * Need to create the new delivery using the delivery business object peristency layer - not a direct update *-------------------------------------------------------------------------------------------------------------* MODIFY z4t_deliveries FROM ls_monitor. IF sy-subrc <> 0. ROLLBACK WORK. ""#EC CI_ROLLBACK RETURN. ENDIF. *-------------------------------------------------------------------------------------------------------------* * TO-DO * Need to call persitency layer of order business object and set the order status to ""C"" (using a constant as * opposed to a hard coded value) *-------------------------------------------------------------------------------------------------------------* UPDATE z4t_order_items SET foul_deed_status = 'C' WHERE order_number = is_output_data-ordernumber AND order_item = is_output_data-orderitem. IF sy-subrc <> 0. ROLLBACK WORK. ""#EC CI_ROLLBACK RETURN. ELSE. COMMIT WORK. ""Horrible, Horrible, Deed has Been Scheduled MESSAGE i014(z4monsters). ENDIF. *-----------------------------------------------------------------------------------------* * Listing 14.02: - Checking ABAP Messaging Channel Application/Channel Combination Exists *-----------------------------------------------------------------------------------------* ""This next bit should be in it's own method of a dedicated local class ""Now, let us tell the push channel that the monster has been scheduled ""to do the atrocity ""Determine message type of the AMC channel TRY. DATA(amc_dt_manager) = cl_amc_dt_manager=>create( i_application_id = 'ZAMC_4_MONSTERS' i_channel_id = '/monsters' ). DATA(amc_message_type) = amc_dt_manager->get_message_type( ). CATCH cx_amc_dt_error INTO DATA(amc_dt_error). MESSAGE amc_dt_error TYPE 'E'. ENDTRY. IF amc_message_type NE 'PCP'. RETURN. ENDIF. *-----------------------------------------------------------------------* * Listing 14.01: - Defining Where AMC Message Will Be Published *-----------------------------------------------------------------------* * Listing 14.03: - Preparing and Sending ABAP Messaging Channels Message *-----------------------------------------------------------------------* ""Fill Payload TRY. ""Create Bottle to Send ""Set extension ID to be the Castle Number. Only monster ""monitors subscribed to that particular castle will then ""be notified of the new atrocity to be performed. Monitors ""for other castles do not care DATA(message_bottle) = CAST if_amc_message_producer_pcp( cl_amc_channel_manager=>create_message_producer( i_application_id = 'ZAMC_4_MONSTERS' i_channel_id = '/monsters' i_channel_extension_id = CONV #( ls_monitor-castle_number ) ) ). ""Create Message for Bottle DATA(pcp_message) = cl_ac_message_type_pcp=>create( ). pcp_message->set_text( |{ 'A New Atrocity needs to be Committed'(009) }| ). pcp_message->set_field( i_name = |{ 'Delivery Number'(010) }| i_value = CONV #( ls_monitor-delivery_number ) ). ""Put message in bottle, and throw bottle into the sea message_bottle->send( pcp_message ). CATCH cx_ac_message_type_pcp_error INTO DATA(pcp_error). MESSAGE pcp_error TYPE 'E'. CATCH cx_amc_error INTO DATA(amc_error). MESSAGE amc_error TYPE 'E'. ENDTRY. ENDMETHOD. ""allocate_monster ENDCLASS. ""lcl_model IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_view IMPLEMENTATION *----------------------------------------------------------------------* * During the INITIALISATION method this method is called so that * every row in the output table will be * changed such that nominated columns have been made editable. * Now we want to extend this logic to restrict the ability to change * the task description. If a monster has always been assigned to the task, * the nature of the task can no longer be changed. *----------------------------------------------------------------------* CLASS lcl_view IMPLEMENTATION. METHOD make_column_editable. *--------------------------------------------------------------------* * ID_EDIT_CONTROL_FIELD Importing Type LVC_FNAME * IT_EDITABLE_FIELDS Importing Type LVC_T_FNAM * CT_DATA_TABLE Changing Type ANY TABLE *--------------------------------------------------------------------* * Local Variables DATA: ldo_table_line TYPE REF TO data. FIELD-SYMBOLS: TYPE any, TYPE lvc_t_styl, TYPE z4de_monster_order_fd_status. super->make_column_editable( EXPORTING id_edit_control_field = id_edit_control_field it_editable_fields = it_editable_fields CHANGING ct_data_table = ct_data_table ). *----------------------------------------------------------------------------------------------------------* * When the status is ""in progress"" gray out the task description fields. This does not work but it SHOULD. * My working theory is developers at SAP have been instructed to stop this working at all costs. *----------------------------------------------------------------------------------------------------------* * Dynamically create work area for looping through the table that was passed in *----------------------------------------------------------------------------------------------------------* CREATE DATA ldo_table_line LIKE LINE OF ct_data_table. ASSIGN ldo_table_line->* TO . LOOP AT ct_data_table ASSIGNING . ""Determine the Order Status ASSIGN COMPONENT 'FOULDEEDSTATUS' OF STRUCTURE TO . IF sy-subrc NE 0. CONTINUE. ENDIF. ""Based upon this, alter the CELLTAB nested table, to make the ""cell read only if need be IF NE 'C'.""Foul Deed has been Requested CONTINUE. ENDIF. ""Orders in this status cannot have the task description changed ASSIGN COMPONENT 'CELLTAB' OF STRUCTURE TO . IF sy-subrc NE 0. CONTINUE. ENDIF. READ TABLE ASSIGNING FIELD-SYMBOL() WITH KEY fieldname = 'TASKDESCRIPTION'. IF sy-subrc <> 0. INSERT VALUE #( fieldname = 'TASKDESCRIPTION' ) INTO TABLE . READ TABLE ASSIGNING WITH KEY fieldname = 'TASKDESCRIPTION'. ASSERT sy-subrc EQ 0. ENDIF. -style = cl_gui_alv_grid=>mc_style_disabled.""Read Only ENDLOOP.""Data Table ENDMETHOD. ""application_specific_changes METHOD ida_demo ##CALLED.""It is not this is just an example *--------------------------------------------------------------------* * Listing 10.39: - Coding SALV with IDA with Selection Criteria *--------------------------------------------------------------------* TRY. ""Tell the ALV what database table we want DATA(alv_display_object) = cl_salv_gui_table_ida=>create( iv_table_name = 'Z4TMONSTER_HEAD' ). ""Prepare the select-options DATA(range_table_collector) = NEW cl_salv_range_tab_collector( ). range_table_collector->add_ranges_for_name( iv_name = 'MONSTER_NUMBER' it_ranges = go_selections->s_numbr[] ). range_table_collector->add_ranges_for_name( iv_name = 'NAME' it_ranges = go_selections->s_name[] ). range_table_collector->get_collected_ranges( IMPORTING et_named_ranges = DATA(selection_option_table) ). ""Prepare any parameters from the selection screen DATA(parameter_factory) = alv_display_object->condition_factory( ). IF go_selections->p_model IS NOT INITIAL. DATA(parameter_object) = parameter_factory->equals( name = 'MODEL' value = go_selections->p_model ). ELSE. parameter_object = parameter_factory->covers_pattern( name = 'MODEL' pattern = '*' ). ENDIF. ""Tell the ALV about these restrictions alv_display_object->set_select_options( it_ranges = selection_option_table io_condition = parameter_object ). ""Off we go! alv_display_object->fullscreen( )->display( ). CATCH cx_salv_db_connection INTO DATA(connection_error). DATA(error_message) = connection_error->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_db_table_not_supported INTO DATA(not_supported). error_message = not_supported->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_ida_contract_violation INTO DATA(contract_violation). error_message = contract_violation->get_text( ). MESSAGE error_message TYPE 'E'. ENDTRY. *--------------------------------------------------------------------* * Listing 10.40: Coding SALV with IDA without Selection Criteria *--------------------------------------------------------------------* cl_salv_gui_table_ida=>create( 'Z4TMONSTER_HEAD' )->fullscreen( )->display( ). *--------------------------------------------------------------------* * Listing 10.41: Creating IDA SALV for CDS View (Acronym Soup) *--------------------------------------------------------------------* cl_salv_gui_table_ida=>create_for_cds_view( 'Z4CDS_MONSTER_DELIVERIES' )->fullscreen( )->display( ). ENDMETHOD. METHOD ida_demo2 ##CALLED.""It is not this is just an example *-------------------------------------------------------------------------------------* * Listing 10.44: Passing an instance of the Field Calculator into the IDA SALV instance *-------------------------------------------------------------------------------------* TRY. DATA(lo_calc_field_handler) = NEW lcl_ida_calculated_m_fields( ). ""Tell the ALV what database table we want PLUS calculated fields DATA(alv_display_object) = cl_salv_gui_table_ida=>create( iv_table_name = 'Z4TMONSTER_HEAD' io_calc_field_handler = lo_calc_field_handler ). ""Change a column heading, just for kicks TRY. alv_display_object->field_catalog( )->set_field_header_texts( iv_field_name = 'SANITY_DESCRIPTION' iv_header_text = 'Bonkers-Ness'(011) iv_tooltip_text = 'Tra La La'(012) iv_tooltip_text_long = 'Tra La La La La'(013) ). CATCH cx_salv_ida_unknown_name INTO DATA(unknown_name). DATA(error_message) = unknown_name->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_call_after_1st_display INTO DATA(multiple_calls). error_message = multiple_calls->get_text( ). MESSAGE error_message TYPE 'E'. ENDTRY. ""Prepare the select-options DATA(range_table_collector) = NEW cl_salv_range_tab_collector( ). range_table_collector->add_ranges_for_name( iv_name = 'MONSTER_NUMBER' it_ranges = go_selections->s_numbr[] ). range_table_collector->add_ranges_for_name( iv_name = 'NAME' it_ranges = go_selections->s_name[] ). range_table_collector->get_collected_ranges( IMPORTING et_named_ranges = DATA(selection_option_table) ). ""Prepare any parameters from the selection screen DATA(parameter_factory) = alv_display_object->condition_factory( ). IF go_selections->p_model IS NOT INITIAL. DATA(parameter_object) = parameter_factory->equals( name = 'MODEL' value = go_selections->p_model ). ELSE. parameter_object = parameter_factory->covers_pattern( name = 'MODEL' pattern = '*' ). ENDIF. ""Tell the ALV about the SELECTION-SCREEN restrictions alv_display_object->set_select_options( it_ranges = selection_option_table io_condition = parameter_object ). ""Off we go! alv_display_object->fullscreen( )->display( ). CATCH cx_salv_db_connection INTO DATA(connection_error). error_message = connection_error->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_db_table_not_supported INTO DATA(not_supported). error_message = not_supported->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_ida_contract_violation INTO DATA(contract_violation). error_message = contract_violation->get_text( ). MESSAGE error_message TYPE 'E'. ENDTRY. * One Haunted Castle can be found at 14.6 degrees Longtitude ENDMETHOD. ENDCLASS. ""lcl_view IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_controller IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_controller IMPLEMENTATION. METHOD constructor. super->constructor( ). mo_model = io_model. mo_view = io_view. ""Make the controller react to the views events SET HANDLER on_user_command FOR mo_view. ""If the model changes some data, then it needs to ""tell the controller, so it can tell the view ""to refresh the data SET HANDLER on_data_changed FOR mo_model. ENDMETHOD. ""constructor METHOD send_email. * Local Variables DATA: ld_program_name TYPE sy-repid, ld_short_title TYPE zexcel_sheet_title, ld_long_title TYPE char80, ld_tcode TYPE sy-tcode, lo_excel TYPE REF TO zcl_excel, lo_alv_grid TYPE REF TO cl_salv_table. ""Preconditions IF go_selections->p_send NE abap_true. RETURN. ENDIF. ld_short_title = sy-title. ld_long_title = sy-title. ld_program_name = sy-repid. ""bad news to pass this directly ld_tcode = 'ZMADL'. lo_alv_grid ?= mo_view->get_main_alv_object( ). ""Step 1 - convert internal table into an EXCEL object zcl_excel_emailer=>convert_salv_to_excel( EXPORTING id_title = ld_short_title io_salv = lo_alv_grid it_table = mo_model->mt_output_data[] CHANGING co_excel = lo_excel ). ""Step 2 - make any changes to the spreadsheet object that relate to ""this report TRY. adjust_spreadsheet( CHANGING co_excel = lo_excel ). CATCH zcx_excel. RETURN. ENDTRY. ""Step 3 - send the amended EXCEL object as an email zcl_excel_emailer=>send_excel_object( io_excel = lo_excel id_tcode = ld_tcode id_report_title = ld_long_title id_program_name = ld_program_name id_email = go_selections->p_email ). ENDMETHOD. METHOD adjust_spreadsheet. *--------------------------------------------------------------------* * Listing 11.06: Data Declarations *--------------------------------------------------------------------* DATA: column_number TYPE zexcel_cell_column, row_number TYPE zexcel_cell_row. *--------------------------------------------------------------------* * Listing 11.07: Looping Through All the Cells in a Spreadsheet *--------------------------------------------------------------------* DATA(active_worksheet) = co_excel->get_active_worksheet( ). DATA(number_of_rows) = active_worksheet->get_highest_row( ). DATA(number_of_columns) = active_worksheet->get_highest_column( ). DO number_of_columns TIMES. column_number = column_number + 1. DATA(column_as_letter) = zcl_excel_common=>convert_column2alpha( column_number ). row_number = 0. DO number_of_rows TIMES. ""#EC CI_NESTED. row_number = row_number + 1. *--------------------------------------------------------------------* * Listing 11.08: Finding the Style of a Spreadsheet Cell *--------------------------------------------------------------------* active_worksheet->get_cell( EXPORTING ip_column = column_as_letter ip_row = row_number IMPORTING ep_guid = DATA(cell_formatting_guid) ). TRY. DATA(style_information) = active_worksheet->excel->get_style_to_guid( cell_formatting_guid ). CATCH zcx_excel. CLEAR style_information. ENDTRY. *--------------------------------------------------------------------* * Listing 11.09: Setting a Cell to be Formatted Appropriately *--------------------------------------------------------------------* IF style_information-complete_style-number_format-format_code = '#,##0.00'. ""This is a currency amount, use the accounting conventions ""which are to have negative numbers as red in brackets, and show ""zero values as dashes, so as to focus the eye on the real numbers style_information-complete_style-number_format-format_code = '$#,##0.00;[Red]($#,##0.00);-' ##NO_TEXT. active_worksheet->change_cell_style( ip_column = column_as_letter ip_row = row_number ip_number_format_format_code = style_information-complete_style-number_format-format_code ). ENDIF.""Currency Amount ENDDO.""Rows ENDDO.""Columns *--------------------------------------------------------------------* * Listing 11.10: Programmatically Changing the Print Orientation to Landscape *--------------------------------------------------------------------* ""Page printing settings ""Margins are to be set to the values for ""narrow"". I just copy ""the values in the ""narrow"" option on the print preview active_worksheet->sheet_setup->set_page_margins( ip_top = '1.91' ip_bottom = '1.91' ip_left = '0.64' ip_right = '0.64' ip_header = '0.76' ip_footer = '0.76' ip_unit = 'cm' ) ##LITERAL. active_worksheet->sheet_setup->black_and_white = abap_true. ""Requirement is to fit all columns on one sheet ""You should turn ""fit to page"" on to activate fit_to_height and fit_to_width active_worksheet->sheet_setup->fit_to_page = abap_true. active_worksheet->sheet_setup->fit_to_width = 1. ""Used only if fit_to_page = TRUE active_worksheet->sheet_setup->orientation = zcl_excel_sheet_setup=>c_orientation_landscape. active_worksheet->sheet_setup->page_order = zcl_excel_sheet_setup=>c_ord_downthenover. active_worksheet->sheet_setup->paper_size = zcl_excel_sheet_setup=>c_papersize_a4. active_worksheet->sheet_setup->scale = 80. ""Used only if fit_to_page = FALSE active_worksheet->sheet_setup->horizontal_centered = abap_true. *--------------------------------------------------------------------* * Listing 11.11: Coding Header and Footer Print Settings *--------------------------------------------------------------------* ""Put Tab Name in Header Centre DATA(header_information) = VALUE zexcel_s_worksheet_head_foot( center_value = active_worksheet->get_title( ) center_font-size = 8 center_font-name = zcl_excel_style_font=>c_name_arial ). DATA(footer_information) = VALUE zexcel_s_worksheet_head_foot( ""Put last save date on footer left left_value = |{ sy-datum DATE = USER }| left_font = header_information-center_font ""Put Spreadsheet path and name in Footer Centre center_value = '&Z&F' ""Path / Filename center_font = header_information-center_font ""Put page X of Y on Footer Right right_value = 'page &P of &N' ""page x of y right_font = header_information-center_font ) ##no_text. active_worksheet->sheet_setup->set_header_footer( ip_odd_header = header_information ip_odd_footer = footer_information ). *--------------------------------------------------------------------* * Listing 11.12: Making the Header Row Repeat on Every Printed Sheet *--------------------------------------------------------------------* * Jonathon is a SKY BLUE PINK Monster *--------------------------------------------------------------------* active_worksheet->zif_excel_sheet_printsettings~set_print_repeat_rows( iv_rows_from = 1 iv_rows_to = 1 ). *--------------------------------------------------------------------* * Listing 11.14: Creating Colors to Use in a Spreadsheet *--------------------------------------------------------------------* DATA(green_style) = co_excel->add_new_style( ). green_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. green_style->fill->bgcolor-rgb = zcl_excel_style_color=>c_green. DATA(green_guid) = green_style->get_guid( ). DATA(red_style) = co_excel->add_new_style( ). red_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. red_style->fill->bgcolor-rgb = 'FFFF99FF'.""Soft Red (Pink Really) DATA(red_guid) = red_style->get_guid( ). DATA(yellow_style) = co_excel->add_new_style( ). yellow_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. yellow_style->fill->bgcolor-rgb = 'FFFF9900'. ""Orange - see ZDEMO_EXCEL21 DATA(yellow_guid) = yellow_style->get_guid( ). *--------------------------------------------------------------------* * Listing 11.15: Creating Conditional Formatting *--------------------------------------------------------------------* DATA: first_data_row TYPE sy-tabix, last_data_row TYPE sy-tabix. first_data_row = 2.""i.e. first row after header last_data_row = lines( mo_model->mt_output_data[] ) + 1. ""High Strength Monster - Green for 'Good' DATA(style_conditional) = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_rule_cellis. style_conditional->mode_cellis = VALUE #( formula = '""REALLY STRONG""' operator = zcl_excel_style_cond=>c_operator_equal cell_style = green_guid ). style_conditional->priority = 1. style_conditional->set_range( ip_start_column = strength_column_constant ip_start_row = first_data_row ip_stop_column = strength_column_constant ip_stop_row = last_data_row ). ""Low Strength Monster - Red for 'Bad' style_conditional = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_rule_cellis. style_conditional->mode_cellis = VALUE #( formula = '""LOW""' operator = zcl_excel_style_cond=>c_operator_equal cell_style = red_guid ). style_conditional->priority = 2. style_conditional->set_range( ip_start_column = strength_column_constant ip_start_row = first_data_row ip_stop_column = strength_column_constant ip_stop_row = last_data_row ). ""Medium Strength Monster - Yellow for 'nothing special' style_conditional = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_rule_cellis. style_conditional->mode_cellis = VALUE #( formula = '""MEDIUM""' operator = zcl_excel_style_cond=>c_operator_equal cell_style = yellow_guid ). style_conditional->priority = 3. style_conditional->set_range( ip_start_column = strength_column_constant ip_start_row = first_data_row ip_stop_column = strength_column_constant ip_stop_row = last_data_row ). *--------------------------------------------------------------------* * Listing 11.16: Conditional Formatting: Testing the Start of a String *--------------------------------------------------------------------* style_conditional = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_operator_beginswith. style_conditional->mode_cellis = VALUE #( formula = '1' operator = zcl_excel_style_cond=>c_operator_beginswith cell_style = red_guid ). *--------------------------------------------------------------------* * Listing 11.20: Conditional Formatting with Traffic Lights *--------------------------------------------------------------------* DATA: conditional_icon_settings TYPE zexcel_conditional_iconset, number_as_string TYPE string. ""Green if below 7 days conditional_icon_settings-cfvo1_type = zcl_excel_style_cond=>c_cfvo_type_number. conditional_icon_settings-cfvo1_value = '-9999'. ""Red if above 14 days conditional_icon_settings-cfvo2_type = zcl_excel_style_cond=>c_cfvo_type_number. number_as_string = 14. number_as_string = '-' && number_as_string. number_as_string = condense( number_as_string ). conditional_icon_settings-cfvo2_value = number_as_string. ""Yellow otherwise conditional_icon_settings-cfvo3_type = zcl_excel_style_cond=>c_cfvo_type_number. number_as_string = 7. number_as_string = '-' && number_as_string. number_as_string = condense( number_as_string ). conditional_icon_settings-cfvo3_value = number_as_string. ""Show the value as well as the ICON conditional_icon_settings-showvalue = zcl_excel_style_cond=>c_showvalue_true. ""We create a ""style"" to which we will add ""to the settings we just defined style_conditional = active_worksheet->add_new_style_cond( ). ""We are going to show ICONS style_conditional->rule = zcl_excel_style_cond=>c_rule_iconset. style_conditional->priority = 1. ""The ICONS are going to look like Traffic Lights conditional_icon_settings-iconset = zcl_excel_style_cond=>c_iconset_3trafficlights. style_conditional->mode_iconset = conditional_icon_settings. style_conditional->set_range( ip_start_column = age_column_constant ip_start_row = first_data_row ip_stop_column = age_column_constant ip_stop_row = last_data_row ). *--------------------------------------------------------------------* * Listing 11.21: Changing the Formatting to Make Negatives Look Positive *--------------------------------------------------------------------* ""We made all the monster ages negative earlier ""Now we have to show them as positive on the spreadsheet DATA: current_sheet_row TYPE zexcel_cell_row. current_sheet_row = 1. WHILE current_sheet_row LE last_data_row. current_sheet_row = current_sheet_row + 1. style_information-complete_style-number_format-format_code = '#,##0;#,##0'.""i.e. do not show minus sign active_worksheet->change_cell_style( ip_column = age_column_constant ip_row = current_sheet_row ip_number_format_format_code = style_information-complete_style-number_format-format_code ). ENDWHILE. *--------------------------------------------------------------------* * Listing 11.23: Setting Up the Pie Chart Data Worksheet *--------------------------------------------------------------------* active_worksheet = co_excel->add_new_worksheet( ). active_worksheet->set_title( 'Pie Chart Values'(014) ). ""In real life you would loop over an internal table to ""populate the data values for your monsters ""Pie Chart - Monster Types active_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Blue Monsters'(015) ). active_worksheet->set_cell( ip_column = 'A' ip_row = 2 ip_value = 'Red Monsters'(016) ). active_worksheet->set_cell( ip_column = 'A' ip_row = 3 ip_value = 'Green Monsters'(017) ). active_worksheet->set_cell( ip_column = 'A' ip_row = 4 ip_value = 'Sky Blue Pink Monsters'(018) ). ""Pie Chart - Number of each Monster Type active_worksheet->set_cell( ip_column = 'B' ip_row = 1 ip_value = 5 ). active_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 10 ). active_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 15 ). active_worksheet->set_cell( ip_column = 'B' ip_row = 4 ip_value = 20 ). *--------------------------------------------------------------------* * Listing 11.24: Setting Up the Pie Chart Worksheet *--------------------------------------------------------------------* ""Add the worksheet with the actual pie chart on it active_worksheet = co_excel->add_new_worksheet( ). active_worksheet->set_title( 'Monster Pie Chart'(019) ). DATA(monster_pie_chart) = NEW zcl_excel_graph_pie( ). ""Tell the Pie Chart where it gets it's data from monster_pie_chart->create_serie( ip_order = 0 ""The sheet the data comes from ip_sheet = 'Pie Chart Values'(014) ""Range where the labels live ip_lbl_from_col = 'A' ip_lbl_from_row = '1' ip_lbl_to_col = 'A' ip_lbl_to_row = '4' ""Range where the data values live ip_ref_from_col = 'B' ip_ref_from_row = '1' ip_ref_to_col = 'B' ip_ref_to_row = '4' ip_sername = |{ 'Monsters by Color'(020) }| ). monster_pie_chart->set_style( zcl_excel_graph=>c_style_15 ). ""Let us show the category names next to the pie chart monster_pie_chart->set_show_cat_name( zcl_excel_graph_pie=>c_show_true ). DATA(excel_drawing) = active_worksheet->excel->add_new_drawing( ip_type = zcl_excel_drawing=>type_chart ip_title = 'Monster Pie Chart'(019) ). excel_drawing->graph = monster_pie_chart. excel_drawing->graph_type = zcl_excel_drawing=>c_graph_pie. DATA: drawing_location_from_co_ords TYPE zexcel_drawing_location, drawing_location_to_co_ords TYPE zexcel_drawing_location. drawing_location_to_co_ords-row = 20. drawing_location_to_co_ords-col = 10. excel_drawing->set_position2( ip_from = drawing_location_from_co_ords ip_to = drawing_location_to_co_ords ). excel_drawing->set_media( ip_media_type = zcl_excel_drawing=>c_media_type_xml ). active_worksheet->add_drawing( excel_drawing ). ""The value sheet for the pie chart is hidden by default co_excel->set_active_sheet_index( 2 ). active_worksheet = co_excel->get_active_worksheet( ). active_worksheet->zif_excel_sheet_properties~hidden = zif_excel_sheet_properties=>c_hidden. ""We want the user to start on the first worksheet co_excel->set_active_sheet_index( 1 ). *--------------------------------------------------------------------* * Listing 11.32: Inserting Hyperlinks in a Spreadsheet *--------------------------------------------------------------------* DATA: hyperlink TYPE REF TO zcl_excel_hyperlink, hyperlink_url TYPE string, input_parameters TYPE string. active_worksheet = co_excel->get_active_worksheet( ). * Now we loop through the spreadsheet, adding hyperlinks so the user can drill * down into the original document in SAP current_sheet_row = first_data_row. LOOP AT mo_model->mt_output_data ASSIGNING FIELD-SYMBOL(). ""Drill down into the Monster Master Record IF -ordernumber IS NOT INITIAL. input_parameters = 'S_NUMBR-LOW=' && -ordernumber && ';'. hyperlink_url = zcl_excel_emailer=>build_hyperlink_url( id_transaction = 'ZMO3' id_parameters = input_parameters id_ok_code = '=ONLI' ). hyperlink = zcl_excel_hyperlink=>create_external_link( hyperlink_url ). active_worksheet->set_cell( ip_column = monster_column_constant ip_row = current_sheet_row ip_value = -ordernumber ip_hyperlink = hyperlink ). active_worksheet->change_cell_style( ip_column = monster_column_constant ip_row = current_sheet_row ip_font_color_rgb = zcl_excel_style_color=>c_blue ip_font_underline = abap_true ). ENDIF.""Do we have a Monster Number? current_sheet_row = current_sheet_row + 1. ENDLOOP.""Monster Table ENDMETHOD. METHOD change_edit_mode. *--------------------------------------------------------------------* * Listing 10.36: - User Command to Make a SALV Grid Editable *--------------------------------------------------------------------* DATA(underlying_alv_grid) = mo_view->get_alv_grid_object( ). IF underlying_alv_grid IS NOT BOUND. RETURN. ENDIF. underlying_alv_grid->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = DATA(field_catalog_table) ). make_column_editable( : EXPORTING id_column_name = 'MONSTER_HATS' CHANGING ct_fcat = field_catalog_table ), EXPORTING id_column_name = 'MONSTER_HEADS' CHANGING ct_fcat = field_catalog_table ). underlying_alv_grid->set_frontend_fieldcatalog( field_catalog_table ). underlying_alv_grid->set_frontend_layout( VALUE #( stylefname = 'CELLTAB' ) ). underlying_alv_grid->refresh_table_display( ). cl_gui_cfw=>flush( ). ENDMETHOD. METHOD download_spreadseet. *--------------------------------------------------------------------* * Listing 11.28: - Uploading an Excel Template *--------------------------------------------------------------------* * Local Variables DATA: lo_alv_grid TYPE REF TO cl_salv_table, ls_template TYPE ztexcel_template, lo_excel_reader TYPE REF TO zif_excel_reader. TRY. IF go_selections->p_macro = abap_true. lo_excel_reader = NEW zcl_excel_reader_xlsm( ). ""Retrieve template from the database SELECT SINGLE * FROM ztexcel_template INTO CORRESPONDING FIELDS OF ls_template WHERE template_name = 'MONSTER_EXAMPLE'. DATA(lo_excel) = lo_excel_reader->load( ls_template-raw_data ). DATA(lo_worksheet) = lo_excel->get_active_worksheet( ). ENDIF.""Do we want to use a macro? *-------------------------------------------------------------------------------------------------------------------* * In one Haunted Castle there is the ghost who loves to join parties. Her ghost has been seen at functions in the * ballroom, clothed in a ballgown of that era *-------------------------------------------------------------------------------------------------------------------* * Listing 11.05: - Transforming a Report Object into an Excel Object * AND * Listing 11.29: - Filling the Macro-Enabled Worksheet with Data *--------------------------------------------------------------------* * Convert SALV object into EXCEL object *--------------------------------------------------------------------* lo_alv_grid ?= mo_view->get_main_alv_object( ). DATA(lo_converter) = NEW zcl_excel_converter( ). lo_converter->convert( EXPORTING io_alv = lo_alv_grid it_table = mo_model->mt_output_data[] i_table = abap_true i_style_table = zcl_excel_table=>builtinstyle_medium2 io_worksheet = lo_worksheet CHANGING co_excel = lo_excel ). ""Make any changes to the spreadsheet object that relate to this report adjust_spreadsheet( CHANGING co_excel = lo_excel ). CATCH zcx_excel. RETURN. ENDTRY. *--------------------------------------------------------------------* * Listing 11.04: - Downloading an EXCEL Spreadsheet *--------------------------------------------------------------------* * Choose where to download EXCEL spreadsheet to front end *--------------------------------------------------------------------* DATA: lt_rawdata TYPE solix_tab, ld_bytecount TYPE i, ld_filename TYPE string, ld_path TYPE string, ld_fullpath TYPE string. ""From now on this is all bog standard SAP cl_gui_frontend_services=>file_save_dialog( EXPORTING window_title = |{ 'Choose where to save file'(021) }| default_extension = 'XLSX' "" Default Extension CHANGING filename = ld_filename "" File Name to Save path = ld_path "" Path to File fullpath = ld_fullpath "" Path + File Name EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 OTHERS = 4 ). IF sy-subrc <> 0. RETURN. ENDIF. *--------------------------------------------------------------------* * Listing 11.30: - Making sure the Spreadsheet File is Saved Correctly *--------------------------------------------------------------------* * Convert to XML *--------------------------------------------------------------------* DATA: ld_xml_file TYPE xstring, lo_excel_writer TYPE REF TO zif_excel_writer, lf_macro_enabled TYPE abap_bool. TRY. IF lo_excel->zif_excel_book_vba_project~codename_pr IS NOT INITIAL. lf_macro_enabled = abap_true. ELSE. lf_macro_enabled = abap_false. ENDIF. IF ld_fullpath CS 'XLSM' AND lf_macro_enabled = abap_false. REPLACE 'XLSM' WITH 'XLSX' INTO ld_fullpath. ELSEIF ld_fullpath CS 'XLSX' AND lf_macro_enabled = abap_true. REPLACE 'XLSX' WITH 'XLSM' INTO ld_fullpath. ELSEIF ld_fullpath CS 'XLSX' OR ld_fullpath CS 'XLSM'. ""Do nothing - everything is fine ELSEIF ld_fullpath CS 'XLS' AND lf_macro_enabled = abap_false. REPLACE 'XLS' WITH 'XLSX' INTO ld_fullpath. ELSEIF ld_fullpath CS 'XLS' AND lf_macro_enabled = abap_true. REPLACE 'XLS' WITH 'XLSM' INTO ld_fullpath. ENDIF. IF ld_fullpath CS 'XLSM'. lo_excel_writer = NEW zcl_excel_writer_xlsm( ). ELSE. lo_excel_writer = NEW zcl_excel_writer_2007( ). ENDIF. ld_xml_file = lo_excel_writer->write_file( lo_excel ). *--------------------------------------------------------------------* * Download to Front End *--------------------------------------------------------------------* lt_rawdata = cl_bcs_convert=>xstring_to_solix( ld_xml_file ). ld_bytecount = xstrlen( ld_xml_file ). cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = ld_bytecount filename = ld_fullpath filetype = 'BIN' CHANGING data_tab = lt_rawdata ). CATCH zcx_excel INTO DATA(lo_exception). DATA(ld_error) = lo_exception->get_text( ). MESSAGE ld_error TYPE 'E'. ENDTRY. ENDMETHOD. METHOD on_user_command. *--------------------------------------------------------------------* * FOR EVENT added_function OF cl_salv_events * IMPORTING ed_user_command * ed_row * ed_column. *--------------------------------------------------------------------* CASE ed_user_command. WHEN 'ZEDIT'. ""A command to change the edit mode change_edit_mode( ). WHEN 'ZEXCEL'. ""Command to download the spreadsheet to the local machine download_spreadseet( ). ENDCASE.""User Command mo_model->user_command( id_user_command = ed_user_command id_column = ed_column id_row = ed_row ). mo_view->refresh_display( ). *----------------------------------------------------------------------------------------------------------* * At the time of the murder the Green Monster was in the castle directly to the west of the castle that the * Sky-Blue Pink Monster was in *----------------------------------------------------------------------------------------------------------* ENDMETHOD.""User Command / Controller METHOD on_data_changed. mo_view->refresh_display( ). ENDMETHOD. ""on_data_changed METHOD make_column_editable. *--------------------------------------------------------------------* * Listng 10.38: - MAKE_COLUMN_EDITABLE Method *--------------------------------------------------------------------* * IMPORTING id_column_name TYPE dd03l-fieldname * CHANGING ct_fcat TYPE lvc_t_fcat. *--------------------------------------------------------------------* LOOP AT mo_model->mt_output_data ASSIGNING FIELD-SYMBOL(). READ TABLE -celltab ASSIGNING FIELD-SYMBOL() WITH KEY fieldname = id_column_name. IF sy-subrc <> 0. INSERT VALUE #( fieldname = id_column_name ) INTO TABLE -celltab. READ TABLE -celltab ASSIGNING WITH KEY fieldname = id_column_name. ASSERT sy-subrc EQ 0. ENDIF. IF -style EQ cl_gui_alv_grid=>mc_style_enabled. -style = cl_gui_alv_grid=>mc_style_disabled. ELSE. -style = cl_gui_alv_grid=>mc_style_enabled. ENDIF. ENDLOOP. LOOP AT ct_fcat ASSIGNING FIELD-SYMBOL() WHERE fieldname = id_column_name. -edit = abap_true. ENDLOOP. ENDMETHOD.""make column editable ENDCLASS. ""lcl_controller IMPLEMENTATION *----------------------------------------------------------------------------* * Listing 10.43: - IDA Class to Calculate Extra Field Values – Implementation *----------------------------------------------------------------------------* CLASS lcl_ida_calculated_m_fields IMPLEMENTATION. METHOD constructor. mo_monster_model = NEW #( ). ENDMETHOD. METHOD if_salv_ida_calc_field_handler~get_calc_field_structure. ""Define additional fields by returning the structure description DATA transient_fields TYPE z4st_monster_header_dt. ro_calc_field_structure ?= cl_abap_structdescr=>describe_by_data( transient_fields ). ENDMETHOD. METHOD if_salv_ida_calc_field_handler~get_requested_fields. ""Define which fields are required for the calculation of the additional fields DATA field_name TYPE fieldname. ""To find the sanity description, you need the sanity percentage IF line_exists( its_calc_field_name[ table_line = 'SANITY_DESCRIPTION' ] ). field_name = 'SANITY_PERCENTAGE'. INSERT field_name INTO TABLE rts_db_field_name. ENDIF. ENDMETHOD. METHOD if_salv_ida_calc_field_handler~start_page. CLEAR ev_cancel_calculation. ""Buffer which of the calculated fields are displayed ""--> later calculate values only for these fields to save performance mt_calc_field_names[] = its_calc_field_name[]. ENDMETHOD. METHOD if_salv_ida_calc_field_handler~calculate_line. DATA: all_fields TYPE z4sc_monster_header_ex, persistent_fields TYPE z4t_monster_head, transient_fields TYPE z4st_monster_header_dt. CLEAR es_calculated_fields. persistent_fields = is_data_base_line. all_fields = CORRESPONDING #( persistent_fields ) ##ENH_OK. IF line_exists( mt_calc_field_names[ table_line = 'SANITY_DESCRIPTION' ] ). TRY. mo_monster_model->derive_header_fields( CHANGING cs_monster_header = all_fields ). transient_fields = CORRESPONDING #( all_fields ). CATCH zcx_4_monster_exceptions. RETURN. ENDTRY. ENDIF. es_calculated_fields = transient_fields. ENDMETHOD. METHOD if_salv_ida_calc_field_handler~end_page ##NEEDED. ""Do Nothing. ENDMETHOD. ENDCLASS. ",12229,False,2264.5395351454836,median "CLASS zcl_abapgit_object_tabl DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_object . ALIASES mo_files FOR zif_abapgit_object~mo_files . PROTECTED SECTION. TYPES: BEGIN OF ty_segment_definition, segmentheader TYPE edisegmhd, segmentdefinition TYPE edisegmdef, segmentstructures TYPE STANDARD TABLE OF edisegstru WITH DEFAULT KEY, END OF ty_segment_definition. TYPES: ty_segment_definitions TYPE STANDARD TABLE OF ty_segment_definition WITH DEFAULT KEY. TYPES: BEGIN OF ty_tabl_extras, tddat TYPE tddat, END OF ty_tabl_extras. ""! get additional data like table authorization group ""! @parameter iv_tabname | name of the table METHODS read_extras IMPORTING iv_tabname TYPE ddobjname RETURNING VALUE(rs_tabl_extras) TYPE ty_tabl_extras. ""! Update additional data ""! @parameter iv_tabname | name of the table ""! @parameter is_tabl_extras | additional table data METHODS update_extras IMPORTING iv_tabname TYPE ddobjname is_tabl_extras TYPE ty_tabl_extras. ""! Delete additional data ""! @parameter iv_tabname | name of the table METHODS delete_extras IMPORTING iv_tabname TYPE ddobjname. ""! Serialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @raising zcx_abapgit_exception | Exceptions METHODS serialize_idoc_segment IMPORTING io_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception. ""! Deserialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @parameter iv_package | Target package ""! @parameter rv_deserialized | It's a segment and was desserialized ""! @raising zcx_abapgit_exception | Exceptions METHODS deserialize_idoc_segment IMPORTING io_xml TYPE REF TO zif_abapgit_xml_input iv_package TYPE devclass RETURNING VALUE(rv_deserialized) TYPE abap_bool RAISING zcx_abapgit_exception. ""! Delete the IDoc Segment type if exists ""! @parameter rv_deleted | It's a segment and was deleted ""! @raising zcx_abapgit_exception | Exceptions METHODS delete_idoc_segment RETURNING VALUE(rv_deleted) TYPE abap_bool RAISING zcx_abapgit_exception. PRIVATE SECTION. TYPES: ty_dd03p_tt TYPE STANDARD TABLE OF dd03p . TYPES: BEGIN OF ty_dd02_text, ddlanguage TYPE dd02t-ddlanguage, ddtext TYPE dd02t-ddtext, END OF ty_dd02_text, ty_dd02_texts TYPE STANDARD TABLE OF ty_dd02_text. CONSTANTS c_longtext_id_tabl TYPE dokil-id VALUE 'TB' ##NO_TEXT. CONSTANTS: BEGIN OF c_s_dataname, segment_definition TYPE string VALUE 'SEGMENT_DEFINITION', tabl_extras TYPE string VALUE 'TABL_EXTRAS', END OF c_s_dataname. METHODS clear_dd03p_fields CHANGING !ct_dd03p TYPE ty_dd03p_tt . ""! Check if structure is an IDoc segment ""! @parameter rv_is_idoc_segment | It's an IDoc segment or not METHODS is_idoc_segment RETURNING VALUE(rv_is_idoc_segment) TYPE abap_bool. METHODS clear_dd03p_fields_common CHANGING !cs_dd03p TYPE dd03p . METHODS clear_dd03p_fields_dataelement CHANGING !cs_dd03p TYPE dd03p . METHODS: serialize_texts IMPORTING io_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception, deserialize_texts IMPORTING io_xml TYPE REF TO zif_abapgit_xml_input is_dd02v TYPE dd02v RAISING zcx_abapgit_exception, is_db_table_category IMPORTING iv_tabclass TYPE dd02l-tabclass RETURNING VALUE(rv_is_db_table_type) TYPE dd02l-tabclass. ENDCLASS. CLASS zcl_abapgit_object_tabl IMPLEMENTATION. METHOD clear_dd03p_fields. CONSTANTS lc_comptype_dataelement TYPE comptype VALUE 'E'. DATA: lv_masklen TYPE c LENGTH 4. FIELD-SYMBOLS: TYPE dd03p. * remove nested structures DELETE ct_dd03p WHERE depth <> '00'. * remove fields from .INCLUDEs DELETE ct_dd03p WHERE adminfield <> '0'. LOOP AT ct_dd03p ASSIGNING WHERE NOT rollname IS INITIAL. clear_dd03p_fields_common( CHANGING cs_dd03p = ). lv_masklen = -masklen. IF lv_masklen = '' OR NOT lv_masklen CO '0123456789'. * make sure the field contains valid data, or the XML will dump CLEAR -masklen. ENDIF. IF -comptype = lc_comptype_dataelement. clear_dd03p_fields_dataelement( CHANGING cs_dd03p = ). ENDIF. IF -shlporigin = 'D'. * search help from domain CLEAR: -shlpfield, -shlpname. ENDIF. * XML output assumes correct field content IF -routputlen = ' '. CLEAR -routputlen. ENDIF. ENDLOOP. ENDMETHOD. METHOD clear_dd03p_fields_common. CLEAR: cs_dd03p-ddlanguage, cs_dd03p-dtelmaster, cs_dd03p-logflag, cs_dd03p-ddtext, cs_dd03p-reservedte, cs_dd03p-reptext, cs_dd03p-scrtext_s, cs_dd03p-scrtext_m, cs_dd03p-scrtext_l. ENDMETHOD. METHOD clear_dd03p_fields_dataelement. * type specified via data element CLEAR: cs_dd03p-domname, cs_dd03p-inttype, cs_dd03p-intlen, cs_dd03p-mask, cs_dd03p-memoryid, cs_dd03p-headlen, cs_dd03p-scrlen1, cs_dd03p-scrlen2, cs_dd03p-scrlen3, cs_dd03p-datatype, cs_dd03p-leng, cs_dd03p-outputlen, cs_dd03p-deffdname, cs_dd03p-convexit, cs_dd03p-entitytab, cs_dd03p-dommaster, cs_dd03p-domname3l, cs_dd03p-decimals, cs_dd03p-lowercase, cs_dd03p-signflag. ENDMETHOD. METHOD delete_extras. DELETE FROM tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD delete_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. IF is_idoc_segment( ) = abap_false. rv_deleted = abap_false. RETURN. ""previous XML version or no IDoc segment ENDIF. rv_deleted = abap_true. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_DELETE' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD deserialize_idoc_segment. DATA lv_result LIKE sy-subrc. DATA lt_segment_definitions TYPE ty_segment_definitions. DATA lv_package TYPE devclass. DATA lv_uname TYPE sy-uname. FIELD-SYMBOLS TYPE ty_segment_definition. rv_deserialized = abap_false. TRY. io_xml->read( EXPORTING iv_name = c_s_dataname-segment_definition CHANGING cg_data = lt_segment_definitions ). CATCH zcx_abapgit_exception. RETURN. ""previous XML version or no IDoc segment ENDTRY. IF lines( lt_segment_definitions ) = 0. RETURN. ""no IDoc segment ENDIF. rv_deserialized = abap_true. lv_package = iv_package. LOOP AT lt_segment_definitions ASSIGNING . -segmentheader-presp = -segmentheader-pwork = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = -segmentheader-segtyp IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. CALL FUNCTION 'SEGMENT_CREATE' IMPORTING segmentdefinition = -segmentdefinition TABLES segmentstructure = -segmentstructures CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. ELSE. CALL FUNCTION 'SEGMENT_MODIFY' CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. CALL FUNCTION 'SEGMENTDEFINITION_MODIFY' TABLES segmentstructure = -segmentstructures CHANGING segmentdefinition = -segmentdefinition EXCEPTIONS OTHERS = 1. ENDIF. ENDIF. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDLOOP. lv_uname = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_test_modus = abap_false wi_tadir_pgmid = 'R3TR' wi_tadir_object = ms_item-obj_type wi_tadir_obj_name = ms_item-obj_name wi_tadir_author = lv_uname wi_tadir_devclass = iv_package wi_tadir_masterlang = mv_language iv_set_edtflag = abap_true iv_delflag = abap_false EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD deserialize_texts. DATA: lv_name TYPE ddobjname, ls_dd02v_tmp TYPE dd02v, lt_i18n_langs TYPE TABLE OF langu, lt_dd02_texts TYPE ty_dd02_texts. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. lv_name = ms_item-obj_name. io_xml->read( EXPORTING iv_name = 'I18N_LANGS' CHANGING cg_data = lt_i18n_langs ). io_xml->read( EXPORTING iv_name = 'DD02_TEXTS' CHANGING cg_data = lt_dd02_texts ). SORT lt_i18n_langs. SORT lt_dd02_texts BY ddlanguage. "" Optimization LOOP AT lt_i18n_langs ASSIGNING . "" Table description ls_dd02v_tmp = is_dd02v. READ TABLE lt_dd02_texts ASSIGNING WITH KEY ddlanguage = . IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |DD02_TEXTS cannot find lang { } in XML| ). ENDIF. MOVE-CORRESPONDING TO ls_dd02v_tmp. CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v_tmp EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDLOOP. ENDMETHOD. METHOD is_db_table_category. "" values from domain TABCLASS rv_is_db_table_type = boolc( iv_tabclass = 'TRANSP' OR iv_tabclass = 'CLUSTER' OR iv_tabclass = 'POOL' ). ENDMETHOD. METHOD is_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. lv_segment_type = ms_item-obj_name. SELECT SINGLE segtyp FROM edisegment INTO lv_segment_type WHERE segtyp = lv_segment_type. rv_is_idoc_segment = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD read_extras. SELECT SINGLE * FROM tddat INTO rs_tabl_extras-tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD serialize_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. DATA lv_devclass TYPE devclass. DATA lt_segmentdefinitions TYPE STANDARD TABLE OF edisegmdef. DATA ls_segment_definition TYPE ty_segment_definition. DATA lt_segment_definitions TYPE ty_segment_definitions. FIELD-SYMBOLS: TYPE edisegmdef. IF is_idoc_segment( ) = abap_false. RETURN. ENDIF. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result TABLES segmentdefinition = lt_segmentdefinitions EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. LOOP AT lt_segmentdefinitions ASSIGNING . CLEAR ls_segment_definition. CALL FUNCTION 'SEGMENTDEFINITION_READ' EXPORTING segmenttyp = -segtyp IMPORTING result = lv_result devclass = lv_devclass segmentheader = ls_segment_definition-segmentheader segmentdefinition = ls_segment_definition-segmentdefinition TABLES segmentstructure = ls_segment_definition-segmentstructures CHANGING version = -version EXCEPTIONS no_authority = 1 segment_not_existing = 2 OTHERS = 3. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentdefinition ). zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentheader ). APPEND ls_segment_definition TO lt_segment_definitions. ENDLOOP. io_xml->add( iv_name = c_s_dataname-segment_definition ig_data = lt_segment_definitions ). ENDMETHOD. METHOD serialize_texts. DATA: lv_name TYPE ddobjname, lv_index TYPE i, ls_dd02v TYPE dd02v, lt_dd02_texts TYPE ty_dd02_texts, lt_i18n_langs TYPE TABLE OF langu. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. IF io_xml->i18n_params( )-main_language_only = abap_true. RETURN. ENDIF. lv_name = ms_item-obj_name. "" Collect additional languages, skip main lang - it was serialized already SELECT DISTINCT ddlanguage AS langu INTO TABLE lt_i18n_langs FROM dd02v WHERE tabname = lv_name AND ddlanguage <> mv_language. ""#EC CI_SUBRC LOOP AT lt_i18n_langs ASSIGNING . lv_index = sy-tabix. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = IMPORTING dd02v_wa = ls_dd02v EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0 OR ls_dd02v-ddlanguage IS INITIAL. DELETE lt_i18n_langs INDEX lv_index. "" Don't save this lang CONTINUE. ENDIF. APPEND INITIAL LINE TO lt_dd02_texts ASSIGNING . MOVE-CORRESPONDING ls_dd02v TO . ENDLOOP. SORT lt_i18n_langs ASCENDING. SORT lt_dd02_texts BY ddlanguage ASCENDING. IF lines( lt_i18n_langs ) > 0. io_xml->add( iv_name = 'I18N_LANGS' ig_data = lt_i18n_langs ). io_xml->add( iv_name = 'DD02_TEXTS' ig_data = lt_dd02_texts ). ENDIF. ENDMETHOD. METHOD update_extras. IF is_tabl_extras-tddat IS INITIAL. delete_extras( iv_tabname ). ELSE. MODIFY tddat FROM is_tabl_extras-tddat. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~changed_by. TYPES: BEGIN OF ty_data, as4user TYPE dd02l-as4user, as4date TYPE dd02l-as4date, as4time TYPE dd02l-as4time, END OF ty_data. DATA: lt_data TYPE STANDARD TABLE OF ty_data WITH DEFAULT KEY, ls_data LIKE LINE OF lt_data. SELECT as4user as4date as4time FROM dd02l INTO TABLE lt_data WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd09l WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd12l WHERE sqltab = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SORT lt_data BY as4date DESCENDING as4time DESCENDING. READ TABLE lt_data INDEX 1 INTO ls_data. IF sy-subrc = 0. rv_user = ls_data-as4user. ELSE. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lv_objname TYPE rsedd0-ddobjname, lv_no_ask TYPE abap_bool, lv_subrc TYPE sy-subrc, BEGIN OF ls_dd02l, tabname TYPE dd02l-tabname, tabclass TYPE dd02l-tabclass, sqltab TYPE dd02l-sqltab, END OF ls_dd02l. IF zif_abapgit_object~exists( ) = abap_false. "" Proxies e.g. delete on its own, nothing todo here then. RETURN. ENDIF. lv_objname = ms_item-obj_name. IF delete_idoc_segment( ) = abap_false. lv_no_ask = abap_true. SELECT SINGLE tabname tabclass sqltab FROM dd02l INTO CORRESPONDING FIELDS OF ls_dd02l WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. IF sy-subrc = 0 AND is_db_table_category( ls_dd02l-tabclass ) = abap_true. CALL FUNCTION 'DD_EXISTS_DATA' EXPORTING reftab = ls_dd02l-sqltab tabclass = ls_dd02l-tabclass tabname = ls_dd02l-tabname IMPORTING subrc = lv_subrc EXCEPTIONS missing_reftab = 1 sql_error = 2 buffer_overflow = 3 unknown_error = 4 OTHERS = 5. IF sy-subrc = 0 AND lv_subrc = 0. lv_no_ask = abap_false. ENDIF. ENDIF. delete_ddic( iv_objtype = 'T' iv_no_ask = lv_no_ask ). delete_longtexts( c_longtext_id_tabl ). delete_extras( lv_objname ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lv_name TYPE ddobjname, lv_tname TYPE trobj_name, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE TABLE OF dd03p, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, ls_dd17v LIKE LINE OF lt_dd17v, lt_secondary LIKE lt_dd17v, lt_dd35v TYPE TABLE OF dd35v, lt_dd36m TYPE dd36mttyp, ls_dd12v LIKE LINE OF lt_dd12v, lv_refs TYPE abap_bool, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: TYPE dd03p, TYPE any. IF deserialize_idoc_segment( io_xml = io_xml iv_package = iv_package ) = abap_false. io_xml->read( EXPORTING iv_name = 'DD02V' CHANGING cg_data = ls_dd02v ). io_xml->read( EXPORTING iv_name = 'DD09L' CHANGING cg_data = ls_dd09l ). io_xml->read( EXPORTING iv_name = 'DD03P_TABLE' CHANGING cg_data = lt_dd03p ). ASSIGN COMPONENT 'ROWORCOLST' OF STRUCTURE ls_dd09l TO . IF sy-subrc = 0 AND IS INITIAL. = 'C'. ""Reverse fix from serialize ENDIF. "" DDIC Step: Replace REF TO class/interface with generic reference to avoid cyclic dependency LOOP AT lt_dd03p ASSIGNING WHERE datatype = 'REF'. IF iv_step = zif_abapgit_object=>gc_step_id-ddic. -rollname = 'OBJECT'. ELSE. lv_refs = abap_true. ENDIF. ENDLOOP. io_xml->read( EXPORTING iv_name = 'DD05M_TABLE' CHANGING cg_data = lt_dd05m ). io_xml->read( EXPORTING iv_name = 'DD08V_TABLE' CHANGING cg_data = lt_dd08v ). io_xml->read( EXPORTING iv_name = 'DD12V' CHANGING cg_data = lt_dd12v ). io_xml->read( EXPORTING iv_name = 'DD17V' CHANGING cg_data = lt_dd17v ). io_xml->read( EXPORTING iv_name = 'DD35V_TALE' CHANGING cg_data = lt_dd35v ). io_xml->read( EXPORTING iv_name = 'DD36M' CHANGING cg_data = lt_dd36m ). "" DDIC Step: Remove references to search helps and foreign keys IF iv_step = zif_abapgit_object=>gc_step_id-ddic. CLEAR: lt_dd08v, lt_dd35v, lt_dd36m. ENDIF. IF iv_step = zif_abapgit_object=>gc_step_id-late AND lv_refs = abap_false AND lines( lt_dd35v ) = 0 AND lines( lt_dd08v ) = 0. RETURN. "" already active ENDIF. corr_insert( iv_package = iv_package ig_object_class = 'DICT' ). lv_name = ms_item-obj_name. "" type conversion CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. zcl_abapgit_objects_activation=>add_item( ms_item ). * handle indexes LOOP AT lt_dd12v INTO ls_dd12v. * todo, call corr_insert? CLEAR lt_secondary. LOOP AT lt_dd17v INTO ls_dd17v WHERE sqltab = ls_dd12v-sqltab AND indexname = ls_dd12v-indexname. APPEND ls_dd17v TO lt_secondary. ENDLOOP. CALL FUNCTION 'DDIF_INDX_PUT' EXPORTING name = ls_dd12v-sqltab id = ls_dd12v-indexname dd12v_wa = ls_dd12v TABLES dd17v_tab = lt_secondary EXCEPTIONS indx_not_found = 1 name_inconsistent = 2 indx_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. CALL FUNCTION 'DD_DD_TO_E071' EXPORTING type = 'INDX' name = ls_dd12v-sqltab id = ls_dd12v-indexname IMPORTING obj_name = lv_tname. zcl_abapgit_objects_activation=>add( iv_type = 'INDX' iv_name = lv_tname ). ENDLOOP. deserialize_texts( io_xml = io_xml is_dd02v = ls_dd02v ). deserialize_longtexts( io_xml ). io_xml->read( EXPORTING iv_name = c_s_dataname-tabl_extras CHANGING cg_data = ls_extras ). update_extras( iv_tabname = lv_name is_tabl_extras = ls_extras ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_tabname TYPE dd02l-tabname. lv_tabname = ms_item-obj_name. "" Check nametab because it's fast CALL FUNCTION 'DD_GET_NAMETAB_HEADER' EXPORTING tabname = lv_tabname EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc <> 0. "" Check for new, inactive, or modified versions that might not be in nametab SELECT SINGLE tabname FROM dd02l INTO lv_tabname WHERE tabname = lv_tabname. ENDIF. rv_bool = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. DATA: li_local_version_output TYPE REF TO zif_abapgit_xml_output, li_local_version_input TYPE REF TO zif_abapgit_xml_input. CREATE OBJECT li_local_version_output TYPE zcl_abapgit_xml_output. zif_abapgit_object~serialize( li_local_version_output ). CREATE OBJECT li_local_version_input TYPE zcl_abapgit_xml_input EXPORTING iv_xml = li_local_version_output->render( ). CREATE OBJECT ri_comparator TYPE zcl_abapgit_object_tabl_compar EXPORTING ii_local = li_local_version_input. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-ddic TO rt_steps. APPEND zif_abapgit_object=>gc_step_id-late TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). rs_metadata-ddic = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'ESDICT' iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. jump_se11( ). ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lv_name TYPE ddobjname, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE ty_dd03p_tt, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, lt_dd35v TYPE TABLE OF dd35v, lv_index LIKE sy-index, lt_dd36m TYPE dd36mttyp, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: LIKE LINE OF lt_dd12v, LIKE LINE OF lt_dd05m, LIKE LINE OF lt_dd36m, TYPE any. lv_name = ms_item-obj_name. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = mv_language IMPORTING dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd12v_tab = lt_dd12v dd17v_tab = lt_dd17v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_TABL_GET' ). ENDIF. IF ls_dd02v IS INITIAL. RETURN. "" object does not exits ENDIF. CLEAR: ls_dd02v-as4user, ls_dd02v-as4date, ls_dd02v-as4time. * reset numeric field, so XML does not crash IF ls_dd02v-prozpuff = ''. CLEAR ls_dd02v-prozpuff. ENDIF. IF ls_dd02v-datmin = ''. CLEAR ls_dd02v-datmin. ENDIF. IF ls_dd02v-datmax = ''. CLEAR ls_dd02v-datmax. ENDIF. IF ls_dd02v-datavg = ''. CLEAR ls_dd02v-datavg. ENDIF. CLEAR: ls_dd09l-as4user, ls_dd09l-as4date, ls_dd09l-as4time. ASSIGN COMPONENT 'ROWORCOLST' OF STRUCTURE ls_dd09l TO . IF sy-subrc = 0 AND = 'C'. CLEAR . ""To avoid diff errors. This field doesn't exists in all releases ENDIF. LOOP AT lt_dd12v ASSIGNING . CLEAR: -as4user, -as4date, -as4time. ENDLOOP. clear_dd03p_fields( CHANGING ct_dd03p = lt_dd03p ). * remove foreign keys inherited from .INCLUDEs DELETE lt_dd08v WHERE noinherit = 'N'. LOOP AT lt_dd05m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd08v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd05m INDEX lv_index. ENDIF. ENDLOOP. * remove inherited search helps DELETE lt_dd35v WHERE shlpinher = abap_true. LOOP AT lt_dd36m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd35v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd36m INDEX lv_index. ENDIF. ENDLOOP. io_xml->add( iv_name = 'DD02V' ig_data = ls_dd02v ). IF NOT ls_dd09l IS INITIAL. io_xml->add( iv_name = 'DD09L' ig_data = ls_dd09l ). ENDIF. io_xml->add( iv_name = 'DD03P_TABLE' ig_data = lt_dd03p ). io_xml->add( iv_name = 'DD05M_TABLE' ig_data = lt_dd05m ). io_xml->add( iv_name = 'DD08V_TABLE' ig_data = lt_dd08v ). io_xml->add( iv_name = 'DD12V' ig_data = lt_dd12v ). io_xml->add( iv_name = 'DD17V' ig_data = lt_dd17v ). io_xml->add( iv_name = 'DD35V_TALE' ig_data = lt_dd35v ). io_xml->add( iv_name = 'DD36M' ig_data = lt_dd36m ). serialize_texts( io_xml ). serialize_longtexts( ii_xml = io_xml iv_longtext_id = c_longtext_id_tabl ). serialize_idoc_segment( io_xml ). ls_extras = read_extras( lv_name ). io_xml->add( iv_name = c_s_dataname-tabl_extras ig_data = ls_extras ). ENDMETHOD. ENDCLASS. ",8430,False,1902.8872061307538,median "//////////////////////////////////////////////////////////////////////////////// // // ADOBE SYSTEMS INCORPORATED // Copyright 2008 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 spark.components { import flash.display.BlendMode; import flash.display.DisplayObject; import flash.geom.Rectangle; import mx.core.FlexVersion; import mx.styles.IAdvancedStyleClient; import mx.core.IFlexModule; import mx.core.IFontContextComponent; import mx.core.IUIComponent; import mx.core.IUITextField; import mx.core.IVisualElement; import mx.core.IVisualElementContainer; import mx.core.UIComponent; import mx.core.mx_internal; import mx.events.FlexEvent; import mx.graphics.shaderClasses.ColorBurnShader; import mx.graphics.shaderClasses.ColorDodgeShader; import mx.graphics.shaderClasses.ColorShader; import mx.graphics.shaderClasses.ExclusionShader; import mx.graphics.shaderClasses.HueShader; import mx.graphics.shaderClasses.LuminosityShader; import mx.graphics.shaderClasses.SaturationShader; import mx.graphics.shaderClasses.SoftLightShader; import mx.styles.ISimpleStyleClient; import mx.styles.IStyleClient; import mx.styles.StyleProtoChain; import spark.components.supportClasses.GroupBase; import spark.core.DisplayObjectSharingMode; import spark.core.IGraphicElement; import spark.core.IGraphicElementContainer; import spark.core.ISharedDisplayObject; import spark.events.ElementExistenceEvent; use namespace mx_internal; //-------------------------------------- // Events //-------------------------------------- /** * Dispatched when a visual element is added to the content holder. * event.element is the visual element that was added. * * @eventType spark.events.ElementExistenceEvent.ELEMENT_ADD * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Event(name=""elementAdd"", type=""spark.events.ElementExistenceEvent"")] /** * Dispatched when a visual element is removed from the content holder. * event.element is the visual element that's being removed. * * @eventType spark.events.ElementExistenceEvent.ELEMENT_REMOVE * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Event(name=""elementRemove"", type=""spark.events.ElementExistenceEvent"")] //-------------------------------------- // Styles //-------------------------------------- /** * Color of text shadows. * * @default #FFFFFF * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""textShadowColor"", type=""uint"", format=""Color"", inherit=""yes"", theme=""mobile"")] /** * Alpha of text shadows. * * @default 0.55 * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""textShadowAlpha"", type=""Number"",inherit=""yes"", minValue=""0.0"", maxValue=""1.0"", theme=""mobile"")] //-------------------------------------- // Excluded APIs //-------------------------------------- [Exclude(name=""addChild"", kind=""method"")] [Exclude(name=""addChildAt"", kind=""method"")] [Exclude(name=""removeChild"", kind=""method"")] [Exclude(name=""removeChildAt"", kind=""method"")] [Exclude(name=""setChildIndex"", kind=""method"")] [Exclude(name=""swapChildren"", kind=""method"")] [Exclude(name=""swapChildrenAt"", kind=""method"")] [Exclude(name=""numChildren"", kind=""property"")] [Exclude(name=""getChildAt"", kind=""method"")] [Exclude(name=""getChildIndex"", kind=""method"")] //-------------------------------------- // Other metadata //-------------------------------------- [ResourceBundle(""components"")] [DefaultProperty(""mxmlContent"")] [IconFile(""Group.png"")] /** * The Group class is the base container class for visual elements. * The Group container takes as children any components that implement * the IUIComponent interface, and any components that implement * the IGraphicElement interface. * Use this container when you want to manage visual children, * both visual components and graphical components. * *

To improve performance and minimize application size, * the Group container cannot be skinned. * If you want to apply a skin, use the SkinnableContainer instead.

* *

Note: The scale grid might not function correctly when there * are DisplayObject children inside of the Group, such as a component * or another Group. If the children are GraphicElement objects, and * they all share the Group's DisplayObject, then the scale grid works * properly.

* *

Setting any of the following properties on a GraphicElement child * requires that GraphicElement to create its own DisplayObject, * thus negating the scale grid properties on the Group.

* *
 *  alpha
 *  blendMode other than BlendMode.NORMAL or ""auto""
 *  colorTransform
 *  filters
 *  mask
 *  matrix
 *  rotation
 *  scaling
 *  3D properties
 *  bounds outside the extent of the Group
 *  
* *

The Group container has the following default characteristics:

* * * * * *
CharacteristicDescription
Default sizeLarge enough to display its children
Minimum size0 pixels
Maximum size10000 pixels wide and 10000 pixels high
* * @mxml * *

The <s:Group> tag inherits all of the tag * attributes of its superclass and adds the following tag attributes:

* *
 *  <s:Group
 *    Properties
 *    blendMode=""auto""
 *    mxmlContent=""null""
 *    scaleGridBottom=""null""
 *    scaleGridLeft=""null""
 *    scaleGridRight=""null""
 *    scaleGridTop=""null""
 *  
 *    Events
 *    elementAdd=""No default""
 *    elementRemove=""No default""
 *  />
 *  
* * @see spark.components.DataGroup * @see spark.components.SkinnableContainer * * @includeExample examples/GroupExample.mxml * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public class Group extends GroupBase implements IVisualElementContainer, IGraphicElementContainer, ISharedDisplayObject { /** * Constructor. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function Group():void { super(); } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- private var needsDisplayObjectAssignment:Boolean = false; private var layeringMode:uint = ITEM_ORDERED_LAYERING; private var numGraphicElements:uint = 0; private static const ITEM_ORDERED_LAYERING:uint = 0; private static const SPARSE_LAYERING:uint = 1; //-------------------------------------------------------------------------- // // Overridden properties // //-------------------------------------------------------------------------- //---------------------------------- // baselinePosition //---------------------------------- /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ override public function get baselinePosition():Number { if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_5) return super.baselinePosition; if (!validateBaselinePosition()) return NaN; var bElement:IVisualElement = baselinePositionElement; // If no baselinePositionElement is specified, use the first element if (bElement == null) { for (var i:int = 0; i < numElements; i++) { var elt:IVisualElement = getElementAt(i); if (elt.includeInLayout) { bElement = elt; break; } } } if (bElement) return bElement.baselinePosition + bElement.y; else return super.baselinePosition; } [Inspectable(category=""General"", enumeration=""noScale,scale"", defaultValue=""noScale"")] /** * @private */ override public function set resizeMode(value:String):void { if (isValidScaleGrid()) { // Force the resize mode to be scale if we // have set scaleGrid properties value = ResizeMode.SCALE; } super.resizeMode = value; } /** * @private */ override public function set scrollRect(value:Rectangle):void { // Work-around for Flash Player bug: if GraphicElements share // the Group's Display Object and cacheAsBitmap is true, the // scrollRect won't function correctly. var previous:Boolean = canShareDisplayObject; super.scrollRect = value; if (numGraphicElements > 0 && previous != canShareDisplayObject) invalidateDisplayObjectOrdering(); if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } /** * @private */ override mx_internal function set hasMouseListeners(value:Boolean):void { if (mouseEnabledWhereTransparent) redrawRequested = true; super.hasMouseListeners = value; } /** * @private */ override public function set width(value:Number):void { if (_width != value) { if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } super.width = value; } /** * @private */ override public function set height(value:Number):void { if (_height != value) { if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } super.height = value; } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // alpha //---------------------------------- [Inspectable(defaultValue=""1.0"", category=""General"", verbose=""1"")] /** * @private */ override public function set alpha(value:Number):void { if (super.alpha == value) return; if (_blendMode == ""auto"") { // If alpha changes from an opaque/transparent (1/0) and translucent // (0 < value < 1), then trigger a blendMode change if ((value > 0 && value < 1 && (super.alpha == 0 || super.alpha == 1)) || ((value == 0 || value == 1) && (super.alpha > 0 && super.alpha < 1))) { blendModeChanged = true; invalidateDisplayObjectOrdering(); invalidateProperties(); } } super.alpha = value; } //---------------------------------- // baselinePositionElement //---------------------------------- private var _baselinePositionElement:IVisualElement; /** * The element used to calculate the GroupBase's baselinePosition * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get baselinePositionElement():IVisualElement { return _baselinePositionElement; } /** * @private */ public function set baselinePositionElement(value:IVisualElement):void { if (value === _baselinePositionElement) return; _baselinePositionElement = value; invalidateParentSizeAndDisplayList(); } //---------------------------------- // blendMode //---------------------------------- /** * @private * Storage for the blendMode property. */ private var _blendMode:String = ""auto""; private var blendModeChanged:Boolean; private var blendShaderChanged:Boolean; [Inspectable(category=""General"", enumeration=""auto,add,alpha,darken,difference,erase,hardlight,invert,layer,lighten,multiply,normal,subtract,screen,overlay,colordodge,colorburn,exclusion,softlight,hue,saturation,color,luminosity"", defaultValue=""auto"")] /** * 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 Player or Adobe AIR sets the value to BlendMode.NORMAL. * *

A value of ""auto"" (the default) is specific to Group's use of * blendMode and indicates that the underlying blendMode should be * BlendMode.NORMAL except when alpha is not * equal to either 0 or 1, when it is set to BlendMode.LAYER. * This behavior ensures that groups have correct * compositing of their graphic objects when the group is translucent.

* * @default ""auto"" * * @see flash.display.DisplayObject#blendMode * @see flash.display.BlendMode * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ override public function get blendMode():String { return _blendMode; } /** * @private */ override public function set blendMode(value:String):void { if (value == _blendMode) return; invalidateProperties(); blendModeChanged = true; //The default blendMode in FXG is 'auto'. There are only //certain cases where this results in a rendering difference, //one being when the alpha of the Group is > 0 and < 1. In that //case we set the blendMode to layer to avoid the performance //overhead that comes with a non-normal blendMode. if (value == ""auto"") { _blendMode = value; // SDK-29631: Use super.$blendMode instead of super.blendMode // since Group completely overrides blendMode and we // want to bypass the extra logic in UIComponent which // has its own override. // TODO (egeorgie): figure out whether we can share some // of that logic in the future. if (((alpha > 0 && alpha < 1) && super.$blendMode != BlendMode.LAYER) || ((alpha == 1 || alpha == 0) && super.$blendMode != BlendMode.NORMAL) ) { invalidateDisplayObjectOrdering(); } } else { var oldValue:String = _blendMode; _blendMode = value; // If one of the non-native Flash blendModes is set, // record the new value and set the appropriate // blendShader on the display object. if (isAIMBlendMode(value)) { blendShaderChanged = true; } // Only need to re-do display object assignment if blendmode was normal // and is changing to something else, or the blend mode was something else // and is going back to normal. This is because display object sharing // only happens when blendMode is normal. if ((oldValue == BlendMode.NORMAL || value == BlendMode.NORMAL) && !(oldValue == BlendMode.NORMAL && value == BlendMode.NORMAL)) { invalidateDisplayObjectOrdering(); } } } //---------------------------------- // mxmlContent //---------------------------------- private var mxmlContentChanged:Boolean = false; private var _mxmlContent:Array; [ArrayElementType(""mx.core.IVisualElement"")] /** * The visual content children for this Group. * * This method is used internally by Flex and is not intended for direct * use by developers. * *

The content items should only be IVisualElement objects. * An mxmlContent Array should not be shared between multiple * Group containers because visual elements can only live in one container * at a time.

* *

If the content is an Array, do not modify the Array * directly. Use the methods defined by the Group class instead.

* * @default null * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function set mxmlContent(value:Array):void { if (createChildrenCalled) { setMXMLContent(value); } else { mxmlContentChanged = true; _mxmlContent = value; // we will validate this in createChildren(); } } /** * @private */ mx_internal function getMXMLContent():Array { if (_mxmlContent) return _mxmlContent.concat(); else return null; } /** * @private * Adds the elements in mxmlContent to the Group. * Flex calls this method automatically; you do not call it directly. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ private function setMXMLContent(value:Array):void { var i:int; // if there's old content and it's different than what // we're trying to set it to, then let's remove all the old // elements first. if (_mxmlContent != null && _mxmlContent != value) { for (i = _mxmlContent.length - 1; i >= 0; i--) { elementRemoved(_mxmlContent[i], i); } } _mxmlContent = (value) ? value.concat() : null; // defensive copy if (_mxmlContent != null) { var n:int = _mxmlContent.length; for (i = 0; i < n; i++) { var elt:IVisualElement = _mxmlContent[i]; // A common mistake is to bind the viewport property of a Scroller // to a group that was defined in the MXML file with a different parent if (elt.parent && (elt.parent != this)) throw new Error(resourceManager.getString(""components"", ""mxmlElementNoMultipleParents"", [elt])); elementAdded(elt, i); } } } //-------------------------------------------------------------------------- // // Properties: ScaleGrid // //-------------------------------------------------------------------------- private var scaleGridChanged:Boolean = false; // store the scaleGrid into a rectangle to save space (top, left, bottom, right); private var scaleGridStorageVariable:Rectangle; //---------------------------------- // scale9Grid //---------------------------------- /** * @private */ override public function set scale9Grid(value:Rectangle):void { if (value != null) { scaleGridTop = value.top; scaleGridBottom = value.bottom; scaleGridLeft = value.left; scaleGridRight = value.right; } else { scaleGridTop = NaN; scaleGridBottom = NaN; scaleGridLeft = NaN; scaleGridRight = NaN; } } //---------------------------------- // scaleGridBottom //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the bottom coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridBottom():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.height; return NaN; } public function set scaleGridBottom(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.height) { scaleGridStorageVariable.height = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } //---------------------------------- // scaleGridLeft //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the left coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridLeft():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.x; return NaN; } public function set scaleGridLeft(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.x) { scaleGridStorageVariable.x = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } //---------------------------------- // scaleGridRight //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the right coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridRight():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.width; return NaN; } public function set scaleGridRight(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.width) { scaleGridStorageVariable.width = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } //---------------------------------- // scaleGridTop //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the top coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridTop():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.y; return NaN; } public function set scaleGridTop(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.y) { scaleGridStorageVariable.y = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } private function isValidScaleGrid():Boolean { return !isNaN(scaleGridLeft) && !isNaN(scaleGridTop) && !isNaN(scaleGridRight) && !isNaN(scaleGridBottom); } //-------------------------------------------------------------------------- // // Overridden methods: UIComponent // //-------------------------------------------------------------------------- /** * @private * Whether createChildren() has been called or not. * We use this in the setter for mxmlContent to know * whether to validate the value immediately, or just * wait to let createChildren() do it. */ private var createChildrenCalled:Boolean = false; /** * @private */ override protected function createChildren():void { super.createChildren(); createChildrenCalled = true; if (mxmlContentChanged) { mxmlContentChanged = false; setMXMLContent(_mxmlContent); } } /** * @private */ override public function validateProperties():void { super.validateProperties(); // Property validation happens top-down, so now let's // validate graphic element properties after // calling super.validateProperties() if (numGraphicElements > 0) { var length:int = numElements; for (var i:int = 0; i < length; i++) { var element:IGraphicElement = getElementAt(i) as IGraphicElement; if (element) element.validateProperties(); } } } /** * @private */ override protected function commitProperties():void { super.commitProperties(); invalidatePropertiesFlag = false; if (blendModeChanged) { blendModeChanged = false; // Figure out the correct blendMode value // to set. // SDK-29631: Use super.$blendMode instead of super.blendMode // since Group completely overrides blendMode and we // want to bypass the extra logic in UIComponent which // has its own override. // TODO (egeorgie): figure out whether we can share some // of that logic in the future. if (_blendMode == ""auto"") { if (alpha == 0 || alpha == 1) super.$blendMode = BlendMode.NORMAL; else super.$blendMode = BlendMode.LAYER; } else if (!isAIMBlendMode(_blendMode)) { super.$blendMode = _blendMode; } if (blendShaderChanged) { // The graphic element's blendMode was set to a non-Flash // blendMode. We mimic the look by instantiating the // appropriate shader class and setting the blendShader // property on the displayObject. blendShaderChanged = false; switch(_blendMode) { case ""color"": { super.blendShader = new ColorShader(); break; } case ""colordodge"": { super.blendShader = new ColorDodgeShader(); break; } case ""colorburn"": { super.blendShader = new ColorBurnShader(); break; } case ""exclusion"": { super.blendShader = new ExclusionShader(); break; } case ""hue"": { super.blendShader = new HueShader(); break; } case ""luminosity"": { super.blendShader = new LuminosityShader(); break; } case ""saturation"": { super.blendShader = new SaturationShader(); break; } case ""softlight"": { super.blendShader = new SoftLightShader(); break; } } } } // Due to dependent properties alpha and blendMode there may be a need // for a second pass at committing properties (to ensure our new // blendMode or blendShader is assigned to our underlying display // object). if (invalidatePropertiesFlag) { super.commitProperties(); invalidatePropertiesFlag = false; } if (needsDisplayObjectAssignment) { needsDisplayObjectAssignment = false; assignDisplayObjects(); } if (scaleGridChanged) { // Don't reset scaleGridChanged since we also check it in updateDisplayList if (isValidScaleGrid()) resizeMode = ResizeMode.SCALE; // Force the resizeMode to scale } } /** * @private */ override public function validateSize(recursive:Boolean = false):void { // Since IGraphicElement is not ILayoutManagerClient, we need to make sure we // validate sizes of the elements, even in cases where recursive==false. // Size validation happens bottom-up, so now let's // validate graphic element size before // calling super.validateSize() if (numGraphicElements > 0) { var length:int = numElements; for (var i:int = 0; i < length; i++) { var element:IGraphicElement = getElementAt(i) as IGraphicElement; if (element) element.validateSize(); } } super.validateSize(recursive); } /** * @private */ override public function setActualSize(w:Number, h:Number):void { if (_width != w || _height != h) { if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } super.setActualSize(w, h); } /** * @private */ override public function validateDisplayList():void { // call super.validateDisplayList() and let updateDisplayList() run super.validateDisplayList(); // If the DisplayObject assignment is still not completed, then postpone validation // of the GraphicElements. invalidateDisplayList() will be called during the next // commitProperties() call since needsDisplayObjectAssignment=true, // so we will be re-running validateDisplayList() anyways if (needsDisplayObjectAssignment && invalidatePropertiesFlag) return; // DisplayList validation happens top-down, so we should // validate graphic element DisplayList after // calling super.validateDisplayList(). This is // gets tricky because of graphic-element sharing. We clear // Group's graphic's object in updateDisplayList() and handle the // rest of the DisplayList validation in here. // Iterate through the graphic elements. If an element has a displayObject that has been // invalidated, then validate all graphic elements that draw to this displayObject. // The algorithm assumes that all of the elements that share a displayObject are in between // the element with the shared displayObject and the next element that has a displayObject. var sharedDisplayObject:ISharedDisplayObject = this; if (numGraphicElements > 0) { var length:int = numElements; for (var i:int = 0; i < length; i++) { var element:IGraphicElement = getElementAt(i) as IGraphicElement; if (!element) continue; // Do a special check for layer, we may stumble upon an element with layer != 0 // before we're done with the current shared sequence and we don't want to mark // the sequence as valid, until we reach the next sequence. if (element.depth == 0) { // Is this the start of a new shared sequence? if (element.displayObjectSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT) { // We have finished redrawing the previous sequence if (sharedDisplayObject) sharedDisplayObject.redrawRequested = false; // Start the new sequence sharedDisplayObject = element.displayObject as ISharedDisplayObject; } if (!sharedDisplayObject || sharedDisplayObject.redrawRequested) element.validateDisplayList(); } else { // If we have layering, we don't share the display objects. // Don't update the current sharedDisplayObject var elementDisplayObject:ISharedDisplayObject = element.displayObject as ISharedDisplayObject; if (!elementDisplayObject || elementDisplayObject.redrawRequested) { element.validateDisplayList(); if (elementDisplayObject) elementDisplayObject.redrawRequested = false; } } } } // Mark the last shared displayObject valid if (sharedDisplayObject) sharedDisplayObject.redrawRequested = false; } /** * @private */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { // let user's code (layout) run first before dealing with graphic element // sharing because that's when redraws can be requested super.updateDisplayList(unscaledWidth, unscaledHeight); // Clear the group's graphic because graphic elements might be drawing to it // This isn't needed for DataGroup because there's no DisplayObject sharing // This code exists in updateDisplayList() as opposed to validateDisplayList() // because of compatibility issues since most of this code was // refactored from updateDisplayList() and in to validateDisplayList(). User's code // already assumed that they could call super.updateDisplayList() and then be able to draw // into the Group's graphics object. Because of that, the graphics.clear() call is left // in updateDisplayList() instead of in validateDisplayList() with the rest of the graphic // element sharing code. var sharedDisplayObject:ISharedDisplayObject = this; if (sharedDisplayObject.redrawRequested) { // clear the graphics here. The pattern is usually to call graphics.clear() // before calling super.updateDisplayList() so what happens in super.updateDisplayList() // isn't erased. However, in this case, what happens in super.updateDisplayList() isn't // much, and we want to make sure super.updateDisplayList() runs first since the layout // is what actually triggers the the shareDisplayObject to request to be redrawn. graphics.clear(); drawBackground(); // If a scaleGrid is set, make sure the extent of the groups bounds are filled so // the player will scale our contents as expected. if (isValidScaleGrid() && resizeMode == ResizeMode.SCALE) { graphics.lineStyle(); graphics.beginFill(0, 0); graphics.drawRect(0, 0, 1, 1); graphics.drawRect(measuredWidth - 1, measuredHeight - 1, 1, 1); graphics.endFill(); } } if (scaleGridChanged) { scaleGridChanged = false; if (isValidScaleGrid()) { // Check for DisplayObjects other than overlays var overlayCount:int = _overlay ? _overlay.numDisplayObjects : 0; if (numChildren - overlayCount > 0) throw new Error(resourceManager.getString(""components"", ""scaleGridGroupError"")); super.scale9Grid = new Rectangle(scaleGridLeft, scaleGridTop, scaleGridRight - scaleGridLeft, scaleGridBottom - scaleGridTop); } else { super.scale9Grid = null; } } } /** * @private * TODO (rfrishbe): Most of this code is a duplicate of UIComponent::notifyStyleChangeInChildren, * refactor as appropriate to avoid code duplication once we have a common * child iterator between UIComponent and Group. */ override public function notifyStyleChangeInChildren( styleProp:String, recursive:Boolean):void { if (mxmlContentChanged || !recursive) return; var n:int = numElements; for (var i:int = 0; i < n; i++) { var child:ISimpleStyleClient = getElementAt(i) as ISimpleStyleClient; if (child) { child.styleChanged(styleProp); if (child is IStyleClient) IStyleClient(child).notifyStyleChangeInChildren(styleProp, recursive); } } if (advanceStyleClientChildren != null) { for (var styleClient:Object in advanceStyleClientChildren) { var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient as IAdvancedStyleClient; if (iAdvanceStyleClientChild) { iAdvanceStyleClientChild.styleChanged(styleProp); } } } } /** * @private * TODO (rfrishbe): Most of this code is a duplicate of UIComponent::regenerateStyleCache, * refactor as appropriate to avoid code duplication once we have a common * child iterator between UIComponent and Group. */ override public function regenerateStyleCache(recursive:Boolean):void { // Regenerate the proto chain for this object initProtoChain(); // Recursively call this method on each child. var n:int = numElements; for (var i:int = 0; i < n; i++) { var child:IVisualElement = getElementAt(i); if (child is IStyleClient) { // Does this object already have a proto chain? // If not, there's no need to regenerate a new one. if (IStyleClient(child).inheritingStyles != StyleProtoChain.STYLE_UNINITIALIZED) { IStyleClient(child).regenerateStyleCache(recursive); } } else if (child is IUITextField) { // Does this object already have a proto chain? // If not, there's no need to regenerate a new one. if (IUITextField(child).inheritingStyles) StyleProtoChain.initTextField(IUITextField(child)); } } // Call this method on each non-visual StyleClient if (advanceStyleClientChildren != null) { for (var styleClient:Object in advanceStyleClientChildren) { var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient as IAdvancedStyleClient; if (iAdvanceStyleClientChild && iAdvanceStyleClientChild.inheritingStyles != StyleProtoChain.STYLE_UNINITIALIZED) { iAdvanceStyleClientChild.regenerateStyleCache(recursive); } } } } //-------------------------------------------------------------------------- // // Content management // //-------------------------------------------------------------------------- /** * @private */ override public function get numElements():int { if (_mxmlContent == null) return 0; return _mxmlContent.length; } /** * @private */ override public function getElementAt(index:int):IVisualElement { // check for RangeError: checkForRangeError(index); return _mxmlContent[index]; } /** * @private * Checks the range of index to make sure it's valid */ private function checkForRangeError(index:int, addingElement:Boolean = false):void { // figure out the maximum allowable index var maxIndex:int = (_mxmlContent == null ? -1 : _mxmlContent.length - 1); // if adding an element, we allow an extra index at the end if (addingElement) maxIndex++; if (index < 0 || index > maxIndex) throw new RangeError(resourceManager.getString(""components"", ""indexOutOfRange"", [index])); } /** * @private */ private function isAIMBlendMode(value:String):Boolean { if (value == ""colordodge"" || value ==""colorburn"" || value ==""exclusion"" || value ==""softlight"" || value ==""hue"" || value ==""saturation"" || value ==""color"" || value ==""luminosity"") return true; else return false; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function addElement(element:IVisualElement):IVisualElement { var index:int = numElements; // This handles the case where we call addElement on something // that already is in the list. Let's just handle it silently // and not throw up any errors. if (element.parent == this) index = numElements-1; return addElementAt(element, index); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function addElementAt(element:IVisualElement, index:int):IVisualElement { if (element == this) throw new ArgumentError(resourceManager.getString(""components"", ""cannotAddYourselfAsYourChild"")); // check for RangeError: checkForRangeError(index, true); var host:DisplayObject = element.parent; // This handles the case where we call addElement on something // that already is in the list. Let's just handle it silently // and not throw up any errors. if (host == this) { setElementIndex(element, index); return element; } else if (host is IVisualElementContainer) { // Remove the item from the group if that group isn't this group IVisualElementContainer(host).removeElement(element); } // If we don't have any content yet, initialize it to an empty array if (_mxmlContent == null) _mxmlContent = []; _mxmlContent.splice(index, 0, element); if (!mxmlContentChanged) elementAdded(element, index); scaleGridChanged = true; return element; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function removeElement(element:IVisualElement):IVisualElement { return removeElementAt(getElementIndex(element)); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function removeElementAt(index:int):IVisualElement { // check RangeError checkForRangeError(index); var element:IVisualElement = _mxmlContent[index]; // Need to call elementRemoved before removing the item so anyone listening // for the event can access the item. if (!mxmlContentChanged) elementRemoved(element, index); _mxmlContent.splice(index, 1); return element; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function removeAllElements():void { for (var i:int = numElements - 1; i >= 0; i--) { removeElementAt(i); } } /** * @private */ override public function getElementIndex(element:IVisualElement):int { var index:int = _mxmlContent ? _mxmlContent.indexOf(element) : -1; if (index == -1) throw ArgumentError(resourceManager.getString(""components"", ""elementNotFoundInGroup"", [element])); else return index; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function setElementIndex(element:IVisualElement, index:int):void { // check for RangeError...this is done in addItemAt // but we want to do it before removing the element checkForRangeError(index); if (getElementIndex(element) == index) return; removeElement(element); addElementAt(element, index); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function swapElements(element1:IVisualElement, element2:IVisualElement):void { swapElementsAt(getElementIndex(element1), getElementIndex(element2)); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function swapElementsAt(index1:int, index2:int):void { checkForRangeError(index1); checkForRangeError(index2); // Make sure that index1 is the smaller index so that addElementAt // doesn't RTE if (index1 > index2) { var temp:int = index2; index2 = index1; index1 = temp; } else if (index1 == index2) return; var element1:IVisualElement = _mxmlContent[index1]; var element2:IVisualElement = _mxmlContent[index2]; // Make sure we do the proper invalidations, but don't dispatch events if (!mxmlContentChanged) { elementRemoved(element1, index1, false /*notifyListeners*/); elementRemoved(element2, index2, false /*notifyListeners*/); } // Step 1: remove // Make sure we remove the bigger index first _mxmlContent.splice(index2, 1); _mxmlContent.splice(index1, 1); // Step 2: swap // Add them in reverse order _mxmlContent.splice(index1, 0, element2); _mxmlContent.splice(index2, 0, element1); // Make sure we do the proper invalidations, but don't dispatch events if (!mxmlContentChanged) { elementAdded(element2, index1, false /*notifyListeners*/); elementAdded(element1, index2, false /*notifyListeners*/); } } //-------------------------------------------------------------------------- // // Content management (internal) // //-------------------------------------------------------------------------- /** * @private */ override public function invalidateLayering():void { if (layeringMode == ITEM_ORDERED_LAYERING) layeringMode = SPARSE_LAYERING; invalidateDisplayObjectOrdering(); } /** * Adds an item to this Group. * Flex calls this method automatically; you do not call it directly. * * @param item The item that was added. * * @param index The index where the item was added. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ mx_internal function elementAdded(element:IVisualElement, index:int, notifyListeners:Boolean = true):void { if (layout) layout.elementAdded(index); if (element.depth != 0) invalidateLayering(); // Set the moduleFactory to the child, but don't overwrite an existing moduleFactory. // Propagate moduleFactory to the child, but don't overwrite an existing moduleFactory. if (element is IFlexModule && IFlexModule(element).moduleFactory == null) { if (moduleFactory != null) IFlexModule(element).moduleFactory = moduleFactory; else if (document is IFlexModule && document.moduleFactory != null) IFlexModule(element).moduleFactory = document.moduleFactory; else if (parent is IFlexModule && IFlexModule(element).moduleFactory != null) IFlexModule(element).moduleFactory = IFlexModule(parent).moduleFactory; } // Set the font context in non-UIComponent children. // UIComponent children use moduleFactory. if (element is IFontContextComponent && !(element is UIComponent) && IFontContextComponent(element).fontContext == null) { IFontContextComponent(element).fontContext = moduleFactory; } if (element is IGraphicElement) { numGraphicElements++; addingGraphicElementChild(element as IGraphicElement); invalidateDisplayObjectOrdering(); } else { // item must be a DisplayObject // if the display object ordering is invalidated (because we have graphic elements // that aren't actually in the display list), then lets just add our item to the end. // If the ordering isn't invalidated, then let's just try to add it to the proper index. if (invalidateDisplayObjectOrdering()) { // This always adds the child to the end of the display list. Any // ordering discrepancies will be fixed up in assignDisplayObjects(). addDisplayObjectToDisplayList(DisplayObject(element)); } else { addDisplayObjectToDisplayList(DisplayObject(element), index); } } if (notifyListeners) { if (hasEventListener(ElementExistenceEvent.ELEMENT_ADD)) dispatchEvent(new ElementExistenceEvent( ElementExistenceEvent.ELEMENT_ADD, false, false, element, index)); if (element is IUIComponent && element.hasEventListener(FlexEvent.ADD)) element.dispatchEvent(new FlexEvent(FlexEvent.ADD)); } invalidateSize(); invalidateDisplayList(); } /** * Removes an item from this Group. * Flex calls this method automatically; you do not call it directly. * * @param index The index of the item that is being removed. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ mx_internal function elementRemoved(element:IVisualElement, index:int, notifyListeners:Boolean = true):void { var childDO:DisplayObject = element as DisplayObject; if (notifyListeners) { if (hasEventListener(ElementExistenceEvent.ELEMENT_REMOVE)) dispatchEvent(new ElementExistenceEvent( ElementExistenceEvent.ELEMENT_REMOVE, false, false, element, index)); if (element is IUIComponent && element.hasEventListener(FlexEvent.REMOVE)) element.dispatchEvent(new FlexEvent(FlexEvent.REMOVE)); } if (element && (element is IGraphicElement)) { numGraphicElements--; removingGraphicElementChild(element as IGraphicElement); } else if (childDO && childDO.parent == this) { super.removeChild(childDO); } invalidateDisplayObjectOrdering(); invalidateSize(); invalidateDisplayList(); if (layout) layout.elementRemoved(index); } /** * @private */ mx_internal function addingGraphicElementChild(child:IGraphicElement):void { // Special case (defensive coding) - if the element was previously // a child of this Group, and it didn't release its previously assigned // DisplayObject when its parent changed, and there's the possibility that // the Group may assign it the same DisplayObject and the same sharing mode, // we still need to invalidate and redraw as the displayObject likely has // been redrawn while the element was not a child of this Group. if (child.displayObject && child.displayObjectSharingMode == DisplayObjectSharingMode.USES_SHARED_OBJECT) invalidateGraphicElementDisplayList(child); child.parentChanged(this); // Sets up the inheritingStyles and nonInheritingStyles objects // and their proto chains so that getStyle() works. // If this object already has some children, // then reinitialize the children's proto chains. if (child is IStyleClient) IStyleClient(child).regenerateStyleCache(true); if (child is ISimpleStyleClient) ISimpleStyleClient(child).styleChanged(null); if (child is IStyleClient) IStyleClient(child).notifyStyleChangeInChildren(null, true); } /** * @private */ mx_internal function removingGraphicElementChild(child:IGraphicElement):void { // First discard the displayObject, as child may decide to destroy it // when parent changes. discardDisplayObject(child); child.parentChanged(null); } /** * Removes the element's DisplayObject from this Group's * display list. * * The Group also ensures any elements that share the * DisplayObject is redrawn. * *

This method doesn't necessarily trigger new DisplayObject * reassignment for the passed in element. * To request new display object reassignment, call the * invalidateGraphicElementSharing() method.

* * @param element The graphic element whose display object is discarded. * @see #invalidateGraphicElementSharing * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ mx_internal function discardDisplayObject(element:IGraphicElement):void { var oldDisplayObject:DisplayObject = element.displayObject; if (!oldDisplayObject) return; // If the element created the display object if (element.displayObjectSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT && oldDisplayObject.parent == this) { super.removeChild(oldDisplayObject); // Redo the shared sequences. invalidateDisplayObjectOrdering(); } else if (oldDisplayObject is ISharedDisplayObject) { // Redraw the shared sequence ISharedDisplayObject(oldDisplayObject).redrawRequested = true; // Make sure we do a pass through the graphic elements and redraw // the invalid ones. We should only redraw, no need to redo the layout. super.$invalidateDisplayList(); } } /** * @private * * Returns true if the Group's display object can be shared with graphic elements * inside the group */ private function get canShareDisplayObject():Boolean { // Work-around for Flash Player bug: if GraphicElements share // the Group's Display Object and cacheAsBitmap is true, the // scrollRect won't function correctly. // We can't even check the cacheAsBitmap property since that will // cause a back buffer allocation, which is another FP bug. if (scrollRect) return false; // We can't share ourselves if we're in blendMode != normal, or we have // to deal with any layering. The reason is because we handle layer = 0 first // in our implementation, and we don't want those to use our display object to // draw into because there could be something further down the line that has // layer < 0. The cases where we are in blendMode != normal is when blendMode // has been explicitly set or blendMode is auto and there is a fractional alpha. return (_blendMode == ""normal"" || _blendMode == ""auto"" && (alpha == 0 || alpha == 1)) && (layeringMode == ITEM_ORDERED_LAYERING); } /** * @private * * Invalidates the display object ordering and will run assignDisplayObjects() * if necessary. * * @return true if the display object ordering needed to be invalidated; * false otherwise. */ private function invalidateDisplayObjectOrdering():Boolean { if (layeringMode == SPARSE_LAYERING || numGraphicElements > 0) { needsDisplayObjectAssignment = true; invalidateProperties(); return true; } return false; } /** * @private * * Called to assign display objects to graphic elements */ private function assignDisplayObjects():void { var topLayerItems:Vector.; var bottomLayerItems:Vector.; var keepLayeringEnabled:Boolean = false; var insertIndex:int = 0; // Keep track of the previous IVisualElement. This is used when // assigning DisplayObjects to the IGraphicElements. // If the Group can share its DisplayObject with the IGraphicElements // then initialize the prevItem with this Group object. var prevItem:IVisualElement; if (canShareDisplayObject) prevItem = this; // Iterate through all of the items var len:int = numElements; for (var i:int = 0; i < len; i++) { var item:IVisualElement = getElementAt(i); if (layeringMode != ITEM_ORDERED_LAYERING) { var layer:Number = item.depth; if (layer != 0) { if (layer > 0) { if (topLayerItems == null) topLayerItems = new Vector.(); topLayerItems.push(item); continue; } else { if (bottomLayerItems == null) bottomLayerItems = new Vector.(); bottomLayerItems.push(item); continue; } } } // this should only get called if layer == 0, or we don't care // about layering (layeringMode == ITEM_ORDERED_LAYERING) insertIndex = assignDisplayObjectTo(item, prevItem, insertIndex); prevItem = item; } // we've done all layer == 0 items. // now let's put the higher z-index ones on next // then we'll handle the ones on bottom, but we'll // insert them in the very beginning (index = 0) if (topLayerItems != null) { keepLayeringEnabled = true; //topLayerItems.sortOn(""layer"",Array.NUMERIC); GroupBase.sortOnLayer(topLayerItems); len = topLayerItems.length; for (i=0;icurElement implements IGraphicElement, then both its * DisplayObject and displayObjectSharingMode will be updated. * * @curElement The current element to assign DisplayObject to * @prevEelement The previous element in the list of elements or null. * @return Returns the display list index after the current element's * DisplayObject. */ private function assignDisplayObjectTo(curElement:IVisualElement, prevElement:IVisualElement, insertIndex:int):int { if (curElement is DisplayObject) { super.setChildIndex(curElement as DisplayObject, insertIndex++); } else if (curElement is IGraphicElement) { var current:IGraphicElement = IGraphicElement(curElement); var previous:IGraphicElement = prevElement as IGraphicElement; var oldDisplayObject:DisplayObject = current.displayObject; var oldSharingMode:String = current.displayObjectSharingMode; if (previous && previous.canShareWithNext(current) && current.canShareWithPrevious(previous) && current.setSharedDisplayObject(previous.displayObject)) { // If we are the second element in the shared sequence, // make sure that the first element has the correct displayObjectSharingMode if (previous.displayObjectSharingMode == DisplayObjectSharingMode.OWNS_UNSHARED_OBJECT) previous.displayObjectSharingMode = DisplayObjectSharingMode.OWNS_SHARED_OBJECT; current.displayObjectSharingMode = DisplayObjectSharingMode.USES_SHARED_OBJECT; } else if (prevElement == this && current.setSharedDisplayObject(this)) { current.displayObjectSharingMode = DisplayObjectSharingMode.USES_SHARED_OBJECT; } else { // We don't want to create new DisplayObjects for elements that // already have created their own their display objects. var ownsDisplayObject:Boolean = oldSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT; // If the element doesn't have a DisplayObject or it doesn't own // the DisplayObject it currently has, then create a new one var displayObject:DisplayObject = oldDisplayObject; if (!ownsDisplayObject || !displayObject) displayObject = current.createDisplayObject(); // Make sure the DisplayObject is at the correct position. // Check displayObject for null, some graphic elements // may choose not to create a DisplayObject during this pass. if (displayObject) addDisplayObjectToDisplayList(displayObject, insertIndex++); current.displayObjectSharingMode = DisplayObjectSharingMode.OWNS_UNSHARED_OBJECT; } invalidateAfterAssignment(current, oldSharingMode, oldDisplayObject); } return insertIndex; } /** * @private * Performs invalidation of the old and new shared sequenences. * If necesary, removes the old display object from the list. */ private function invalidateAfterAssignment(element:IGraphicElement, oldSharingMode:String, oldDisplayObject:DisplayObject):void { // Make sure we remove or mark for redraw the old displayObject var displayObject:DisplayObject = element.displayObject; var sharingMode:String = element.displayObjectSharingMode; if (oldDisplayObject == displayObject && sharingMode == oldSharingMode) return; // Make sure we redraw the display object if (displayObject is ISharedDisplayObject) ISharedDisplayObject(displayObject).redrawRequested = true; // Old display object also needs to be redrawn, in case any other GE still uses it. if (oldDisplayObject is ISharedDisplayObject) ISharedDisplayObject(oldDisplayObject).redrawRequested = true; // Make sure we remove the old display object, if needed if (oldDisplayObject && oldDisplayObject.parent == this && oldDisplayObject != displayObject && oldSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT) super.removeChild(oldDisplayObject); } /** * @private * * If the displayObject is not a child of this Group, then insert it at the * specified index (or at the end of the list, when index is -1). * Else, if the displayObject is already a child of the Group, then simply * adjust its child index. */ private function addDisplayObjectToDisplayList(child:DisplayObject, index:int = -1):void { var overlayCount:int = _overlay ? _overlay.numDisplayObjects : 0; if (child.parent == this) super.setChildIndex(child, index != -1 ? index : super.numChildren - 1 - overlayCount); else super.addChildAt(child, index != -1 ? index : super.numChildren - overlayCount); } /** * Notify the host component that an element has changed and needs to be redrawn. * Group calls the validateDisplayList() method on the IGraphicElement * to give it a chance to redraw. * * @param element The element that has changed. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementDisplayList(element:IGraphicElement):void { if (element.displayObject is ISharedDisplayObject) ISharedDisplayObject(element.displayObject).redrawRequested = true; // Invalidate display list only, no need to run the layout. super.$invalidateDisplayList(); } /** * Notify the host component that an element changed and needs to validate properties. * Group calls the validateProperties() method on the IGraphicElement * to give it a chance to commit its properties. * * @param element The element that has changed. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementProperties(element:IGraphicElement):void { invalidateProperties(); } /** * Notify the host component that an element size has changed. * Group calls the validateSize() method on the IGraphicElement * to give it a chance to validate its size. * * @param element The element that has changed size. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementSize(element:IGraphicElement):void { // Invalidate the size only, no need to run the layout. // Later on, if the size changes, then a layout pass will be triggered. super.$invalidateSize(); } /** * Notify the host that an element layer has changed. * Group re-evaluates the sequences of elements with shared DisplayObjects * and may re-assign the DisplayObjects and redraw the sequences as a result. * * @param element The element that has changed size. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementSharing(element:IGraphicElement):void { // One of our children have told us they might need a displayObject invalidateDisplayObjectOrdering(); } /** * @private */ override public function addChild(child:DisplayObject):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""addChildError""))); } /** * @private */ override public function addChildAt(child:DisplayObject, index:int):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""addChildAtError""))); } /** * @private */ override public function removeChild(child:DisplayObject):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""removeChildError""))); } /** * @private */ override public function removeChildAt(index:int):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""removeChildAtError""))); } /** * @private */ override public function setChildIndex(child:DisplayObject, index:int):void { throw(new Error(resourceManager.getString(""components"", ""setChildIndexError""))); } /** * @private */ override public function swapChildren(child1:DisplayObject, child2:DisplayObject):void { throw(new Error(resourceManager.getString(""components"", ""swapChildrenError""))); } /** * @private */ override public function swapChildrenAt(index1:int, index2:int):void { throw(new Error(resourceManager.getString(""components"", ""swapChildrenAtError""))); } /** * @private * Override to ensure we set redrawRequested when appropriate. */ override public function set mouseEnabledWhereTransparent(value:Boolean):void { if (value == mouseEnabledWhereTransparent) return; super.mouseEnabledWhereTransparent = value; redrawRequested = true; } //-------------------------------------------------------------------------- // // ISharedDisplayObject // //-------------------------------------------------------------------------- /** * @private */ private var _redrawRequested:Boolean = false; /** * @private * Contains true when any of the IGraphicElement objects that share * this DisplayObject object needs to redraw or the background for the container * needs to be redrawn. * This is used internally * by the Group class and developers don't typically use this. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get redrawRequested():Boolean { return _redrawRequested; } /** * @private */ public function set redrawRequested(value:Boolean):void { _redrawRequested = value; } } } ",16159,True,3332.559965639238,median "CLASS zcl_excel_common DEFINITION PUBLIC FINAL CREATE PUBLIC . *""* public components of class ZCL_EXCEL_COMMON *""* do not include other source files here!!! PUBLIC SECTION. CONSTANTS c_excel_baseline_date TYPE d VALUE '19000101'. ""#EC NOTEXT CLASS-DATA c_excel_numfmt_offset TYPE int1 VALUE 164. ""#EC NOTEXT . . . . . . . . . . . . . . . . "" . CONSTANTS c_excel_sheet_max_col TYPE int4 VALUE 16384. ""#EC NOTEXT CONSTANTS c_excel_sheet_min_col TYPE int4 VALUE 1. ""#EC NOTEXT CONSTANTS c_excel_sheet_max_row TYPE int4 VALUE 1048576. ""#EC NOTEXT CONSTANTS c_excel_sheet_min_row TYPE int4 VALUE 1. ""#EC NOTEXT CLASS-DATA c_spras_en TYPE spras VALUE 'E'. ""#EC NOTEXT . . . . . . . . . . . . . . . . "" . CLASS-DATA o_conv TYPE REF TO cl_abap_conv_out_ce . CONSTANTS c_excel_1900_leap_year TYPE d VALUE '19000228'. ""#EC NOTEXT CLASS-DATA c_xlsx_file_filter TYPE string VALUE 'Excel Workbook (*.xlsx)|*.xlsx|'. ""#EC NOTEXT . . . . . . . "" . CLASS-METHODS class_constructor . CLASS-METHODS describe_structure IMPORTING !io_struct TYPE REF TO cl_abap_structdescr RETURNING VALUE(rt_dfies) TYPE ddfields . CLASS-METHODS convert_column2alpha IMPORTING !ip_column TYPE simple RETURNING VALUE(ep_column) TYPE zexcel_cell_column_alpha RAISING zcx_excel . CLASS-METHODS convert_column2int IMPORTING !ip_column TYPE simple RETURNING VALUE(ep_column) TYPE zexcel_cell_column RAISING zcx_excel . CLASS-METHODS convert_columnrow2column_a_row IMPORTING !i_columnrow TYPE clike EXPORTING !e_column TYPE zexcel_cell_column_alpha !e_row TYPE zexcel_cell_row . CLASS-METHODS convert_range2column_a_row IMPORTING !i_range TYPE clike EXPORTING !e_column_start TYPE zexcel_cell_column_alpha !e_column_end TYPE zexcel_cell_column_alpha !e_row_start TYPE zexcel_cell_row !e_row_end TYPE zexcel_cell_row !e_sheet TYPE clike RAISING zcx_excel . CLASS-METHODS date_to_excel_string IMPORTING !ip_value TYPE d RETURNING VALUE(ep_value) TYPE zexcel_cell_value . CLASS-METHODS encrypt_password IMPORTING !i_pwd TYPE zexcel_aes_password RETURNING VALUE(r_encrypted_pwd) TYPE zexcel_aes_password . CLASS-METHODS escape_string IMPORTING !ip_value TYPE clike RETURNING VALUE(ep_escaped_value) TYPE string . CLASS-METHODS unescape_string IMPORTING !iv_escaped TYPE clike RETURNING VALUE(ev_unescaped_string) TYPE string RAISING zcx_excel . CLASS-METHODS excel_string_to_date IMPORTING !ip_value TYPE zexcel_cell_value RETURNING VALUE(ep_value) TYPE d RAISING zcx_excel . CLASS-METHODS excel_string_to_time IMPORTING !ip_value TYPE zexcel_cell_value RETURNING VALUE(ep_value) TYPE t RAISING zcx_excel . CLASS-METHODS excel_string_to_number IMPORTING !ip_value TYPE zexcel_cell_value RETURNING VALUE(ep_value) TYPE f RAISING zcx_excel . CLASS-METHODS get_fieldcatalog IMPORTING !ip_table TYPE STANDARD TABLE !iv_hide_mandt TYPE abap_bool DEFAULT abap_true RETURNING VALUE(ep_fieldcatalog) TYPE zexcel_t_fieldcatalog . CLASS-METHODS number_to_excel_string IMPORTING VALUE(ip_value) TYPE numeric RETURNING VALUE(ep_value) TYPE zexcel_cell_value . CLASS-METHODS recursive_class_to_struct IMPORTING !i_source TYPE any CHANGING !e_target TYPE data !e_targetx TYPE data . CLASS-METHODS recursive_struct_to_class IMPORTING !i_source TYPE data !i_sourcex TYPE data CHANGING !e_target TYPE any . CLASS-METHODS time_to_excel_string IMPORTING !ip_value TYPE t RETURNING VALUE(ep_value) TYPE zexcel_cell_value . TYPE-POOLS abap . TYPES: t_char10 TYPE c LENGTH 10. CLASS-METHODS split_file IMPORTING !ip_file TYPE text255 EXPORTING !ep_file TYPE text255 !ep_extension TYPE t_char10 !ep_dotextension TYPE t_char10 . CLASS-METHODS calculate_cell_distance IMPORTING !iv_reference_cell TYPE clike !iv_current_cell TYPE clike EXPORTING !ev_row_difference TYPE i !ev_col_difference TYPE i RAISING zcx_excel . CLASS-METHODS determine_resulting_formula IMPORTING !iv_reference_cell TYPE clike !iv_reference_formula TYPE clike !iv_current_cell TYPE clike RETURNING VALUE(ev_resulting_formula) TYPE string RAISING zcx_excel . CLASS-METHODS shift_formula IMPORTING !iv_reference_formula TYPE clike VALUE(iv_shift_cols) TYPE i VALUE(iv_shift_rows) TYPE i RETURNING VALUE(ev_resulting_formula) TYPE string RAISING zcx_excel . CLASS-METHODS is_cell_in_range IMPORTING !ip_column TYPE simple !ip_row TYPE zexcel_cell_row !ip_range TYPE clike RETURNING VALUE(rp_in_range) TYPE abap_bool RAISING zcx_excel . *""* protected components of class ZCL_EXCEL_COMMON *""* do not include other source files here!!! *""* protected components of class ZCL_EXCEL_COMMON *""* do not include other source files here!!! PROTECTED SECTION. PRIVATE SECTION. CLASS-DATA c_excel_col_module TYPE int2 VALUE 64. ""#EC NOTEXT . . . . . . . . . . . . . . . "" . CLASS-METHODS structure_case IMPORTING !is_component TYPE abap_componentdescr CHANGING !xt_components TYPE abap_component_tab . CLASS-METHODS structure_recursive IMPORTING !is_component TYPE abap_componentdescr RETURNING VALUE(rt_components) TYPE abap_component_tab . CLASS-METHODS char2hex IMPORTING !i_char TYPE char1 RETURNING VALUE(r_hex) TYPE zexcel_pwd_hash . CLASS-METHODS shl01 IMPORTING !i_pwd_hash TYPE zexcel_pwd_hash RETURNING VALUE(r_pwd_hash) TYPE zexcel_pwd_hash . CLASS-METHODS shr14 IMPORTING !i_pwd_hash TYPE zexcel_pwd_hash RETURNING VALUE(r_pwd_hash) TYPE zexcel_pwd_hash . ENDCLASS. CLASS zcl_excel_common IMPLEMENTATION. METHOD calculate_cell_distance. DATA: lv_reference_row TYPE i, lv_reference_col_alpha TYPE zexcel_cell_column_alpha, lv_reference_col TYPE i, lv_current_row TYPE i, lv_current_col_alpha TYPE zexcel_cell_column_alpha, lv_current_col TYPE i. *--------------------------------------------------------------------* * Split reference cell into numerical row/column representation *--------------------------------------------------------------------* convert_columnrow2column_a_row( EXPORTING i_columnrow = iv_reference_cell IMPORTING e_column = lv_reference_col_alpha e_row = lv_reference_row ). lv_reference_col = convert_column2int( lv_reference_col_alpha ). *--------------------------------------------------------------------* * Split current cell into numerical row/column representation *--------------------------------------------------------------------* convert_columnrow2column_a_row( EXPORTING i_columnrow = iv_current_cell IMPORTING e_column = lv_current_col_alpha e_row = lv_current_row ). lv_current_col = convert_column2int( lv_current_col_alpha ). *--------------------------------------------------------------------* * Calculate row and column difference * Positive: Current cell below reference cell * or Current cell right of reference cell * Negative: Current cell above reference cell * or Current cell left of reference cell *--------------------------------------------------------------------* ev_row_difference = lv_current_row - lv_reference_row. ev_col_difference = lv_current_col - lv_reference_col. ENDMETHOD. METHOD char2hex. IF o_conv IS NOT BOUND. o_conv = cl_abap_conv_out_ce=>create( endian = 'L' ignore_cerr = abap_true replacement = '#' ). ENDIF. CALL METHOD o_conv->reset( ). CALL METHOD o_conv->write( data = i_char ). r_hex+1 = o_conv->get_buffer( ). "" x'65' must be x'0065' ENDMETHOD. METHOD class_constructor. c_xlsx_file_filter = 'Excel Workbook (*.xlsx)|*.xlsx|'(005). ENDMETHOD. METHOD convert_column2alpha. DATA: lv_uccpi TYPE i, lv_text TYPE sychar02, lv_module TYPE int4, lv_column TYPE zexcel_cell_column. STATICS: sv_prev_in LIKE lv_column, sv_prev_out LIKE ep_column. * Propagate zcx_excel if error occurs "" issue #155 - less restrictive typing for ip_column lv_column = convert_column2int( ip_column ). "" issue #155 - less restrictive typing for ip_column *--------------------------------------------------------------------* * Check whether column is in allowed range for EXCEL to handle ( 1-16384 ) *--------------------------------------------------------------------* IF lv_column > 16384 OR lv_column < 1. zcx_excel=>raise_text( 'Index out of bounds' ). ENDIF. *--------------------------------------------------------------------* * Look up for previous succesfull cached result *--------------------------------------------------------------------* IF lv_column = sv_prev_in AND sv_prev_out IS NOT INITIAL. ep_column = sv_prev_out. RETURN. ELSE. CLEAR sv_prev_out. sv_prev_in = lv_column. ENDIF. *--------------------------------------------------------------------* * Build alpha representation of column *--------------------------------------------------------------------* WHILE lv_column GT 0. lv_module = ( lv_column - 1 ) MOD 26. lv_uccpi = 65 + lv_module. lv_column = ( lv_column - lv_module ) / 26. lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). CONCATENATE lv_text ep_column INTO ep_column. ENDWHILE. *--------------------------------------------------------------------* * Save succesfull output into cache *--------------------------------------------------------------------* sv_prev_out = ep_column. ENDMETHOD. METHOD convert_column2int. *--------------------------------------------------------------------* * issue #230 - Pimp my Code * - Stefan Schmoecker, (done) 2012-12-29 * - ... * changes: renaming variables to naming conventions * removing unused variables * removing commented out code that is inactive for more then half a year * message made to support multilinguality * adding comments to explain what we are trying to achieve *--------------------------------------------------------------------* * issue#246 - error converting lower case column names * - Stefan Schmoecker, 2012-12-29 * changes: translating the correct variable to upper dase * adding missing exception if input is a number * that is out of bounds * adding missing exception if input contains * illegal characters like german umlauts *--------------------------------------------------------------------* DATA: lv_column TYPE zexcel_cell_column_alpha, lv_column_c TYPE char10, lv_column_s TYPE string, lv_errormessage TYPE string, "" Can't pass '...'(abc) to exception-class lv_modulo TYPE i. STATICS: sv_prev_in LIKE lv_column_c, sv_prev_out LIKE ep_column. *--------------------------------------------------------------------* * This module tries to identify which column a user wants to access * Numbers as input are just passed back, anything else will be converted * using EXCEL nomenclatura A = 1, AA = 27, ..., XFD = 16384 *--------------------------------------------------------------------* *--------------------------------------------------------------------* * Normalize input ( upper case , no gaps ) *--------------------------------------------------------------------* lv_column_c = ip_column. * TRANSLATE lv_column TO UPPER CASE. "" Fix #246 TRANSLATE lv_column_c TO UPPER CASE. "" Fix #246 CONDENSE lv_column_c NO-GAPS. IF lv_column_c EQ ''. * lv_errormessage = 'Unable to interpret input as column'(003). MESSAGE e800(zabap2xlsx) INTO lv_errormessage. zcx_excel=>raise_symsg( ). ENDIF. *--------------------------------------------------------------------* * Look up for previous succesfull cached result *--------------------------------------------------------------------* IF lv_column_c = sv_prev_in AND sv_prev_out IS NOT INITIAL. ep_column = sv_prev_out. RETURN. ELSE. CLEAR sv_prev_out. sv_prev_in = lv_column_c. ENDIF. *--------------------------------------------------------------------* * If a number gets passed, just convert it to an integer and return * the converted value *--------------------------------------------------------------------* TRY. IF lv_column_c CO '1234567890 '. "" Fix #164 ep_column = lv_column_c. "" Fix #164 *--------------------------------------------------------------------* * Maximum column for EXCEL: XFD = 16384 "" if anyone has a reference for this information - please add here instead of this comment *--------------------------------------------------------------------* IF ep_column > 16384 OR ep_column < 1. lv_errormessage = 'Index out of bounds'(004). zcx_excel=>raise_text( lv_errormessage ). ENDIF. EXIT. ENDIF. CATCH cx_sy_conversion_no_number. ""#EC NO_HANDLER "" Try the character-approach if approach via number has failed ENDTRY. *--------------------------------------------------------------------* * Raise error if unexpected characters turns up *--------------------------------------------------------------------* lv_column_s = lv_column_c. IF lv_column_s CN sy-abcde. * lv_errormessage = 'Unable to interpret input as column'(003). MESSAGE e800(zabap2xlsx) INTO lv_errormessage. zcx_excel=>raise_symsg( ). ENDIF. DO 1 TIMES. ""Because of using CHECK *--------------------------------------------------------------------* * Interpret input as number to base 26 with A=1, ... Z=26 * Raise error if unexpected character turns up *--------------------------------------------------------------------* * 1st character *--------------------------------------------------------------------* lv_column = lv_column_c. lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+0(1) ) MOD zcl_excel_common=>c_excel_col_module. IF lv_modulo < 1 OR lv_modulo > 26. * lv_errormessage = 'Unable to interpret input as column'(003). MESSAGE e800(zabap2xlsx) INTO lv_errormessage. zcx_excel=>raise_symsg( ). ENDIF. ep_column = lv_modulo. "" Leftmost digit *--------------------------------------------------------------------* * 2nd character if present *--------------------------------------------------------------------* CHECK lv_column+1(1) IS NOT INITIAL. "" No need to continue if string ended lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+1(1) ) MOD zcl_excel_common=>c_excel_col_module. IF lv_modulo < 1 OR lv_modulo > 26. * lv_errormessage = 'Unable to interpret input as column'(003). MESSAGE e800(zabap2xlsx) INTO lv_errormessage. zcx_excel=>raise_symsg( ). ENDIF. ep_column = 26 * ep_column + lv_modulo. "" if second digit is present first digit is for 26^1 *--------------------------------------------------------------------* * 3rd character if present *--------------------------------------------------------------------* CHECK lv_column+2(1) IS NOT INITIAL. "" No need to continue if string ended lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+2(1) ) MOD zcl_excel_common=>c_excel_col_module. IF lv_modulo < 1 OR lv_modulo > 26. * lv_errormessage = 'Unable to interpret input as column'(003). MESSAGE e800(zabap2xlsx) INTO lv_errormessage. zcx_excel=>raise_symsg( ). ENDIF. ep_column = 26 * ep_column + lv_modulo. "" if third digit is present first digit is for 26^2 and second digit for 26^1 ENDDO. *--------------------------------------------------------------------* * Maximum column for EXCEL: XFD = 16384 "" if anyone has a reference for this information - please add here instead of this comment *--------------------------------------------------------------------* IF ep_column > 16384 OR ep_column < 1. lv_errormessage = 'Index out of bounds'(004). zcx_excel=>raise_text( lv_errormessage ). ENDIF. *--------------------------------------------------------------------* * Save succesfull output into cache *--------------------------------------------------------------------* sv_prev_out = ep_column. ENDMETHOD. METHOD convert_columnrow2column_a_row. *--------------------------------------------------------------------* ""issue #256 - replacing char processing with regex *--------------------------------------------------------------------* * Stefan Schmoecker, 2013-08-11 * Allow input to be CLIKE instead of STRING *--------------------------------------------------------------------* DATA: pane_cell_row_a TYPE string, lv_columnrow TYPE string. lv_columnrow = i_columnrow. "" Get rid of trailing blanks FIND REGEX '^(\\D+)(\\d+)$' IN lv_columnrow SUBMATCHES e_column pane_cell_row_a. e_row = pane_cell_row_a. ENDMETHOD. METHOD convert_range2column_a_row. *--------------------------------------------------------------------* * issue #230 - Pimp my Code * - Stefan Schmoecker, (done) 2012-12-07 * - ... * changes: renaming variables to naming conventions * aligning code * added exceptionclass * added errorhandling for invalid range * adding comments to explain what we are trying to achieve *--------------------------------------------------------------------* * issue#241 - error when sheetname contains ""!"" * - sheetname should be returned unescaped * - Stefan Schmoecker, 2012-12-07 * changes: changed coding to support sheetnames with ""!"" * unescaping sheetname *--------------------------------------------------------------------* * issue#155 - lessening restrictions of input parameters * - Stefan Schmoecker, 2012-12-07 * changes: i_range changed to clike * e_sheet changed to clike *--------------------------------------------------------------------* DATA: lv_sheet TYPE string, lv_range TYPE string, lv_columnrow_start TYPE string, lv_columnrow_end TYPE string, lv_position TYPE i, lv_errormessage TYPE string. "" Can't pass '...'(abc) to exception-class *--------------------------------------------------------------------* * Split input range into sheetname and Area * 4 cases - a) input empty --> nothing to do * - b) sheetname existing - starts with ' example 'Sheet 1'!$B$6:$D$13 * - c) sheetname existing - does not start with ' example Sheet1!$B$6:$D$13 * - d) no sheetname - just area example $B$6:$D$13 *--------------------------------------------------------------------* * Initialize output parameters CLEAR: e_column_start, e_column_end, e_row_start, e_row_end, e_sheet. IF i_range IS INITIAL. "" a) input empty --> nothing to do EXIT. ELSEIF i_range(1) = `'`. "" b) sheetname existing - starts with ' FIND REGEX '\\![^\\!]*$' IN i_range MATCH OFFSET lv_position. "" Find last ! IF sy-subrc = 0. lv_sheet = i_range(lv_position). ADD 1 TO lv_position. lv_range = i_range. SHIFT lv_range LEFT BY lv_position PLACES. ELSE. lv_errormessage = 'Invalid range'(001). zcx_excel=>raise_text( lv_errormessage ). ENDIF. ELSEIF i_range CS '!'. "" c) sheetname existing - does not start with ' SPLIT i_range AT '!' INTO lv_sheet lv_range. "" begin Dennis Schaaf IF lv_range CP '*#REF*'. lv_errormessage = 'Invalid range'(001). zcx_excel=>raise_text( lv_errormessage ). ENDIF. "" end Dennis Schaaf ELSE. "" d) no sheetname - just area lv_range = i_range. ENDIF. REPLACE ALL OCCURRENCES OF '$' IN lv_range WITH ''. SPLIT lv_range AT ':' INTO lv_columnrow_start lv_columnrow_end. convert_columnrow2column_a_row( EXPORTING i_columnrow = lv_columnrow_start IMPORTING e_column = e_column_start e_row = e_row_start ). convert_columnrow2column_a_row( EXPORTING i_columnrow = lv_columnrow_end IMPORTING e_column = e_column_end e_row = e_row_end ). e_sheet = unescape_string( lv_sheet ). "" Return in unescaped form ENDMETHOD. METHOD date_to_excel_string. DATA: lv_date_diff TYPE i. CHECK ip_value IS NOT INITIAL AND ip_value <> space. "" Needed hack caused by the problem that: "" Excel 2000 incorrectly assumes that the year 1900 is a leap year "" http://support.microsoft.com/kb/214326/en-us IF ip_value > c_excel_1900_leap_year. lv_date_diff = ip_value - c_excel_baseline_date + 2. ELSE. lv_date_diff = ip_value - c_excel_baseline_date + 1. ENDIF. ep_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_date_diff ). ENDMETHOD. METHOD describe_structure. DATA: lt_components TYPE abap_component_tab, lt_comps TYPE abap_component_tab, ls_component TYPE abap_componentdescr, lo_elemdescr TYPE REF TO cl_abap_elemdescr, ls_dfies TYPE dfies, l_position TYPE tabfdpos. ""for DDIC structure get the info directly IF io_struct->is_ddic_type( ) = abap_true. rt_dfies = io_struct->get_ddic_field_list( ). ELSE. lt_components = io_struct->get_components( ). LOOP AT lt_components INTO ls_component. structure_case( EXPORTING is_component = ls_component CHANGING xt_components = lt_comps ) . ENDLOOP. LOOP AT lt_comps INTO ls_component. CLEAR ls_dfies. IF ls_component-type->kind = cl_abap_typedescr=>kind_elem. ""E Elementary Type ADD 1 TO l_position. lo_elemdescr ?= ls_component-type. IF lo_elemdescr->is_ddic_type( ) = abap_true. ls_dfies = lo_elemdescr->get_ddic_field( ). ls_dfies-fieldname = ls_component-name. ls_dfies-position = l_position. ELSE. ls_dfies-fieldname = ls_component-name. ls_dfies-position = l_position. ls_dfies-inttype = lo_elemdescr->type_kind. ls_dfies-leng = lo_elemdescr->length. ls_dfies-outputlen = lo_elemdescr->length. ls_dfies-decimals = lo_elemdescr->decimals. ls_dfies-fieldtext = ls_component-name. ls_dfies-reptext = ls_component-name. ls_dfies-scrtext_s = ls_component-name. ls_dfies-scrtext_m = ls_component-name. ls_dfies-scrtext_l = ls_component-name. ls_dfies-dynpfld = abap_true. ENDIF. INSERT ls_dfies INTO TABLE rt_dfies. ENDIF. ENDLOOP. ENDIF. ENDMETHOD. METHOD determine_resulting_formula. DATA: lv_row_difference TYPE i, lv_col_difference TYPE i. *--------------------------------------------------------------------* * Calculate distance of reference and current cell *--------------------------------------------------------------------* calculate_cell_distance( EXPORTING iv_reference_cell = iv_reference_cell iv_current_cell = iv_current_cell IMPORTING ev_row_difference = lv_row_difference ev_col_difference = lv_col_difference ). *--------------------------------------------------------------------* * and shift formula by using the row- and columndistance *--------------------------------------------------------------------* ev_resulting_formula = shift_formula( iv_reference_formula = iv_reference_formula iv_shift_rows = lv_row_difference iv_shift_cols = lv_col_difference ). ENDMETHOD. ""determine_resulting_formula METHOD encrypt_password. DATA lv_curr_offset TYPE i. DATA lv_curr_char TYPE c LENGTH 1. DATA lv_curr_hex TYPE zexcel_pwd_hash. DATA lv_pwd_len TYPE zexcel_pwd_hash. DATA lv_pwd_hash TYPE zexcel_pwd_hash. CONSTANTS: lv_0x7fff TYPE zexcel_pwd_hash VALUE '7FFF', lv_0x0001 TYPE zexcel_pwd_hash VALUE '0001', lv_0xce4b TYPE zexcel_pwd_hash VALUE 'CE4B'. DATA lv_pwd TYPE zexcel_aes_password. lv_pwd = i_pwd. lv_pwd_len = strlen( lv_pwd ). lv_curr_offset = lv_pwd_len - 1. WHILE lv_curr_offset GE 0. lv_curr_char = lv_pwd+lv_curr_offset(1). lv_curr_hex = char2hex( lv_curr_char ). lv_pwd_hash = ( shr14( lv_pwd_hash ) BIT-AND lv_0x0001 ) BIT-OR ( shl01( lv_pwd_hash ) BIT-AND lv_0x7fff ). lv_pwd_hash = lv_pwd_hash BIT-XOR lv_curr_hex. SUBTRACT 1 FROM lv_curr_offset. ENDWHILE. lv_pwd_hash = ( shr14( lv_pwd_hash ) BIT-AND lv_0x0001 ) BIT-OR ( shl01( lv_pwd_hash ) BIT-AND lv_0x7fff ). lv_pwd_hash = lv_pwd_hash BIT-XOR lv_0xce4b. lv_pwd_hash = lv_pwd_hash BIT-XOR lv_pwd_len. WRITE lv_pwd_hash TO r_encrypted_pwd. ENDMETHOD. METHOD escape_string. *--------------------------------------------------------------------* * issue #230 - Pimp my Code * - Stefan Schmoecker, (done) 2012-12-08 * - ... * changes: aligning code * adding comments to explain what we are trying to achieve *--------------------------------------------------------------------* * issue#242 - Support escaping for white-spaces * - Escaping also necessary when ' encountered in input * - Stefan Schmoecker, 2012-12-08 * changes: switched check if escaping is necessary to regular expression * and moved the ""REPLACE"" *--------------------------------------------------------------------* * issue#155 - lessening restrictions of input parameters * - Stefan Schmoecker, 2012-12-08 * changes: ip_value changed to clike *--------------------------------------------------------------------* DATA: lv_value TYPE string. *--------------------------------------------------------------------* * There exist various situations when a space will be used to separate * different parts of a string. When we have a string consisting spaces * that will cause errors unless we ""escape"" the string by putting ' at * the beginning and at the end of the string. *--------------------------------------------------------------------* *--------------------------------------------------------------------* * When allowing clike-input parameters we might encounter trailing * ""real"" blanks . These are automatically eliminated when moving * the input parameter to a string. * Now any remaining spaces ( white-spaces or normal spaces ) should * trigger the escaping as well as any ' *--------------------------------------------------------------------* lv_value = ip_value. FIND REGEX `\\s|'` IN lv_value. "" \\s finds regular and white spaces IF sy-subrc = 0. REPLACE ALL OCCURRENCES OF `'` IN lv_value WITH `''`. CONCATENATE `'` lv_value `'` INTO lv_value . ENDIF. ep_escaped_value = lv_value. ENDMETHOD. METHOD excel_string_to_date. DATA: lv_date_int TYPE i. CHECK ip_value IS NOT INITIAL AND ip_value CN ' 0'. TRY. lv_date_int = ip_value. IF lv_date_int NOT BETWEEN 1 AND 2958465. zcx_excel=>raise_text( 'Unable to interpret date' ). ENDIF. ep_value = lv_date_int + c_excel_baseline_date - 2. "" Needed hack caused by the problem that: "" Excel 2000 incorrectly assumes that the year 1900 is a leap year "" http://support.microsoft.com/kb/214326/en-us IF ep_value < c_excel_1900_leap_year. ep_value = ep_value + 1. ENDIF. CATCH cx_sy_conversion_error. zcx_excel=>raise_text( 'Index out of bounds' ). ENDTRY. ENDMETHOD. METHOD excel_string_to_number. * If we encounter anything more complicated in EXCEL we might have to extend this * But currently this works fine - even for numbers in scientific notation ep_value = ip_value. ENDMETHOD. METHOD excel_string_to_time. DATA: lv_seconds_in_day TYPE i, lv_day_fraction TYPE f, lc_seconds_in_day TYPE i VALUE 86400. TRY. lv_day_fraction = ip_value. lv_seconds_in_day = lv_day_fraction * lc_seconds_in_day. ep_value = lv_seconds_in_day. CATCH cx_sy_conversion_error. zcx_excel=>raise_text( 'Unable to interpret time' ). ENDTRY. ENDMETHOD. METHOD get_fieldcatalog. DATA: lr_dref_tab TYPE REF TO data, lo_salv_table TYPE REF TO cl_salv_table, lo_salv_columns_table TYPE REF TO cl_salv_columns_table, lt_salv_t_column_ref TYPE salv_t_column_ref, ls_salv_t_column_ref LIKE LINE OF lt_salv_t_column_ref, lo_salv_column_table TYPE REF TO cl_salv_column_table. FIELD-SYMBOLS: TYPE STANDARD TABLE. FIELD-SYMBOLS: LIKE LINE OF ep_fieldcatalog. * Get copy of IP_TABLE-structure <-- must be changeable to create salv CREATE DATA lr_dref_tab LIKE ip_table. ASSIGN lr_dref_tab->* TO . * Create salv --> implicitly create fieldcat TRY. cl_salv_table=>factory( IMPORTING r_salv_table = lo_salv_table CHANGING t_table = ). lo_salv_columns_table = lo_salv_table->get_columns( ). lt_salv_t_column_ref = lo_salv_columns_table->get( ). CATCH cx_root. * maybe some errorhandling here - just haven't made up my mind yet ENDTRY. * Loop through columns and set relevant fields ( fieldname, texts ) LOOP AT lt_salv_t_column_ref INTO ls_salv_t_column_ref. lo_salv_column_table ?= ls_salv_t_column_ref-r_column. APPEND INITIAL LINE TO ep_fieldcatalog ASSIGNING . -position = sy-tabix. -fieldname = ls_salv_t_column_ref-columnname. -scrtext_s = ls_salv_t_column_ref-r_column->get_short_text( ). -scrtext_m = ls_salv_t_column_ref-r_column->get_medium_text( ). -scrtext_l = ls_salv_t_column_ref-r_column->get_long_text( ). -abap_type = lo_salv_column_table->get_ddic_inttype( ). -dynpfld = 'X'. "" What in the world would we exclude here? "" except for the MANDT-field of most tables ( 1st column that is ) IF -position = 1 AND lo_salv_column_table->get_ddic_datatype( ) = 'CLNT' AND iv_hide_mandt = abap_true. CLEAR -dynpfld. ENDIF. * For fields that don't a description ( i.e. defined by ""field type i,"" ) * just use the fieldname as description - that is better than nothing IF -scrtext_s IS INITIAL AND -scrtext_m IS INITIAL AND -scrtext_l IS INITIAL. CONCATENATE 'Col:' -fieldname INTO -scrtext_l SEPARATED BY space. -scrtext_m = -scrtext_l. -scrtext_s = -scrtext_l. ENDIF. ENDLOOP. ENDMETHOD. METHOD is_cell_in_range. DATA lv_column_start TYPE zexcel_cell_column_alpha. DATA lv_column_end TYPE zexcel_cell_column_alpha. DATA lv_row_start TYPE zexcel_cell_row. DATA lv_row_end TYPE zexcel_cell_row. DATA lv_column_start_i TYPE zexcel_cell_column. DATA lv_column_end_i TYPE zexcel_cell_column. DATA lv_column_i TYPE zexcel_cell_column. * Split range and convert columns convert_range2column_a_row( EXPORTING i_range = ip_range IMPORTING e_column_start = lv_column_start e_column_end = lv_column_end e_row_start = lv_row_start e_row_end = lv_row_end ). lv_column_start_i = convert_column2int( ip_column = lv_column_start ). lv_column_end_i = convert_column2int( ip_column = lv_column_end ). lv_column_i = convert_column2int( ip_column = ip_column ). * Check if cell is in range IF lv_column_i >= lv_column_start_i AND lv_column_i <= lv_column_end_i AND ip_row >= lv_row_start AND ip_row <= lv_row_end. rp_in_range = abap_true. ENDIF. ENDMETHOD. METHOD number_to_excel_string. DATA: lv_value_c TYPE c LENGTH 100. WRITE ip_value TO lv_value_c EXPONENT 0 NO-GROUPING NO-SIGN. REPLACE ALL OCCURRENCES OF ',' IN lv_value_c WITH '.'. ep_value = lv_value_c. CONDENSE ep_value. IF ip_value < 0. CONCATENATE '-' ep_value INTO ep_value. ELSEIF ip_value EQ 0. ep_value = '0'. ENDIF. ENDMETHOD. METHOD recursive_class_to_struct. "" # issue 139 * is working for me - but after looking through this coding I guess * I'll rewrite this to a version w/o recursion * This is private an no one using it so far except me, so no need to hurry DATA: descr TYPE REF TO cl_abap_structdescr, wa_component LIKE LINE OF descr->components, attribute_name TYPE fieldname, flag_class TYPE flag. FIELD-SYMBOLS: TYPE any, TYPE any, TYPE any. descr ?= cl_abap_structdescr=>describe_by_data( e_target ). LOOP AT descr->components INTO wa_component. * Assign structure and X-structure ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO . ASSIGN COMPONENT wa_component-name OF STRUCTURE e_targetx TO . * At least one field in the structure should be marked - otherwise continue with next field CLEAR flag_class. * maybe source is just a structure - try assign component... ASSIGN COMPONENT wa_component-name OF STRUCTURE i_source TO . IF sy-subrc <> 0. * not - then it is an attribute of the class - use different assign then CONCATENATE 'i_source->' wa_component-name INTO attribute_name. ASSIGN (attribute_name) TO . IF sy-subrc <> 0. EXIT. ENDIF. "" Should not happen if structure is built properly - otherwise just exit to create no dumps flag_class = abap_true. ENDIF. CASE wa_component-type_kind. WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. "" Structure --> use recursio * IF flag_class = abap_true. ** Only borders will be passed as unbound references. But since we want to set a value we have to create an instance * ENDIF. zcl_excel_common=>recursive_class_to_struct( EXPORTING i_source = CHANGING e_target = e_targetx = ). WHEN OTHERS. = . = abap_true. ENDCASE. ENDLOOP. ENDMETHOD. METHOD recursive_struct_to_class. "" # issue 139 * is working for me - but after looking through this coding I guess * I'll rewrite this to a version w/o recursion * This is private an no one using it so far except me, so no need to hurry DATA: descr TYPE REF TO cl_abap_structdescr, wa_component LIKE LINE OF descr->components, attribute_name TYPE fieldname, flag_class TYPE flag, o_border TYPE REF TO zcl_excel_style_border. FIELD-SYMBOLS: TYPE any, TYPE any, TYPE any. descr ?= cl_abap_structdescr=>describe_by_data( i_source ). LOOP AT descr->components INTO wa_component. * Assign structure and X-structure ASSIGN COMPONENT wa_component-name OF STRUCTURE i_source TO . ASSIGN COMPONENT wa_component-name OF STRUCTURE i_sourcex TO . * At least one field in the structure should be marked - otherwise continue with next field CHECK CA abap_true. CLEAR flag_class. * maybe target is just a structure - try assign component... ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO . IF sy-subrc <> 0. * not - then it is an attribute of the class - use different assign then CONCATENATE 'E_TARGET->' wa_component-name INTO attribute_name. ASSIGN (attribute_name) TO . IF sy-subrc <> 0.EXIT.ENDIF. "" Should not happen if structure is built properly - otherwise just exit to create no dumps flag_class = abap_true. ENDIF. CASE wa_component-type_kind. WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. "" Structure --> use recursion "" To avoid dump with attribute GRADTYPE of class ZCL_EXCEL_STYLE_FILL "" quick and really dirty fix -> check the attribute name "" Border has to be initialized somewhere else IF wa_component-name EQ 'GRADTYPE'. flag_class = abap_false. ENDIF. IF flag_class = abap_true AND IS INITIAL. * Only borders will be passed as unbound references. But since we want to set a value we have to create an instance CREATE OBJECT o_border. = o_border. ENDIF. zcl_excel_common=>recursive_struct_to_class( EXPORTING i_source = i_sourcex = CHANGING e_target = ). * WHEN cl_abap_structdescr=>typekind_struct2. "" String * CHECK = abap_true. "" Marked for change * = . WHEN OTHERS. CHECK = abap_true. "" Marked for change = . ENDCASE. ENDLOOP. ENDMETHOD. METHOD shift_formula. CONSTANTS: lcv_operators TYPE string VALUE '+-/*^%=<>&, !', lcv_letters TYPE string VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ$', lcv_digits TYPE string VALUE '0123456789', lcv_cell_reference_error TYPE string VALUE '#REF!'. DATA: lv_tcnt TYPE i, "" Counter variable lv_tlen TYPE i, "" Temp variable length lv_cnt TYPE i, "" Counter variable lv_cnt2 TYPE i, "" Counter variable lv_offset1 TYPE i, "" Character offset lv_numchars TYPE i, "" Number of characters counter lv_tchar(1) TYPE c, "" Temp character lv_tchar2(1) TYPE c, "" Temp character lv_cur_form(2000) TYPE c, "" Formula for current cell lv_ref_cell_addr TYPE string, "" Reference cell address lv_tcol1 TYPE string, "" Temp column letter lv_tcol2 TYPE string, "" Temp column letter lv_tcoln TYPE i, "" Temp column number lv_trow1 TYPE string, "" Temp row number lv_trow2 TYPE string, "" Temp row number lv_flen TYPE i, "" Length of reference formula lv_tlen2 TYPE i, "" Temp variable length lv_substr1 TYPE string, "" Substring variable lv_abscol TYPE string, "" Absolute column symbol lv_absrow TYPE string, "" Absolute row symbol lv_errormessage TYPE string. *--------------------------------------------------------------------* * When copying a cell in EXCEL to another cell any inherent formulas * are copied as well. Cell-references in the formula are being adjusted * by the distance of the new cell to the original one *--------------------------------------------------------------------* * §1 Parse reference formula character by character * §2 Identify Cell-references * §3 Shift cell-reference * §4 Build resulting formula *--------------------------------------------------------------------* *--------------------------------------------------------------------* * No distance --> Reference = resulting cell/formula *--------------------------------------------------------------------* IF iv_shift_cols = 0 AND iv_shift_rows = 0. ev_resulting_formula = iv_reference_formula. EXIT. "" done ENDIF. lv_flen = strlen( iv_reference_formula ). lv_numchars = 1. *--------------------------------------------------------------------* * §1 Parse reference formula character by character *--------------------------------------------------------------------* DO lv_flen TIMES. CLEAR: lv_tchar, lv_substr1, lv_ref_cell_addr. lv_cnt2 = lv_cnt + 1. IF lv_cnt2 > lv_flen. EXIT. "" Done ENDIF. *--------------------------------------------------------------------* * Here we have the current character in the formula *--------------------------------------------------------------------* lv_tchar = iv_reference_formula+lv_cnt(1). *--------------------------------------------------------------------* * Operators or opening parenthesis will separate possible cellreferences *--------------------------------------------------------------------* IF ( lv_tchar CA lcv_operators OR lv_tchar CA '(' ) AND lv_cnt2 = 1. lv_substr1 = iv_reference_formula+lv_offset1(1). CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_numchars = 1. CONTINUE. "" --> next character in formula can be analyzed ENDIF. *--------------------------------------------------------------------* * Quoted literal text holds no cell reference --> advance to end of text *--------------------------------------------------------------------* IF lv_tchar EQ '""'. lv_cnt = lv_cnt + 1. lv_numchars = lv_numchars + 1. lv_tchar = iv_reference_formula+lv_cnt(1). WHILE lv_tchar NE '""'. lv_cnt = lv_cnt + 1. lv_numchars = lv_numchars + 1. lv_tchar = iv_reference_formula+lv_cnt(1). ENDWHILE. lv_cnt2 = lv_cnt + 1. lv_substr1 = iv_reference_formula+lv_offset1(lv_numchars). CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. IF lv_cnt = lv_flen. EXIT. ENDIF. lv_offset1 = lv_cnt. lv_numchars = 1. lv_tchar = iv_reference_formula+lv_cnt(1). lv_cnt2 = lv_cnt + 1. CONTINUE. "" --> next character in formula can be analyzed ENDIF. *--------------------------------------------------------------------* * Operators or parenthesis or last character in formula will separate possible cellreferences *--------------------------------------------------------------------* IF lv_tchar CA lcv_operators OR lv_tchar CA '():' OR lv_cnt2 = lv_flen. IF lv_cnt > 0. lv_substr1 = iv_reference_formula+lv_offset1(lv_numchars). *--------------------------------------------------------------------* * Check for text concatenation and functions *--------------------------------------------------------------------* IF ( lv_tchar CA lcv_operators AND lv_tchar EQ lv_substr1 ) OR lv_tchar EQ '('. CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_cnt2 = lv_cnt + 1. lv_numchars = 1. CONTINUE. "" --> next character in formula can be analyzed ENDIF. lv_tlen = lv_cnt2 - lv_offset1. *--------------------------------------------------------------------* * Exclude mathematical operators and closing parentheses *--------------------------------------------------------------------* IF lv_tchar CA lcv_operators OR lv_tchar CA ':)'. IF lv_cnt2 = lv_flen AND lv_numchars = 1. CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_cnt2 = lv_cnt + 1. lv_numchars = 1. CONTINUE. "" --> next character in formula can be analyzed ELSE. lv_tlen = lv_tlen - 1. ENDIF. ENDIF. *--------------------------------------------------------------------* * Capture reference cell address *--------------------------------------------------------------------* TRY. MOVE: iv_reference_formula+lv_offset1(lv_tlen) TO lv_ref_cell_addr. ""Ref cell address CATCH cx_root. lv_errormessage = 'Internal error in Class ZCL_EXCEL_COMMON Method SHIFT_FORMULA Spot 1 '. "" Change to messageclass if possible zcx_excel=>raise_text( lv_errormessage ). ENDTRY. *--------------------------------------------------------------------* * Split cell address into characters and numbers *--------------------------------------------------------------------* CLEAR: lv_tlen, lv_tcnt, lv_tcol1, lv_trow1. lv_tlen = strlen( lv_ref_cell_addr ). IF lv_tlen <> 0. CLEAR: lv_tcnt. DO lv_tlen TIMES. CLEAR: lv_tchar2. lv_tchar2 = lv_ref_cell_addr+lv_tcnt(1). IF lv_tchar2 CA lcv_letters. CONCATENATE lv_tcol1 lv_tchar2 INTO lv_tcol1. ELSEIF lv_tchar2 CA lcv_digits. CONCATENATE lv_trow1 lv_tchar2 INTO lv_trow1. ENDIF. lv_tcnt = lv_tcnt + 1. ENDDO. ENDIF. *--------------------------------------------------------------------* * Check for invalid cell address *--------------------------------------------------------------------* IF lv_tcol1 IS INITIAL OR lv_trow1 IS INITIAL. CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_cnt2 = lv_cnt + 1. lv_numchars = 1. CONTINUE. ENDIF. *--------------------------------------------------------------------* * Check for range names *--------------------------------------------------------------------* CLEAR: lv_tlen. lv_tlen = strlen( lv_tcol1 ). IF lv_tlen GT 3. CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_cnt2 = lv_cnt + 1. lv_numchars = 1. CONTINUE. ENDIF. *--------------------------------------------------------------------* * Check for valid row *--------------------------------------------------------------------* IF lv_trow1 GT 1048576. CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_cnt2 = lv_cnt + 1. lv_numchars = 1. CONTINUE. ENDIF. *--------------------------------------------------------------------* * Check for absolute column or row reference *--------------------------------------------------------------------* CLEAR: lv_tcol2, lv_trow2, lv_abscol, lv_absrow. lv_tlen2 = strlen( lv_tcol1 ) - 1. IF lv_tcol1 IS NOT INITIAL. lv_abscol = lv_tcol1(1). ENDIF. IF lv_tlen2 GE 0. lv_absrow = lv_tcol1+lv_tlen2(1). ENDIF. IF lv_abscol EQ '$' AND lv_absrow EQ '$'. lv_tlen2 = lv_tlen2 - 1. IF lv_tlen2 > 0. lv_tcol1 = lv_tcol1+1(lv_tlen2). ENDIF. lv_tlen2 = lv_tlen2 + 1. ELSEIF lv_abscol EQ '$'. lv_tcol1 = lv_tcol1+1(lv_tlen2). ELSEIF lv_absrow EQ '$'. lv_tcol1 = lv_tcol1(lv_tlen2). ENDIF. *--------------------------------------------------------------------* * Check for valid column *--------------------------------------------------------------------* TRY. lv_tcoln = zcl_excel_common=>convert_column2int( lv_tcol1 ) + iv_shift_cols. CATCH zcx_excel. CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_cnt2 = lv_cnt + 1. lv_numchars = 1. CONTINUE. ENDTRY. *--------------------------------------------------------------------* * Check whether there is a referencing problem *--------------------------------------------------------------------* lv_trow2 = lv_trow1 + iv_shift_rows. IF ( lv_tcoln < 1 AND lv_abscol <> '$' ) "" Maybe we should add here max-column and max row-tests as well. OR ( lv_trow2 < 1 AND lv_absrow <> '$' ). "" Check how EXCEL behaves in this case *--------------------------------------------------------------------* * Referencing problem encountered --> set error *--------------------------------------------------------------------* CONCATENATE lv_cur_form lcv_cell_reference_error INTO lv_cur_form. ELSE. *--------------------------------------------------------------------* * No referencing problems --> adjust row and column *--------------------------------------------------------------------* *--------------------------------------------------------------------* * Adjust column *--------------------------------------------------------------------* IF lv_abscol EQ '$'. CONCATENATE lv_cur_form lv_abscol lv_tcol1 INTO lv_cur_form. ELSEIF iv_shift_cols EQ 0. CONCATENATE lv_cur_form lv_tcol1 INTO lv_cur_form. ELSE. TRY. lv_tcol2 = zcl_excel_common=>convert_column2alpha( lv_tcoln ). CONCATENATE lv_cur_form lv_tcol2 INTO lv_cur_form. CATCH zcx_excel. CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. lv_cnt = lv_cnt + 1. lv_offset1 = lv_cnt. lv_cnt2 = lv_cnt + 1. lv_numchars = 1. CONTINUE. ENDTRY. ENDIF. *--------------------------------------------------------------------* * Adjust row *--------------------------------------------------------------------* IF lv_absrow EQ '$'. CONCATENATE lv_cur_form lv_absrow lv_trow1 INTO lv_cur_form. ELSEIF iv_shift_rows = 0. CONCATENATE lv_cur_form lv_trow1 INTO lv_cur_form. * elseif lv_trow2 < 1. * CONCATENATE lv_cur_form lc_cell_reference_error INTO lv_cur_form. ELSE. CONCATENATE lv_cur_form lv_trow2 INTO lv_cur_form. ENDIF. ENDIF. lv_numchars = 0. IF lv_tchar CA lcv_operators OR lv_tchar CA ':)'. CONCATENATE lv_cur_form lv_tchar INTO lv_cur_form. ENDIF. lv_offset1 = lv_cnt2. ENDIF. ENDIF. lv_numchars = lv_numchars + 1. lv_cnt = lv_cnt + 1. lv_cnt2 = lv_cnt + 1. ENDDO. *--------------------------------------------------------------------* * Return resulting formula *--------------------------------------------------------------------* IF lv_cur_form IS NOT INITIAL. MOVE lv_cur_form TO ev_resulting_formula. ENDIF. ENDMETHOD. METHOD shl01. DATA: lv_bit TYPE i, lv_curr_pos TYPE i VALUE 2, lv_prev_pos TYPE i VALUE 1. DO 15 TIMES. GET BIT lv_curr_pos OF i_pwd_hash INTO lv_bit. SET BIT lv_prev_pos OF r_pwd_hash TO lv_bit. ADD 1 TO lv_curr_pos. ADD 1 TO lv_prev_pos. ENDDO. SET BIT 16 OF r_pwd_hash TO 0. ENDMETHOD. METHOD shr14. DATA: lv_bit TYPE i, lv_curr_pos TYPE i, lv_next_pos TYPE i. r_pwd_hash = i_pwd_hash. DO 14 TIMES. lv_curr_pos = 15. lv_next_pos = 16. DO 15 TIMES. GET BIT lv_curr_pos OF r_pwd_hash INTO lv_bit. SET BIT lv_next_pos OF r_pwd_hash TO lv_bit. SUBTRACT 1 FROM lv_curr_pos. SUBTRACT 1 FROM lv_next_pos. ENDDO. SET BIT 1 OF r_pwd_hash TO 0. ENDDO. ENDMETHOD. METHOD split_file. DATA: lt_hlp TYPE TABLE OF text255, ls_hlp TYPE text255. DATA: lf_ext(10) TYPE c, lf_dot_ext(10) TYPE c. DATA: lf_anz TYPE i, lf_len TYPE i. ** --------------------------------------------------------------------- CLEAR: lt_hlp, ep_file, ep_extension, ep_dotextension. ** Split the whole file at '.' SPLIT ip_file AT '.' INTO TABLE lt_hlp. ** get the extenstion from the last line of table DESCRIBE TABLE lt_hlp LINES lf_anz. IF lf_anz <= 1. ep_file = ip_file. EXIT. ENDIF. READ TABLE lt_hlp INTO ls_hlp INDEX lf_anz. ep_extension = ls_hlp. lf_ext = ls_hlp. IF NOT lf_ext IS INITIAL. CONCATENATE '.' lf_ext INTO lf_dot_ext. ENDIF. ep_dotextension = lf_dot_ext. ** get only the filename lf_len = strlen( ip_file ) - strlen( lf_dot_ext ). IF lf_len > 0. ep_file = ip_file(lf_len). ENDIF. ENDMETHOD. METHOD structure_case. DATA: lt_comp_str TYPE abap_component_tab. CASE is_component-type->kind. WHEN cl_abap_typedescr=>kind_elem. ""E Elementary Type INSERT is_component INTO TABLE xt_components. WHEN cl_abap_typedescr=>kind_table. ""T Table INSERT is_component INTO TABLE xt_components. WHEN cl_abap_typedescr=>kind_struct. ""S Structure lt_comp_str = structure_recursive( is_component = is_component ). INSERT LINES OF lt_comp_str INTO TABLE xt_components. WHEN OTHERS. ""cl_abap_typedescr=>kind_ref or cl_abap_typedescr=>kind_class or cl_abap_typedescr=>kind_intf. * We skip it. for now. ENDCASE. ENDMETHOD. METHOD structure_recursive. DATA: lo_struct TYPE REF TO cl_abap_structdescr, lt_components TYPE abap_component_tab, ls_components TYPE abap_componentdescr. REFRESH rt_components. lo_struct ?= is_component-type. lt_components = lo_struct->get_components( ). LOOP AT lt_components INTO ls_components. structure_case( EXPORTING is_component = ls_components CHANGING xt_components = rt_components ) . ENDLOOP. ENDMETHOD. METHOD time_to_excel_string. DATA: lv_seconds_in_day TYPE i, lv_day_fraction TYPE f, lc_time_baseline TYPE t VALUE '000000', lc_seconds_in_day TYPE i VALUE 86400. lv_seconds_in_day = ip_value - lc_time_baseline. lv_day_fraction = lv_seconds_in_day / lc_seconds_in_day. ep_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_day_fraction ). ENDMETHOD. METHOD unescape_string. CONSTANTS lcv_regex TYPE string VALUE `^'[^']` & `|` & "" Beginning single ' OR `[^']'$` & `|` & "" Trailing single ' OR `[^']'[^']`. "" Single ' somewhere in between DATA: lv_errormessage TYPE string. "" Can't pass '...'(abc) to exception-class *--------------------------------------------------------------------* * This method is used to extract the ""real"" string from an escaped string. * An escaped string can be identified by a beginning ' which must be * accompanied by a trailing ' * All '' in between beginning and trailing ' are treated as single ' *--------------------------------------------------------------------* *--------------------------------------------------------------------* * When allowing clike-input parameters we might encounter trailing * ""real"" blanks . These are automatically eliminated when moving * the input parameter to a string. *--------------------------------------------------------------------* ev_unescaped_string = iv_escaped. "" Pass through if not escaped CHECK ev_unescaped_string IS NOT INITIAL. "" Nothing to do if empty CHECK ev_unescaped_string(1) = `'`. "" Nothing to do if not escaped *--------------------------------------------------------------------* * Remove leading and trailing ' *--------------------------------------------------------------------* REPLACE REGEX `^'(.*)'$` IN ev_unescaped_string WITH '$1'. IF sy-subrc <> 0. lv_errormessage = 'Input not properly escaped - &'(002). zcx_excel=>raise_text( lv_errormessage ). ENDIF. *--------------------------------------------------------------------* * Any remaining single ' should not be here *--------------------------------------------------------------------* FIND REGEX lcv_regex IN ev_unescaped_string. IF sy-subrc = 0. lv_errormessage = 'Input not properly escaped - &'(002). zcx_excel=>raise_text( lv_errormessage ). ENDIF. *--------------------------------------------------------------------* * Replace '' with ' *--------------------------------------------------------------------* REPLACE ALL OCCURRENCES OF `''` IN ev_unescaped_string WITH `'`. ENDMETHOD. ENDCLASS. ",13704,True,2517.4399695669226,median "CLASS zcl_abapgit_popups DEFINITION PUBLIC FINAL CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_ui_factory. PUBLIC SECTION. INTERFACES: zif_abapgit_popups. ALIASES: popup_package_export FOR zif_abapgit_popups~popup_package_export, popup_folder_logic FOR zif_abapgit_popups~popup_folder_logic, popup_object FOR zif_abapgit_popups~popup_object, create_branch_popup FOR zif_abapgit_popups~create_branch_popup, repo_new_offline FOR zif_abapgit_popups~repo_new_offline, branch_list_popup FOR zif_abapgit_popups~branch_list_popup, repo_popup FOR zif_abapgit_popups~repo_popup, popup_to_confirm FOR zif_abapgit_popups~popup_to_confirm, popup_to_inform FOR zif_abapgit_popups~popup_to_inform, popup_to_create_package FOR zif_abapgit_popups~popup_to_create_package, popup_to_create_transp_branch FOR zif_abapgit_popups~popup_to_create_transp_branch, popup_to_select_transports FOR zif_abapgit_popups~popup_to_select_transports, popup_to_select_from_list FOR zif_abapgit_popups~popup_to_select_from_list, branch_popup_callback FOR zif_abapgit_popups~branch_popup_callback, package_popup_callback FOR zif_abapgit_popups~package_popup_callback, popup_transport_request FOR zif_abapgit_popups~popup_transport_request, popup_proxy_bypass FOR zif_abapgit_popups~popup_proxy_bypass. 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 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_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. mo_table_descr ?= cl_abap_tabledescr=>describe_by_data( it_list ). lo_struct_descr ?= mo_table_descr->get_table_line_type( ). lt_components = lo_struct_descr->get_components( ). INSERT INITIAL LINE INTO lt_components ASSIGNING INDEX 1. ASSERT sy-subrc = 0. -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 . MOVE-CORRESPONDING TO . 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 abap_bool, TYPE LINE OF salv_t_row. DATA: 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 . LOOP AT ASSIGNING WHERE (lv_condition). CLEAR . MOVE-CORRESPONDING TO . 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 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 <> 'refs/heads/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. ""#EC NOTEXT 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 ). 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'. ""#EC NOTEXT 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~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' ""#EC NOTEXT 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' ""#EC NOTEXT 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' ""#EC NOTEXT 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' ""#EC NOTEXT 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_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. ""#EC NOTEXT 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. IF sy-subrc = 0. ev_create = abap_true. ELSE. ev_create = abap_false. ENDIF. 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' ""#EC NOTEXT 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_functions TYPE REF TO cl_salv_functions_list, 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_new_offline. DATA: lv_returncode TYPE c, lt_fields TYPE TABLE OF sval, lv_icon_ok TYPE icon-name, lv_button1 TYPE svalbutton-buttontext, lv_icon1 TYPE icon-name, lv_finished TYPE abap_bool, lx_error TYPE REF TO zcx_abapgit_exception. FIELD-SYMBOLS: LIKE LINE OF lt_fields. add_field( EXPORTING iv_tabname = 'ABAPTXT255' iv_fieldname = 'LINE' iv_fieldtext = 'Name' iv_obligatory = abap_true CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'TDEVC' iv_fieldname = 'DEVCLASS' iv_fieldtext = 'Package' iv_obligatory = abap_true CHANGING ct_fields = lt_fields ). add_field( EXPORTING iv_tabname = 'ZABAPGIT' iv_fieldname = 'VALUE' 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 = 'DOKIL' iv_fieldname = 'MASTERLANG' iv_fieldtext = 'Master language only' iv_value = abap_true CHANGING ct_fields = lt_fields ). WHILE lv_finished = abap_false. lv_icon_ok = icon_okay. lv_button1 = 'Create package' ##NO_TEXT. lv_icon1 = icon_folder. CALL FUNCTION 'POPUP_GET_VALUES_USER_BUTTONS' EXPORTING popup_title = 'New Offline Project' programname = sy-cprog formname = 'PACKAGE_POPUP' ok_pushbuttontext = 'OK' icon_ok_push = lv_icon_ok first_pushbutton = lv_button1 icon_button_1 = lv_icon1 second_pushbutton = '' icon_button_2 = '' 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. READ TABLE lt_fields INDEX 1 ASSIGNING . ASSERT sy-subrc = 0. rs_popup-url = -value. READ TABLE lt_fields INDEX 2 ASSIGNING . ASSERT sy-subrc = 0. TRANSLATE -value TO UPPER CASE. rs_popup-package = -value. READ TABLE lt_fields INDEX 3 ASSIGNING . ASSERT sy-subrc = 0. TRANSLATE -value TO UPPER CASE. rs_popup-folder_logic = -value. READ TABLE lt_fields INDEX 4 ASSIGNING . ASSERT sy-subrc = 0. rs_popup-master_lang_only = -value. lv_finished = abap_true. TRY. zcl_abapgit_repo_srv=>get_instance( )->validate_package( iv_package = rs_popup-package iv_chk_exists = abap_false ). validate_folder_logic( rs_popup-folder_logic ). CATCH zcx_abapgit_exception INTO lx_error. "" in case of validation errors we display the popup again MESSAGE lx_error TYPE 'S' DISPLAY LIKE 'E'. CLEAR lv_finished. ENDTRY. ENDWHILE. 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' ##NO_TEXT. 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. ""#EC NOTEXT 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 ##NO_TEXT. 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. ",11082,False,2343.888054097411,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 spark.components { import flash.display.BlendMode; import flash.display.DisplayObject; import flash.geom.Rectangle; import mx.core.FlexVersion; import mx.styles.IAdvancedStyleClient; import mx.core.IFlexModule; import mx.core.IFontContextComponent; import mx.core.IUIComponent; import mx.core.IUITextField; import mx.core.IVisualElement; import mx.core.IVisualElementContainer; import mx.core.UIComponent; import mx.core.mx_internal; import mx.events.FlexEvent; import mx.graphics.shaderClasses.ColorBurnShader; import mx.graphics.shaderClasses.ColorDodgeShader; import mx.graphics.shaderClasses.ColorShader; import mx.graphics.shaderClasses.ExclusionShader; import mx.graphics.shaderClasses.HueShader; import mx.graphics.shaderClasses.LuminosityShader; import mx.graphics.shaderClasses.SaturationShader; import mx.graphics.shaderClasses.SoftLightShader; import mx.styles.ISimpleStyleClient; import mx.styles.IStyleClient; import mx.styles.StyleProtoChain; import spark.components.supportClasses.GroupBase; import spark.core.DisplayObjectSharingMode; import spark.core.IGraphicElement; import spark.core.IGraphicElementContainer; import spark.core.ISharedDisplayObject; import spark.events.ElementExistenceEvent; use namespace mx_internal; //-------------------------------------- // Events //-------------------------------------- /** * Dispatched when a visual element is added to the content holder. * event.element is the visual element that was added. * * @eventType spark.events.ElementExistenceEvent.ELEMENT_ADD * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Event(name=""elementAdd"", type=""spark.events.ElementExistenceEvent"")] /** * Dispatched when a visual element is removed from the content holder. * event.element is the visual element that's being removed. * * @eventType spark.events.ElementExistenceEvent.ELEMENT_REMOVE * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Event(name=""elementRemove"", type=""spark.events.ElementExistenceEvent"")] //-------------------------------------- // Styles //-------------------------------------- /** * Color of text shadows. * * @default #FFFFFF * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""textShadowColor"", type=""uint"", format=""Color"", inherit=""yes"", theme=""mobile"")] /** * Alpha of text shadows. * * @default 0.55 * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""textShadowAlpha"", type=""Number"",inherit=""yes"", minValue=""0.0"", maxValue=""1.0"", theme=""mobile"")] //-------------------------------------- // Excluded APIs //-------------------------------------- [Exclude(name=""addChild"", kind=""method"")] [Exclude(name=""addChildAt"", kind=""method"")] [Exclude(name=""removeChild"", kind=""method"")] [Exclude(name=""removeChildAt"", kind=""method"")] [Exclude(name=""setChildIndex"", kind=""method"")] [Exclude(name=""swapChildren"", kind=""method"")] [Exclude(name=""swapChildrenAt"", kind=""method"")] [Exclude(name=""numChildren"", kind=""property"")] [Exclude(name=""getChildAt"", kind=""method"")] [Exclude(name=""getChildIndex"", kind=""method"")] //-------------------------------------- // Other metadata //-------------------------------------- [ResourceBundle(""components"")] [DefaultProperty(""mxmlContent"")] [IconFile(""Group.png"")] /** * The Group class is the base container class for visual elements. * The Group container takes as children any components that implement * the IUIComponent interface, and any components that implement * the IGraphicElement interface. * Use this container when you want to manage visual children, * both visual components and graphical components. * *

To improve performance and minimize application size, * the Group container cannot be skinned. * If you want to apply a skin, use the SkinnableContainer instead.

* *

Note: The scale grid might not function correctly when there * are DisplayObject children inside of the Group, such as a component * or another Group. If the children are GraphicElement objects, and * they all share the Group's DisplayObject, then the scale grid works * properly.

* *

Setting any of the following properties on a GraphicElement child * requires that GraphicElement to create its own DisplayObject, * thus negating the scale grid properties on the Group.

* *
 *  alpha
 *  blendMode other than BlendMode.NORMAL or ""auto""
 *  colorTransform
 *  filters
 *  mask
 *  matrix
 *  rotation
 *  scaling
 *  3D properties
 *  bounds outside the extent of the Group
 *  
* *

The Group container has the following default characteristics:

* * * * * *
CharacteristicDescription
Default sizeLarge enough to display its children
Minimum size0 pixels
Maximum size10000 pixels wide and 10000 pixels high
* * @mxml * *

The <s:Group> tag inherits all of the tag * attributes of its superclass and adds the following tag attributes:

* *
 *  <s:Group
 *    Properties
 *    blendMode=""auto""
 *    mxmlContent=""null""
 *    scaleGridBottom=""null""
 *    scaleGridLeft=""null""
 *    scaleGridRight=""null""
 *    scaleGridTop=""null""
 *  
 *    Events
 *    elementAdd=""No default""
 *    elementRemove=""No default""
 *  />
 *  
* * @see spark.components.DataGroup * @see spark.components.SkinnableContainer * * @includeExample examples/GroupExample.mxml * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public class Group extends GroupBase implements IVisualElementContainer, IGraphicElementContainer, ISharedDisplayObject { /** * Constructor. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function Group():void { super(); } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- private var needsDisplayObjectAssignment:Boolean = false; private var layeringMode:uint = ITEM_ORDERED_LAYERING; private var numGraphicElements:uint = 0; private static const ITEM_ORDERED_LAYERING:uint = 0; private static const SPARSE_LAYERING:uint = 1; //-------------------------------------------------------------------------- // // Overridden properties // //-------------------------------------------------------------------------- //---------------------------------- // baselinePosition //---------------------------------- /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ override public function get baselinePosition():Number { if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_5) return super.baselinePosition; if (!validateBaselinePosition()) return NaN; var bElement:IVisualElement = baselinePositionElement; // If no baselinePositionElement is specified, use the first element if (bElement == null) { for (var i:int = 0; i < numElements; i++) { var elt:IVisualElement = getElementAt(i); if (elt.includeInLayout) { bElement = elt; break; } } } if (bElement) return bElement.baselinePosition + bElement.y; else return super.baselinePosition; } [Inspectable(category=""General"", enumeration=""noScale,scale"", defaultValue=""noScale"")] /** * @private */ override public function set resizeMode(value:String):void { if (isValidScaleGrid()) { // Force the resize mode to be scale if we // have set scaleGrid properties value = ResizeMode.SCALE; } super.resizeMode = value; } /** * @private */ override public function set scrollRect(value:Rectangle):void { // Work-around for Flash Player bug: if GraphicElements share // the Group's Display Object and cacheAsBitmap is true, the // scrollRect won't function correctly. var previous:Boolean = canShareDisplayObject; super.scrollRect = value; if (numGraphicElements > 0 && previous != canShareDisplayObject) invalidateDisplayObjectOrdering(); if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } /** * @private */ override mx_internal function set hasMouseListeners(value:Boolean):void { if (mouseEnabledWhereTransparent) redrawRequested = true; super.hasMouseListeners = value; } /** * @private */ override public function set width(value:Number):void { if (_width != value) { if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } super.width = value; } /** * @private */ override public function set height(value:Number):void { if (_height != value) { if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } super.height = value; } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // alpha //---------------------------------- [Inspectable(defaultValue=""1.0"", category=""General"", verbose=""1"")] /** * @private */ override public function set alpha(value:Number):void { if (super.alpha == value) return; if (_blendMode == ""auto"") { // If alpha changes from an opaque/transparent (1/0) and translucent // (0 < value < 1), then trigger a blendMode change if ((value > 0 && value < 1 && (super.alpha == 0 || super.alpha == 1)) || ((value == 0 || value == 1) && (super.alpha > 0 && super.alpha < 1))) { blendModeChanged = true; invalidateDisplayObjectOrdering(); invalidateProperties(); } } super.alpha = value; } //---------------------------------- // baselinePositionElement //---------------------------------- private var _baselinePositionElement:IVisualElement; /** * The element used to calculate the GroupBase's baselinePosition * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get baselinePositionElement():IVisualElement { return _baselinePositionElement; } /** * @private */ public function set baselinePositionElement(value:IVisualElement):void { if (value === _baselinePositionElement) return; _baselinePositionElement = value; invalidateParentSizeAndDisplayList(); } //---------------------------------- // blendMode //---------------------------------- /** * @private * Storage for the blendMode property. */ private var _blendMode:String = ""auto""; private var blendModeChanged:Boolean; private var blendShaderChanged:Boolean; [Inspectable(category=""General"", enumeration=""auto,add,alpha,darken,difference,erase,hardlight,invert,layer,lighten,multiply,normal,subtract,screen,overlay,colordodge,colorburn,exclusion,softlight,hue,saturation,color,luminosity"", defaultValue=""auto"")] /** * 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 Player or Adobe AIR sets the value to BlendMode.NORMAL. * *

A value of ""auto"" (the default) is specific to Group's use of * blendMode and indicates that the underlying blendMode should be * BlendMode.NORMAL except when alpha is not * equal to either 0 or 1, when it is set to BlendMode.LAYER. * This behavior ensures that groups have correct * compositing of their graphic objects when the group is translucent.

* * @default ""auto"" * * @see flash.display.DisplayObject#blendMode * @see flash.display.BlendMode * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ override public function get blendMode():String { return _blendMode; } /** * @private */ override public function set blendMode(value:String):void { if (value == _blendMode) return; invalidateProperties(); blendModeChanged = true; //The default blendMode in FXG is 'auto'. There are only //certain cases where this results in a rendering difference, //one being when the alpha of the Group is > 0 and < 1. In that //case we set the blendMode to layer to avoid the performance //overhead that comes with a non-normal blendMode. if (value == ""auto"") { _blendMode = value; // SDK-29631: Use super.$blendMode instead of super.blendMode // since Group completely overrides blendMode and we // want to bypass the extra logic in UIComponent which // has its own override. // TODO (egeorgie): figure out whether we can share some // of that logic in the future. if (((alpha > 0 && alpha < 1) && super.$blendMode != BlendMode.LAYER) || ((alpha == 1 || alpha == 0) && super.$blendMode != BlendMode.NORMAL) ) { invalidateDisplayObjectOrdering(); } } else { var oldValue:String = _blendMode; _blendMode = value; // If one of the non-native Flash blendModes is set, // record the new value and set the appropriate // blendShader on the display object. if (isAIMBlendMode(value)) { blendShaderChanged = true; } // Only need to re-do display object assignment if blendmode was normal // and is changing to something else, or the blend mode was something else // and is going back to normal. This is because display object sharing // only happens when blendMode is normal. if ((oldValue == BlendMode.NORMAL || value == BlendMode.NORMAL) && !(oldValue == BlendMode.NORMAL && value == BlendMode.NORMAL)) { invalidateDisplayObjectOrdering(); } } } //---------------------------------- // mxmlContent //---------------------------------- private var mxmlContentChanged:Boolean = false; private var _mxmlContent:Array; [ArrayElementType(""mx.core.IVisualElement"")] /** * The visual content children for this Group. * * This method is used internally by Flex and is not intended for direct * use by developers. * *

The content items should only be IVisualElement objects. * An mxmlContent Array should not be shared between multiple * Group containers because visual elements can only live in one container * at a time.

* *

If the content is an Array, do not modify the Array * directly. Use the methods defined by the Group class instead.

* * @default null * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function set mxmlContent(value:Array):void { if (createChildrenCalled) { setMXMLContent(value); } else { mxmlContentChanged = true; _mxmlContent = value; // we will validate this in createChildren(); } } /** * @private */ mx_internal function getMXMLContent():Array { if (_mxmlContent) return _mxmlContent.concat(); else return null; } /** * @private * Adds the elements in mxmlContent to the Group. * Flex calls this method automatically; you do not call it directly. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ private function setMXMLContent(value:Array):void { var i:int; // if there's old content and it's different than what // we're trying to set it to, then let's remove all the old // elements first. if (_mxmlContent != null && _mxmlContent != value) { for (i = _mxmlContent.length - 1; i >= 0; i--) { elementRemoved(_mxmlContent[i], i); } } _mxmlContent = (value) ? value.concat() : null; // defensive copy if (_mxmlContent != null) { var n:int = _mxmlContent.length; for (i = 0; i < n; i++) { var elt:IVisualElement = _mxmlContent[i]; // A common mistake is to bind the viewport property of a Scroller // to a group that was defined in the MXML file with a different parent if (elt.parent && (elt.parent != this)) throw new Error(resourceManager.getString(""components"", ""mxmlElementNoMultipleParents"", [elt])); elementAdded(elt, i); } } } //-------------------------------------------------------------------------- // // Properties: ScaleGrid // //-------------------------------------------------------------------------- private var scaleGridChanged:Boolean = false; // store the scaleGrid into a rectangle to save space (top, left, bottom, right); private var scaleGridStorageVariable:Rectangle; //---------------------------------- // scale9Grid //---------------------------------- /** * @private */ override public function set scale9Grid(value:Rectangle):void { if (value != null) { scaleGridTop = value.top; scaleGridBottom = value.bottom; scaleGridLeft = value.left; scaleGridRight = value.right; } else { scaleGridTop = NaN; scaleGridBottom = NaN; scaleGridLeft = NaN; scaleGridRight = NaN; } } //---------------------------------- // scaleGridBottom //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the bottom coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridBottom():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.height; return NaN; } public function set scaleGridBottom(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.height) { scaleGridStorageVariable.height = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } //---------------------------------- // scaleGridLeft //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the left coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridLeft():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.x; return NaN; } public function set scaleGridLeft(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.x) { scaleGridStorageVariable.x = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } //---------------------------------- // scaleGridRight //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the right coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridRight():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.width; return NaN; } public function set scaleGridRight(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.width) { scaleGridStorageVariable.width = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } //---------------------------------- // scaleGridTop //---------------------------------- [Inspectable(category=""General"")] /** * Specifies the top coordinate of the scale grid. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get scaleGridTop():Number { if (scaleGridStorageVariable) return scaleGridStorageVariable.y; return NaN; } public function set scaleGridTop(value:Number):void { if (!scaleGridStorageVariable) scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN); if (value != scaleGridStorageVariable.y) { scaleGridStorageVariable.y = value; scaleGridChanged = true; invalidateProperties(); invalidateDisplayList(); } } private function isValidScaleGrid():Boolean { return !isNaN(scaleGridLeft) && !isNaN(scaleGridTop) && !isNaN(scaleGridRight) && !isNaN(scaleGridBottom); } //-------------------------------------------------------------------------- // // Overridden methods: UIComponent // //-------------------------------------------------------------------------- /** * @private * Whether createChildren() has been called or not. * We use this in the setter for mxmlContent to know * whether to validate the value immediately, or just * wait to let createChildren() do it. */ private var createChildrenCalled:Boolean = false; /** * @private */ override protected function createChildren():void { super.createChildren(); createChildrenCalled = true; if (mxmlContentChanged) { mxmlContentChanged = false; setMXMLContent(_mxmlContent); } } /** * @private */ override public function validateProperties():void { super.validateProperties(); // Property validation happens top-down, so now let's // validate graphic element properties after // calling super.validateProperties() if (numGraphicElements > 0) { var length:int = numElements; for (var i:int = 0; i < length; i++) { var element:IGraphicElement = getElementAt(i) as IGraphicElement; if (element) element.validateProperties(); } } } /** * @private */ override protected function commitProperties():void { super.commitProperties(); invalidatePropertiesFlag = false; if (blendModeChanged) { blendModeChanged = false; // Figure out the correct blendMode value // to set. // SDK-29631: Use super.$blendMode instead of super.blendMode // since Group completely overrides blendMode and we // want to bypass the extra logic in UIComponent which // has its own override. // TODO (egeorgie): figure out whether we can share some // of that logic in the future. if (_blendMode == ""auto"") { if (alpha == 0 || alpha == 1) super.$blendMode = BlendMode.NORMAL; else super.$blendMode = BlendMode.LAYER; } else if (!isAIMBlendMode(_blendMode)) { super.$blendMode = _blendMode; } if (blendShaderChanged) { // The graphic element's blendMode was set to a non-Flash // blendMode. We mimic the look by instantiating the // appropriate shader class and setting the blendShader // property on the displayObject. blendShaderChanged = false; switch(_blendMode) { case ""color"": { super.blendShader = new ColorShader(); break; } case ""colordodge"": { super.blendShader = new ColorDodgeShader(); break; } case ""colorburn"": { super.blendShader = new ColorBurnShader(); break; } case ""exclusion"": { super.blendShader = new ExclusionShader(); break; } case ""hue"": { super.blendShader = new HueShader(); break; } case ""luminosity"": { super.blendShader = new LuminosityShader(); break; } case ""saturation"": { super.blendShader = new SaturationShader(); break; } case ""softlight"": { super.blendShader = new SoftLightShader(); break; } } } } // Due to dependent properties alpha and blendMode there may be a need // for a second pass at committing properties (to ensure our new // blendMode or blendShader is assigned to our underlying display // object). if (invalidatePropertiesFlag) { super.commitProperties(); invalidatePropertiesFlag = false; } if (needsDisplayObjectAssignment) { needsDisplayObjectAssignment = false; assignDisplayObjects(); } if (scaleGridChanged) { // Don't reset scaleGridChanged since we also check it in updateDisplayList if (isValidScaleGrid()) resizeMode = ResizeMode.SCALE; // Force the resizeMode to scale } } /** * @private */ override public function validateSize(recursive:Boolean = false):void { // Since IGraphicElement is not ILayoutManagerClient, we need to make sure we // validate sizes of the elements, even in cases where recursive==false. // Size validation happens bottom-up, so now let's // validate graphic element size before // calling super.validateSize() if (numGraphicElements > 0) { var length:int = numElements; for (var i:int = 0; i < length; i++) { var element:IGraphicElement = getElementAt(i) as IGraphicElement; if (element) element.validateSize(); } } super.validateSize(recursive); } /** * @private */ override public function setActualSize(w:Number, h:Number):void { if (_width != w || _height != h) { if (mouseEnabledWhereTransparent && hasMouseListeners) { // Re-render our mouse event fill if necessary. redrawRequested = true; super.$invalidateDisplayList(); } } super.setActualSize(w, h); } /** * @private */ override public function validateDisplayList():void { // call super.validateDisplayList() and let updateDisplayList() run super.validateDisplayList(); // If the DisplayObject assignment is still not completed, then postpone validation // of the GraphicElements. invalidateDisplayList() will be called during the next // commitProperties() call since needsDisplayObjectAssignment=true, // so we will be re-running validateDisplayList() anyways if (needsDisplayObjectAssignment && invalidatePropertiesFlag) return; // DisplayList validation happens top-down, so we should // validate graphic element DisplayList after // calling super.validateDisplayList(). This is // gets tricky because of graphic-element sharing. We clear // Group's graphic's object in updateDisplayList() and handle the // rest of the DisplayList validation in here. // Iterate through the graphic elements. If an element has a displayObject that has been // invalidated, then validate all graphic elements that draw to this displayObject. // The algorithm assumes that all of the elements that share a displayObject are in between // the element with the shared displayObject and the next element that has a displayObject. var sharedDisplayObject:ISharedDisplayObject = this; if (numGraphicElements > 0) { var length:int = numElements; for (var i:int = 0; i < length; i++) { var element:IGraphicElement = getElementAt(i) as IGraphicElement; if (!element) continue; // Do a special check for layer, we may stumble upon an element with layer != 0 // before we're done with the current shared sequence and we don't want to mark // the sequence as valid, until we reach the next sequence. if (element.depth == 0) { // Is this the start of a new shared sequence? if (element.displayObjectSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT) { // We have finished redrawing the previous sequence if (sharedDisplayObject) sharedDisplayObject.redrawRequested = false; // Start the new sequence sharedDisplayObject = element.displayObject as ISharedDisplayObject; } if (!sharedDisplayObject || sharedDisplayObject.redrawRequested) element.validateDisplayList(); } else { // If we have layering, we don't share the display objects. // Don't update the current sharedDisplayObject var elementDisplayObject:ISharedDisplayObject = element.displayObject as ISharedDisplayObject; if (!elementDisplayObject || elementDisplayObject.redrawRequested) { element.validateDisplayList(); if (elementDisplayObject) elementDisplayObject.redrawRequested = false; } } } } // Mark the last shared displayObject valid if (sharedDisplayObject) sharedDisplayObject.redrawRequested = false; } /** * @private */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { // let user's code (layout) run first before dealing with graphic element // sharing because that's when redraws can be requested super.updateDisplayList(unscaledWidth, unscaledHeight); // Clear the group's graphic because graphic elements might be drawing to it // This isn't needed for DataGroup because there's no DisplayObject sharing // This code exists in updateDisplayList() as opposed to validateDisplayList() // because of compatibility issues since most of this code was // refactored from updateDisplayList() and in to validateDisplayList(). User's code // already assumed that they could call super.updateDisplayList() and then be able to draw // into the Group's graphics object. Because of that, the graphics.clear() call is left // in updateDisplayList() instead of in validateDisplayList() with the rest of the graphic // element sharing code. var sharedDisplayObject:ISharedDisplayObject = this; if (sharedDisplayObject.redrawRequested) { // clear the graphics here. The pattern is usually to call graphics.clear() // before calling super.updateDisplayList() so what happens in super.updateDisplayList() // isn't erased. However, in this case, what happens in super.updateDisplayList() isn't // much, and we want to make sure super.updateDisplayList() runs first since the layout // is what actually triggers the the shareDisplayObject to request to be redrawn. graphics.clear(); drawBackground(); // If a scaleGrid is set, make sure the extent of the groups bounds are filled so // the player will scale our contents as expected. if (isValidScaleGrid() && resizeMode == ResizeMode.SCALE) { graphics.lineStyle(); graphics.beginFill(0, 0); graphics.drawRect(0, 0, 1, 1); graphics.drawRect(measuredWidth - 1, measuredHeight - 1, 1, 1); graphics.endFill(); } } if (scaleGridChanged) { scaleGridChanged = false; if (isValidScaleGrid()) { // Check for DisplayObjects other than overlays var overlayCount:int = _overlay ? _overlay.numDisplayObjects : 0; if (numChildren - overlayCount > 0) throw new Error(resourceManager.getString(""components"", ""scaleGridGroupError"")); super.scale9Grid = new Rectangle(scaleGridLeft, scaleGridTop, scaleGridRight - scaleGridLeft, scaleGridBottom - scaleGridTop); } else { super.scale9Grid = null; } } } /** * @private * TODO (rfrishbe): Most of this code is a duplicate of UIComponent::notifyStyleChangeInChildren, * refactor as appropriate to avoid code duplication once we have a common * child iterator between UIComponent and Group. */ override public function notifyStyleChangeInChildren( styleProp:String, recursive:Boolean):void { if (mxmlContentChanged || !recursive) return; var n:int = numElements; for (var i:int = 0; i < n; i++) { var child:ISimpleStyleClient = getElementAt(i) as ISimpleStyleClient; if (child) { child.styleChanged(styleProp); if (child is IStyleClient) IStyleClient(child).notifyStyleChangeInChildren(styleProp, recursive); } } if (advanceStyleClientChildren != null) { for (var styleClient:Object in advanceStyleClientChildren) { var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient as IAdvancedStyleClient; if (iAdvanceStyleClientChild) { iAdvanceStyleClientChild.styleChanged(styleProp); } } } } /** * @private * TODO (rfrishbe): Most of this code is a duplicate of UIComponent::regenerateStyleCache, * refactor as appropriate to avoid code duplication once we have a common * child iterator between UIComponent and Group. */ override public function regenerateStyleCache(recursive:Boolean):void { // Regenerate the proto chain for this object initProtoChain(); // Recursively call this method on each child. var n:int = numElements; for (var i:int = 0; i < n; i++) { var child:IVisualElement = getElementAt(i); if (child is IStyleClient) { // Does this object already have a proto chain? // If not, there's no need to regenerate a new one. if (IStyleClient(child).inheritingStyles != StyleProtoChain.STYLE_UNINITIALIZED) { IStyleClient(child).regenerateStyleCache(recursive); } } else if (child is IUITextField) { // Does this object already have a proto chain? // If not, there's no need to regenerate a new one. if (IUITextField(child).inheritingStyles) StyleProtoChain.initTextField(IUITextField(child)); } } // Call this method on each non-visual StyleClient if (advanceStyleClientChildren != null) { for (var styleClient:Object in advanceStyleClientChildren) { var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient as IAdvancedStyleClient; if (iAdvanceStyleClientChild && iAdvanceStyleClientChild.inheritingStyles != StyleProtoChain.STYLE_UNINITIALIZED) { iAdvanceStyleClientChild.regenerateStyleCache(recursive); } } } } //-------------------------------------------------------------------------- // // Content management // //-------------------------------------------------------------------------- /** * @private */ override public function get numElements():int { if (_mxmlContent == null) return 0; return _mxmlContent.length; } /** * @private */ override public function getElementAt(index:int):IVisualElement { // check for RangeError: checkForRangeError(index); return _mxmlContent[index]; } /** * @private * Checks the range of index to make sure it's valid */ private function checkForRangeError(index:int, addingElement:Boolean = false):void { // figure out the maximum allowable index var maxIndex:int = (_mxmlContent == null ? -1 : _mxmlContent.length - 1); // if adding an element, we allow an extra index at the end if (addingElement) maxIndex++; if (index < 0 || index > maxIndex) throw new RangeError(resourceManager.getString(""components"", ""indexOutOfRange"", [index])); } /** * @private */ private function isAIMBlendMode(value:String):Boolean { if (value == ""colordodge"" || value ==""colorburn"" || value ==""exclusion"" || value ==""softlight"" || value ==""hue"" || value ==""saturation"" || value ==""color"" || value ==""luminosity"") return true; else return false; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function addElement(element:IVisualElement):IVisualElement { var index:int = numElements; // This handles the case where we call addElement on something // that already is in the list. Let's just handle it silently // and not throw up any errors. if (element.parent == this) index = numElements-1; return addElementAt(element, index); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function addElementAt(element:IVisualElement, index:int):IVisualElement { if (element == this) throw new ArgumentError(resourceManager.getString(""components"", ""cannotAddYourselfAsYourChild"")); // check for RangeError: checkForRangeError(index, true); var host:DisplayObject = element.parent; // This handles the case where we call addElement on something // that already is in the list. Let's just handle it silently // and not throw up any errors. if (host == this) { setElementIndex(element, index); return element; } else if (host is IVisualElementContainer) { // Remove the item from the group if that group isn't this group IVisualElementContainer(host).removeElement(element); } // If we don't have any content yet, initialize it to an empty array if (_mxmlContent == null) _mxmlContent = []; _mxmlContent.splice(index, 0, element); if (!mxmlContentChanged) elementAdded(element, index); scaleGridChanged = true; return element; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function removeElement(element:IVisualElement):IVisualElement { return removeElementAt(getElementIndex(element)); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function removeElementAt(index:int):IVisualElement { // check RangeError checkForRangeError(index); var element:IVisualElement = _mxmlContent[index]; // Need to call elementRemoved before removing the item so anyone listening // for the event can access the item. if (!mxmlContentChanged) elementRemoved(element, index); _mxmlContent.splice(index, 1); return element; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 2.5 * @productversion Flex 4.5 */ public function removeAllElements():void { for (var i:int = numElements - 1; i >= 0; i--) { removeElementAt(i); } } /** * @private */ override public function getElementIndex(element:IVisualElement):int { var index:int = _mxmlContent ? _mxmlContent.indexOf(element) : -1; if (index == -1) throw ArgumentError(resourceManager.getString(""components"", ""elementNotFoundInGroup"", [element])); else return index; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function setElementIndex(element:IVisualElement, index:int):void { // check for RangeError...this is done in addItemAt // but we want to do it before removing the element checkForRangeError(index); if (getElementIndex(element) == index) return; removeElement(element); addElementAt(element, index); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function swapElements(element1:IVisualElement, element2:IVisualElement):void { swapElementsAt(getElementIndex(element1), getElementIndex(element2)); } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function swapElementsAt(index1:int, index2:int):void { checkForRangeError(index1); checkForRangeError(index2); // Make sure that index1 is the smaller index so that addElementAt // doesn't RTE if (index1 > index2) { var temp:int = index2; index2 = index1; index1 = temp; } else if (index1 == index2) return; var element1:IVisualElement = _mxmlContent[index1]; var element2:IVisualElement = _mxmlContent[index2]; // Make sure we do the proper invalidations, but don't dispatch events if (!mxmlContentChanged) { elementRemoved(element1, index1, false /*notifyListeners*/); elementRemoved(element2, index2, false /*notifyListeners*/); } // Step 1: remove // Make sure we remove the bigger index first _mxmlContent.splice(index2, 1); _mxmlContent.splice(index1, 1); // Step 2: swap // Add them in reverse order _mxmlContent.splice(index1, 0, element2); _mxmlContent.splice(index2, 0, element1); // Make sure we do the proper invalidations, but don't dispatch events if (!mxmlContentChanged) { elementAdded(element2, index1, false /*notifyListeners*/); elementAdded(element1, index2, false /*notifyListeners*/); } } //-------------------------------------------------------------------------- // // Content management (internal) // //-------------------------------------------------------------------------- /** * @private */ override public function invalidateLayering():void { if (layeringMode == ITEM_ORDERED_LAYERING) layeringMode = SPARSE_LAYERING; invalidateDisplayObjectOrdering(); } /** * Adds an item to this Group. * Flex calls this method automatically; you do not call it directly. * * @param item The item that was added. * * @param index The index where the item was added. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ mx_internal function elementAdded(element:IVisualElement, index:int, notifyListeners:Boolean = true):void { if (layout) layout.elementAdded(index); if (element.depth != 0) invalidateLayering(); // Set the moduleFactory to the child, but don't overwrite an existing moduleFactory. // Propagate moduleFactory to the child, but don't overwrite an existing moduleFactory. if (element is IFlexModule && IFlexModule(element).moduleFactory == null) { if (moduleFactory != null) IFlexModule(element).moduleFactory = moduleFactory; else if (document is IFlexModule && document.moduleFactory != null) IFlexModule(element).moduleFactory = document.moduleFactory; else if (parent is IFlexModule && IFlexModule(element).moduleFactory != null) IFlexModule(element).moduleFactory = IFlexModule(parent).moduleFactory; } // Set the font context in non-UIComponent children. // UIComponent children use moduleFactory. if (element is IFontContextComponent && !(element is UIComponent) && IFontContextComponent(element).fontContext == null) { IFontContextComponent(element).fontContext = moduleFactory; } if (element is IGraphicElement) { numGraphicElements++; addingGraphicElementChild(element as IGraphicElement); invalidateDisplayObjectOrdering(); } else { // item must be a DisplayObject // if the display object ordering is invalidated (because we have graphic elements // that aren't actually in the display list), then lets just add our item to the end. // If the ordering isn't invalidated, then let's just try to add it to the proper index. if (invalidateDisplayObjectOrdering()) { // This always adds the child to the end of the display list. Any // ordering discrepancies will be fixed up in assignDisplayObjects(). addDisplayObjectToDisplayList(DisplayObject(element)); } else { addDisplayObjectToDisplayList(DisplayObject(element), index); } } if (notifyListeners) { if (hasEventListener(ElementExistenceEvent.ELEMENT_ADD)) dispatchEvent(new ElementExistenceEvent( ElementExistenceEvent.ELEMENT_ADD, false, false, element, index)); if (element is IUIComponent && element.hasEventListener(FlexEvent.ADD)) element.dispatchEvent(new FlexEvent(FlexEvent.ADD)); } invalidateSize(); invalidateDisplayList(); } /** * Removes an item from this Group. * Flex calls this method automatically; you do not call it directly. * * @param index The index of the item that is being removed. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ mx_internal function elementRemoved(element:IVisualElement, index:int, notifyListeners:Boolean = true):void { var childDO:DisplayObject = element as DisplayObject; if (notifyListeners) { if (hasEventListener(ElementExistenceEvent.ELEMENT_REMOVE)) dispatchEvent(new ElementExistenceEvent( ElementExistenceEvent.ELEMENT_REMOVE, false, false, element, index)); if (element is IUIComponent && element.hasEventListener(FlexEvent.REMOVE)) element.dispatchEvent(new FlexEvent(FlexEvent.REMOVE)); } if (element && (element is IGraphicElement)) { numGraphicElements--; removingGraphicElementChild(element as IGraphicElement); } else if (childDO && childDO.parent == this) { super.removeChild(childDO); } invalidateDisplayObjectOrdering(); invalidateSize(); invalidateDisplayList(); if (layout) layout.elementRemoved(index); } /** * @private */ mx_internal function addingGraphicElementChild(child:IGraphicElement):void { // Special case (defensive coding) - if the element was previously // a child of this Group, and it didn't release its previously assigned // DisplayObject when its parent changed, and there's the possibility that // the Group may assign it the same DisplayObject and the same sharing mode, // we still need to invalidate and redraw as the displayObject likely has // been redrawn while the element was not a child of this Group. if (child.displayObject && child.displayObjectSharingMode == DisplayObjectSharingMode.USES_SHARED_OBJECT) invalidateGraphicElementDisplayList(child); child.parentChanged(this); // Sets up the inheritingStyles and nonInheritingStyles objects // and their proto chains so that getStyle() works. // If this object already has some children, // then reinitialize the children's proto chains. if (child is IStyleClient) IStyleClient(child).regenerateStyleCache(true); if (child is ISimpleStyleClient) ISimpleStyleClient(child).styleChanged(null); if (child is IStyleClient) IStyleClient(child).notifyStyleChangeInChildren(null, true); } /** * @private */ mx_internal function removingGraphicElementChild(child:IGraphicElement):void { // First discard the displayObject, as child may decide to destroy it // when parent changes. discardDisplayObject(child); child.parentChanged(null); } /** * Removes the element's DisplayObject from this Group's * display list. * * The Group also ensures any elements that share the * DisplayObject is redrawn. * *

This method doesn't necessarily trigger new DisplayObject * reassignment for the passed in element. * To request new display object reassignment, call the * invalidateGraphicElementSharing() method.

* * @param element The graphic element whose display object is discarded. * @see #invalidateGraphicElementSharing * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ mx_internal function discardDisplayObject(element:IGraphicElement):void { var oldDisplayObject:DisplayObject = element.displayObject; if (!oldDisplayObject) return; // If the element created the display object if (element.displayObjectSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT && oldDisplayObject.parent == this) { super.removeChild(oldDisplayObject); // Redo the shared sequences. invalidateDisplayObjectOrdering(); } else if (oldDisplayObject is ISharedDisplayObject) { // Redraw the shared sequence ISharedDisplayObject(oldDisplayObject).redrawRequested = true; // Make sure we do a pass through the graphic elements and redraw // the invalid ones. We should only redraw, no need to redo the layout. super.$invalidateDisplayList(); } } /** * @private * * Returns true if the Group's display object can be shared with graphic elements * inside the group */ private function get canShareDisplayObject():Boolean { // Work-around for Flash Player bug: if GraphicElements share // the Group's Display Object and cacheAsBitmap is true, the // scrollRect won't function correctly. // We can't even check the cacheAsBitmap property since that will // cause a back buffer allocation, which is another FP bug. if (scrollRect) return false; // We can't share ourselves if we're in blendMode != normal, or we have // to deal with any layering. The reason is because we handle layer = 0 first // in our implementation, and we don't want those to use our display object to // draw into because there could be something further down the line that has // layer < 0. The cases where we are in blendMode != normal is when blendMode // has been explicitly set or blendMode is auto and there is a fractional alpha. return (_blendMode == ""normal"" || _blendMode == ""auto"" && (alpha == 0 || alpha == 1)) && (layeringMode == ITEM_ORDERED_LAYERING); } /** * @private * * Invalidates the display object ordering and will run assignDisplayObjects() * if necessary. * * @return true if the display object ordering needed to be invalidated; * false otherwise. */ private function invalidateDisplayObjectOrdering():Boolean { if (layeringMode == SPARSE_LAYERING || numGraphicElements > 0) { needsDisplayObjectAssignment = true; invalidateProperties(); return true; } return false; } /** * @private * * Called to assign display objects to graphic elements */ private function assignDisplayObjects():void { var topLayerItems:Vector.; var bottomLayerItems:Vector.; var keepLayeringEnabled:Boolean = false; var insertIndex:int = 0; // Keep track of the previous IVisualElement. This is used when // assigning DisplayObjects to the IGraphicElements. // If the Group can share its DisplayObject with the IGraphicElements // then initialize the prevItem with this Group object. var prevItem:IVisualElement; if (canShareDisplayObject) prevItem = this; // Iterate through all of the items var len:int = numElements; for (var i:int = 0; i < len; i++) { var item:IVisualElement = getElementAt(i); if (layeringMode != ITEM_ORDERED_LAYERING) { var layer:Number = item.depth; if (layer != 0) { if (layer > 0) { if (topLayerItems == null) topLayerItems = new Vector.(); topLayerItems.push(item); continue; } else { if (bottomLayerItems == null) bottomLayerItems = new Vector.(); bottomLayerItems.push(item); continue; } } } // this should only get called if layer == 0, or we don't care // about layering (layeringMode == ITEM_ORDERED_LAYERING) insertIndex = assignDisplayObjectTo(item, prevItem, insertIndex); prevItem = item; } // we've done all layer == 0 items. // now let's put the higher z-index ones on next // then we'll handle the ones on bottom, but we'll // insert them in the very beginning (index = 0) if (topLayerItems != null) { keepLayeringEnabled = true; //topLayerItems.sortOn(""layer"",Array.NUMERIC); GroupBase.sortOnLayer(topLayerItems); len = topLayerItems.length; for (i=0;icurElement implements IGraphicElement, then both its * DisplayObject and displayObjectSharingMode will be updated. * * @curElement The current element to assign DisplayObject to * @prevEelement The previous element in the list of elements or null. * @return Returns the display list index after the current element's * DisplayObject. */ private function assignDisplayObjectTo(curElement:IVisualElement, prevElement:IVisualElement, insertIndex:int):int { if (curElement is DisplayObject) { super.setChildIndex(curElement as DisplayObject, insertIndex++); } else if (curElement is IGraphicElement) { var current:IGraphicElement = IGraphicElement(curElement); var previous:IGraphicElement = prevElement as IGraphicElement; var oldDisplayObject:DisplayObject = current.displayObject; var oldSharingMode:String = current.displayObjectSharingMode; if (previous && previous.canShareWithNext(current) && current.canShareWithPrevious(previous) && current.setSharedDisplayObject(previous.displayObject)) { // If we are the second element in the shared sequence, // make sure that the first element has the correct displayObjectSharingMode if (previous.displayObjectSharingMode == DisplayObjectSharingMode.OWNS_UNSHARED_OBJECT) previous.displayObjectSharingMode = DisplayObjectSharingMode.OWNS_SHARED_OBJECT; current.displayObjectSharingMode = DisplayObjectSharingMode.USES_SHARED_OBJECT; } else if (prevElement == this && current.setSharedDisplayObject(this)) { current.displayObjectSharingMode = DisplayObjectSharingMode.USES_SHARED_OBJECT; } else { // We don't want to create new DisplayObjects for elements that // already have created their own their display objects. var ownsDisplayObject:Boolean = oldSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT; // If the element doesn't have a DisplayObject or it doesn't own // the DisplayObject it currently has, then create a new one var displayObject:DisplayObject = oldDisplayObject; if (!ownsDisplayObject || !displayObject) displayObject = current.createDisplayObject(); // Make sure the DisplayObject is at the correct position. // Check displayObject for null, some graphic elements // may choose not to create a DisplayObject during this pass. if (displayObject) addDisplayObjectToDisplayList(displayObject, insertIndex++); current.displayObjectSharingMode = DisplayObjectSharingMode.OWNS_UNSHARED_OBJECT; } invalidateAfterAssignment(current, oldSharingMode, oldDisplayObject); } return insertIndex; } /** * @private * Performs invalidation of the old and new shared sequenences. * If necesary, removes the old display object from the list. */ private function invalidateAfterAssignment(element:IGraphicElement, oldSharingMode:String, oldDisplayObject:DisplayObject):void { // Make sure we remove or mark for redraw the old displayObject var displayObject:DisplayObject = element.displayObject; var sharingMode:String = element.displayObjectSharingMode; if (oldDisplayObject == displayObject && sharingMode == oldSharingMode) return; // Make sure we redraw the display object if (displayObject is ISharedDisplayObject) ISharedDisplayObject(displayObject).redrawRequested = true; // Old display object also needs to be redrawn, in case any other GE still uses it. if (oldDisplayObject is ISharedDisplayObject) ISharedDisplayObject(oldDisplayObject).redrawRequested = true; // Make sure we remove the old display object, if needed if (oldDisplayObject && oldDisplayObject.parent == this && oldDisplayObject != displayObject && oldSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT) super.removeChild(oldDisplayObject); } /** * @private * * If the displayObject is not a child of this Group, then insert it at the * specified index (or at the end of the list, when index is -1). * Else, if the displayObject is already a child of the Group, then simply * adjust its child index. */ private function addDisplayObjectToDisplayList(child:DisplayObject, index:int = -1):void { var overlayCount:int = _overlay ? _overlay.numDisplayObjects : 0; if (child.parent == this) super.setChildIndex(child, index != -1 ? index : super.numChildren - 1 - overlayCount); else super.addChildAt(child, index != -1 ? index : super.numChildren - overlayCount); } /** * Notify the host component that an element has changed and needs to be redrawn. * Group calls the validateDisplayList() method on the IGraphicElement * to give it a chance to redraw. * * @param element The element that has changed. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementDisplayList(element:IGraphicElement):void { if (element.displayObject is ISharedDisplayObject) ISharedDisplayObject(element.displayObject).redrawRequested = true; // Invalidate display list only, no need to run the layout. super.$invalidateDisplayList(); } /** * Notify the host component that an element changed and needs to validate properties. * Group calls the validateProperties() method on the IGraphicElement * to give it a chance to commit its properties. * * @param element The element that has changed. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementProperties(element:IGraphicElement):void { invalidateProperties(); } /** * Notify the host component that an element size has changed. * Group calls the validateSize() method on the IGraphicElement * to give it a chance to validate its size. * * @param element The element that has changed size. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementSize(element:IGraphicElement):void { // Invalidate the size only, no need to run the layout. // Later on, if the size changes, then a layout pass will be triggered. super.$invalidateSize(); } /** * Notify the host that an element layer has changed. * Group re-evaluates the sequences of elements with shared DisplayObjects * and may re-assign the DisplayObjects and redraw the sequences as a result. * * @param element The element that has changed size. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function invalidateGraphicElementSharing(element:IGraphicElement):void { // One of our children have told us they might need a displayObject invalidateDisplayObjectOrdering(); } /** * @private */ override public function addChild(child:DisplayObject):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""addChildError""))); } /** * @private */ override public function addChildAt(child:DisplayObject, index:int):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""addChildAtError""))); } /** * @private */ override public function removeChild(child:DisplayObject):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""removeChildError""))); } /** * @private */ override public function removeChildAt(index:int):DisplayObject { throw(new Error(resourceManager.getString(""components"", ""removeChildAtError""))); } /** * @private */ override public function setChildIndex(child:DisplayObject, index:int):void { throw(new Error(resourceManager.getString(""components"", ""setChildIndexError""))); } /** * @private */ override public function swapChildren(child1:DisplayObject, child2:DisplayObject):void { throw(new Error(resourceManager.getString(""components"", ""swapChildrenError""))); } /** * @private */ override public function swapChildrenAt(index1:int, index2:int):void { throw(new Error(resourceManager.getString(""components"", ""swapChildrenAtError""))); } /** * @private * Override to ensure we set redrawRequested when appropriate. */ override public function set mouseEnabledWhereTransparent(value:Boolean):void { if (value == mouseEnabledWhereTransparent) return; super.mouseEnabledWhereTransparent = value; redrawRequested = true; } //-------------------------------------------------------------------------- // // ISharedDisplayObject // //-------------------------------------------------------------------------- /** * @private */ private var _redrawRequested:Boolean = false; /** * @private * Contains true when any of the IGraphicElement objects that share * this DisplayObject object needs to redraw or the background for the container * needs to be redrawn. * This is used internally * by the Group class and developers don't typically use this. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get redrawRequested():Boolean { return _redrawRequested; } /** * @private */ public function set redrawRequested(value:Boolean):void { _redrawRequested = value; } } } ",16274,True,3263.415559171328,median """!

Controlller zum Speichern/Lesen/Löschen von Varianten

CLASS zcl_dbbr_variant_controller DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_uitb_screen_controller . CONSTANTS: BEGIN OF c_modes, save TYPE int1 VALUE 1, delete TYPE int1 VALUE 3, END OF c_modes . METHODS constructor IMPORTING iv_screen_mode TYPE zdbbr_selscreen_mode if_default_variant_mode TYPE abap_bool OPTIONAL if_alv_mode TYPE abap_bool OPTIONAL iv_entity_id TYPE zsat_entity_id iv_entity_name TYPE zsat_entity_id_raw iv_mode TYPE int1 ir_s_global_data TYPE REF TO zdbbr_global_data ir_t_selfields TYPE REF TO zdbbr_selfield_itab OPTIONAL ir_t_selfields_multi TYPE REF TO zdbbr_selfield_itab OPTIONAL ir_t_multi_or TYPE REF TO zdbbr_or_seltab_itab OPTIONAL io_tabfields TYPE REF TO zcl_dbbr_tabfield_list io_tabfields_grpd TYPE REF TO zcl_dbbr_tabfield_list . METHODS call_variant_f4 . PROTECTED SECTION. PRIVATE SECTION. ALIASES get_report_id FOR zif_uitb_screen_controller~get_report_id . ALIASES get_screen_id FOR zif_uitb_screen_controller~get_screen_id . DATA: BEGIN OF ms_ui_refs, variant_name TYPE REF TO zdbbr_variant_name, variant_text TYPE REF TO ddtext, xfilter_fields TYPE REF TO abap_bool, xoutput_fields TYPE REF TO abap_bool, xsort_fields TYPE REF TO abap_bool, xcolumn_widths TYPE REF TO abap_bool, variant_table_name TYPE REF TO tabname16, variant_query_name TYPE REF TO zsat_query_name, variant_for_table_title TYPE REF TO syst_title, variant_for_query_title TYPE REF TO syst_title, variant_for_cds_title TYPE REF TO syst_title, variant_cds_name TYPE REF TO zsat_cds_view_name, END OF ms_ui_refs . DATA mr_t_selfields TYPE REF TO zdbbr_selfield_itab. DATA mr_t_selfields_multi TYPE REF TO zdbbr_selfield_itab. DATA mr_s_global_data TYPE REF TO zdbbr_global_data. DATA mo_tabfields TYPE REF TO zcl_dbbr_tabfield_list . DATA mo_tabfields_grouped TYPE REF TO zcl_dbbr_tabfield_list . DATA mv_mode TYPE int1 . DATA mr_multi_or_itab TYPE REF TO zdbbr_or_seltab_itab . ""!

Mode for Seleciton Screen of DB Browser

DATA mv_selscreen_mode TYPE zdbbr_selscreen_mode . DATA mv_entity_id TYPE zsat_entity_id. DATA mv_entity_name TYPE zsat_entity_id_raw. DATA mf_default_variant_mode TYPE abap_bool. DATA mf_alv_output TYPE abap_bool. ""!

Delete variant

METHODS delete_variant . ""!

Create new variant

METHODS create_variant . ""!

Creates/updates default variant for given entity

METHODS create_default_variant. ""!

Returns 'X' if there are selection criteria

METHODS exists_criteria RETURNING VALUE(rf_exists) TYPE abap_bool. ""!

Persists the variant from the current data

METHODS persist_variant IMPORTING iv_variant_id TYPE zdbbr_variant_id OPTIONAL. ENDCLASS. CLASS zcl_dbbr_variant_controller IMPLEMENTATION. METHOD call_variant_f4. *&---------------------------------------------------------------------* *& Description: Calls value help for getting existing variant *&---------------------------------------------------------------------* TYPES: BEGIN OF lty_variant_f4, variant_name TYPE zdbbr_variant_name, description TYPE ddtext, has_output_fields TYPE zdbbr_defined_outputfields, has_sort_fields TYPE zdbbr_defined_sortfields, created_by TYPE zsat_created_by, END OF lty_variant_f4. DATA: lt_variants TYPE TABLE OF lty_variant_f4. "" get variants from db zcl_dbbr_variant_factory=>find_variants( EXPORTING iv_variant_name = ms_ui_refs-variant_name->* iv_entity_id = mv_entity_id iv_entity_type = mv_selscreen_mode IMPORTING et_variant_info = DATA(lt_variant_info) ). lt_variants = CORRESPONDING #( lt_variant_info ). DATA(lv_return) = zcl_dbbr_f4_helper=>call_int_table_f4( it_table_search = lt_variants iv_return_field_name = 'VARIANT_NAME' ). IF lv_return IS NOT INITIAL. ms_ui_refs-variant_name->* = lv_return. ENDIF. ENDMETHOD. METHOD constructor. mv_mode = iv_mode. mf_default_variant_mode = if_default_variant_mode. mf_alv_output = if_alv_mode. mv_selscreen_mode = iv_screen_mode. mv_entity_id = iv_entity_id. mv_entity_name = iv_entity_name. mo_tabfields = io_tabfields. mo_tabfields_grouped = io_tabfields_grpd. mr_multi_or_itab = ir_t_multi_or. mr_s_global_data = ir_s_global_data. mr_t_selfields = ir_t_selfields. mr_t_selfields_multi = ir_t_selfields_multi. "" init some global data references DATA(lr_data_cache) = zcl_uitb_data_cache=>get_instance( zif_dbbr_c_report_id=>main ). ms_ui_refs-variant_name = CAST zdbbr_variant_name( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_varnam ) ). ms_ui_refs-variant_text = CAST ddtext( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_vartxt ) ). ms_ui_refs-xsort_fields = CAST boolean( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_xsort ) ). ms_ui_refs-xcolumn_widths = CAST abap_bool( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_has_defined_column_widths ) ). ms_ui_refs-xfilter_fields = CAST #( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_has_selection_criteria ) ). ms_ui_refs-xoutput_fields = CAST boolean( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_xfield ) ). ms_ui_refs-variant_table_name = CAST #( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_tab ) ). ms_ui_refs-variant_for_table_title = CAST syst_title( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_tvar_t ) ). ms_ui_refs-variant_for_query_title = CAST syst_title( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_svar_t ) ). ms_ui_refs-variant_for_cds_title = CAST syst_title( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_t_cds_view_variant ) ). ms_ui_refs-variant_query_name = CAST #( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_scrnam ) ). ms_ui_refs-variant_cds_name = CAST #( lr_data_cache->get_data_ref( zif_dbbr_main_report_var_ids=>c_p_cds_view_name ) ). ENDMETHOD. METHOD create_variant. IF zcl_dbbr_variant_factory=>variant_exists( iv_variant_name = ms_ui_refs-variant_name->* iv_entity_id = mv_entity_id iv_entity_type = mv_selscreen_mode ). IF zcl_dbbr_appl_util=>popup_to_confirm( iv_title = |{ TEXT-ms2 }| iv_query = |{ TEXT-013 } '{ ms_ui_refs-variant_name->* }'. { TEXT-014 } { TEXT-016 }| iv_icon_type = 'ICON_MESSAGE_WARNING' ) <> zif_dbbr_c_global=>c_popup_answers-yes. RETURN. ENDIF. zcl_dbbr_variant_factory=>get_variant( EXPORTING iv_variant_name = ms_ui_refs-variant_name->* iv_entity_id = mv_entity_id iv_entity_type = mv_selscreen_mode if_load_completely = abap_false IMPORTING es_variant = DATA(ls_existing_variant) ). ENDIF. persist_variant( ls_existing_variant-variant_id ). ENDMETHOD. METHOD create_default_variant. persist_variant( ). ENDMETHOD. METHOD persist_variant. DATA(ls_variant) = zcl_dbbr_variant_creator=>create_variant( iv_variant_id = iv_variant_id iv_variant_name = ms_ui_refs-variant_name->* iv_entity_id = mv_entity_id iv_entity_type = mv_selscreen_mode iv_variant_description = ms_ui_refs-variant_text->* if_has_output_fields = ms_ui_refs-xoutput_fields->* if_has_sort_fields = ms_ui_refs-xsort_fields->* it_selfields = COND #( WHEN ms_ui_refs-xfilter_fields->* = abap_true AND mr_t_selfields IS BOUND THEN mr_t_selfields->* ) it_multi_selfields = COND #( WHEN ms_ui_refs-xfilter_fields->* = abap_true AND mr_t_selfields_multi IS BOUND THEN mr_t_selfields_multi->* ) it_multi_or = COND #( WHEN ms_ui_refs-xfilter_fields->* = abap_true AND mr_multi_or_itab IS BOUND THEN mr_multi_or_itab->* ) is_global_data = mr_s_global_data->* ). *.. create user/ddic sort order for output / sorting fields IF ms_ui_refs-xoutput_fields->* = abap_true OR ms_ui_refs-xsort_fields->* = abap_true. DATA(lr_tabfields) = mo_tabfields->copy( ). lr_tabfields->switch_mode( zif_dbbr_c_global=>c_field_chooser_modes-output ). lr_tabfields->sort( ). lr_tabfields->switch_mode( zif_dbbr_c_global=>c_field_chooser_modes-sort ). lr_tabfields->sort( ). *.... clear flag for selected fields lr_tabfields->clear_active_flag( if_clear_selection = abap_true if_clear_output = xsdbool( ms_ui_refs-xoutput_fields->* = abap_false ) if_clear_sort = xsdbool( ms_ui_refs-xsort_fields->* = abap_false ) ). *.... save output / order by fields DATA(lt_fields_ui) = lr_tabfields->get_active_fields( if_consider_output = ms_ui_refs-xoutput_fields->* if_consider_sorted = ms_ui_refs-xsort_fields->* if_consider_selected = abap_false ). ls_variant-fields = CORRESPONDING #( lt_fields_ui ). ENDIF. "" save the variant IF mf_default_variant_mode = abap_true. zcl_dbbr_variant_factory=>save_default_variant( ls_variant ). MESSAGE s095(zdbbr_info) WITH mv_entity_name. ELSE. zcl_dbbr_variant_factory=>save_variant( ls_variant ). MESSAGE s028(zdbbr_info) WITH ms_ui_refs-variant_name->*. ENDIF. zcl_dbbr_screen_helper=>leave_screen( ). ENDMETHOD. METHOD exists_criteria. CLEAR rf_exists. CHECK mr_t_selfields IS BOUND. LOOP AT mr_t_selfields->* ASSIGNING FIELD-SYMBOL() WHERE low IS NOT INITIAL OR high IS NOT INITIAL OR option IS NOT INITIAL. EXIT. ENDLOOP. IF sy-subrc = 0. rf_exists = abap_true. ELSE. *.. Are there any or tuple values rf_exists = xsdbool( mr_multi_or_itab->* IS NOT INITIAL ). ENDIF. ENDMETHOD. METHOD delete_variant. zcl_dbbr_variant_factory=>get_variant( EXPORTING iv_variant_name = ms_ui_refs-variant_name->* iv_entity_id = mv_entity_id iv_entity_type = mv_selscreen_mode if_load_completely = abap_false IMPORTING es_variant = DATA(ls_existing_variant) ). IF ls_existing_variant IS INITIAL. MESSAGE e030(zdbbr_info) WITH ms_ui_refs-variant_name->*. RETURN. ENDIF. zcl_dbbr_variant_factory=>delete_variant( ls_existing_variant-variant_id ). MESSAGE s029(zdbbr_info) WITH ms_ui_refs-variant_name->*. zcl_dbbr_screen_helper=>leave_screen( ). ENDMETHOD. METHOD zif_uitb_screen_controller~call_screen. IF mv_mode = c_modes-save AND ms_ui_refs-variant_name->* IS INITIAL. CLEAR: ms_ui_refs-xoutput_fields->*, ms_ui_refs-xsort_fields->*. ENDIF. ms_ui_refs-xfilter_fields->* = exists_criteria( ). CASE mv_selscreen_mode. WHEN zif_dbbr_c_selscreen_mode=>table. ms_ui_refs-variant_table_name->* = mv_entity_name. WHEN zif_dbbr_c_selscreen_mode=>query. ms_ui_refs-variant_query_name->* = mv_entity_name. WHEN zif_dbbr_c_selscreen_mode=>cds_view. ms_ui_refs-variant_cds_name->* = mv_entity_name. ENDCASE. zcl_uitb_screen_util=>call_screen( iv_screen_id = get_screen_id( ) iv_report_id = get_report_id( ) if_selscreen = abap_true it_object_map = VALUE #( ( variable_name = zif_dbbr_main_report_var_ids=>c_r_variant_controller global_ref = me ) ) iv_start_line = 2 iv_start_column = 10 ). ENDMETHOD. METHOD zif_uitb_screen_controller~cancel. zcl_dbbr_screen_helper=>leave_screen( ). ENDMETHOD. METHOD zif_uitb_screen_controller~free_screen_resources. ENDMETHOD. METHOD zif_uitb_screen_controller~get_report_id. result = zif_dbbr_c_report_id=>main. ENDMETHOD. METHOD zif_uitb_screen_controller~get_screen_id. result = SWITCH #( mv_selscreen_mode WHEN zif_dbbr_c_selscreen_mode=>table THEN zif_dbbr_screen_ids=>c_table_variant WHEN zif_dbbr_c_selscreen_mode=>query THEN zif_dbbr_screen_ids=>c_query_variant WHEN zif_dbbr_c_selscreen_mode=>cds_view THEN zif_dbbr_screen_ids=>c_cds_view_variant ). ENDMETHOD. METHOD zif_uitb_screen_controller~handle_user_command. CASE cv_function_code. WHEN 'ENTER'. CASE mv_mode. WHEN c_modes-delete. delete_variant( ). WHEN c_modes-save. IF mf_default_variant_mode = abap_true. create_default_variant( ). ELSE. create_variant( ). ENDIF. ENDCASE. WHEN 'CANCEL'. zcl_dbbr_screen_helper=>leave_screen( ). ENDCASE. CLEAR cv_function_code. ENDMETHOD. METHOD zif_uitb_screen_controller~pbo. zif_uitb_screen_controller~set_status( ). LOOP AT SCREEN. IF mf_default_variant_mode = abap_true. IF screen-group1 = 'TXT' OR screen-group1 = 'VRN'. screen-active = 0. MODIFY SCREEN. CONTINUE. ENDIF. ENDIF. IF screen-group1 = 'ALV' AND mf_alv_output = abap_false. screen-active = 0. MODIFY SCREEN. CONTINUE. ENDIF. IF screen-name = zif_dbbr_main_report_var_ids=>c_p_tab OR screen-name = zif_dbbr_main_report_var_ids=>c_p_scrnam OR screen-name = zif_dbbr_main_report_var_ids=>c_p_cds_view_name. screen-input = 0. MODIFY SCREEN. ELSEIF screen-group1 = 'GLO'. screen-active = 0. MODIFY SCREEN. ELSEIF ( screen-name = zif_dbbr_main_report_var_ids=>c_p_vartxt OR screen-group1 = 'TXT' ) AND mv_mode <> c_modes-save. screen-active = 0. MODIFY SCREEN. ELSEIF screen-group1 = 'PAR' AND mv_mode <> c_modes-save. screen-active = 0. MODIFY SCREEN FROM screen. ENDIF. ENDLOOP. ENDMETHOD. METHOD zif_uitb_screen_controller~set_status. zcl_uitb_screen_util=>set_selscreen_status( iv_status = '0600' iv_repid = get_report_id( ) ). DATA(lv_title) = SWITCH #( mf_default_variant_mode WHEN abap_false THEN SWITCH string( mv_mode WHEN c_modes-save THEN 'Save variant'(v02) WHEN c_modes-delete THEN 'Delete variant'(v03) ) WHEN abap_true THEN SWITCH string( mv_mode WHEN c_modes-save THEN 'Save Default Variant'(017) ) ). CASE mv_selscreen_mode. WHEN zif_dbbr_c_selscreen_mode=>table. ms_ui_refs-variant_for_table_title->* = lv_title. WHEN zif_dbbr_c_selscreen_mode=>query. ms_ui_refs-variant_for_query_title->* = lv_title. WHEN zif_dbbr_c_selscreen_mode=>cds_view. ms_ui_refs-variant_for_cds_title->* = lv_title. ENDCASE. ENDMETHOD. METHOD zif_uitb_screen_controller~was_not_cancelled. ENDMETHOD. ENDCLASS. ",4131,False,801.3439545004443,median "CLASS zcl_abapgit_object_tabl DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. ALIASES mo_files FOR zif_abapgit_object~mo_files. PROTECTED SECTION. TYPES: BEGIN OF ty_segment_definition, segmentheader TYPE edisegmhd, segmentdefinition TYPE edisegmdef, segmentstructures TYPE STANDARD TABLE OF edisegstru WITH DEFAULT KEY, END OF ty_segment_definition. TYPES: ty_segment_definitions TYPE STANDARD TABLE OF ty_segment_definition WITH DEFAULT KEY. TYPES: BEGIN OF ty_tabl_extras, tddat TYPE tddat, END OF ty_tabl_extras. ""! get additional data like table authorization group ""! @parameter iv_tabname | name of the table METHODS read_extras IMPORTING iv_tabname TYPE ddobjname RETURNING VALUE(rs_tabl_extras) TYPE ty_tabl_extras. ""! Update additional data ""! @parameter iv_tabname | name of the table ""! @parameter is_tabl_extras | additional table data METHODS update_extras IMPORTING iv_tabname TYPE ddobjname is_tabl_extras TYPE ty_tabl_extras. ""! Delete additional data ""! @parameter iv_tabname | name of the table METHODS delete_extras IMPORTING iv_tabname TYPE ddobjname. ""! Serialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @raising zcx_abapgit_exception | Exceptions METHODS serialize_idoc_segment IMPORTING io_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception. ""! Deserialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @parameter iv_package | Target package ""! @parameter rv_deserialized | It's a segment and was desserialized ""! @raising zcx_abapgit_exception | Exceptions METHODS deserialize_idoc_segment IMPORTING io_xml TYPE REF TO zif_abapgit_xml_input iv_package TYPE devclass RETURNING VALUE(rv_deserialized) TYPE abap_bool RAISING zcx_abapgit_exception. ""! Delete the IDoc Segment type if exists ""! @parameter rv_deleted | It's a segment and was deleted ""! @raising zcx_abapgit_exception | Exceptions METHODS delete_idoc_segment RETURNING VALUE(rv_deleted) TYPE abap_bool RAISING zcx_abapgit_exception. PRIVATE SECTION. TYPES: ty_dd03p_tt TYPE STANDARD TABLE OF dd03p . TYPES: BEGIN OF ty_dd02_texts, ddlanguage TYPE dd02t-ddlanguage, ddtext TYPE dd02t-ddtext, END OF ty_dd02_texts, tt_dd02_texts TYPE STANDARD TABLE OF ty_dd02_texts. CONSTANTS c_longtext_id_tabl TYPE dokil-id VALUE 'TB' ##NO_TEXT. CONSTANTS: BEGIN OF c_s_dataname, segment_definition TYPE string VALUE 'SEGMENT_DEFINITION', tabl_extras TYPE string VALUE 'TABL_EXTRAS', END OF c_s_dataname. METHODS clear_dd03p_fields CHANGING !ct_dd03p TYPE ty_dd03p_tt . ""! Check if structure is an IDoc segment ""! @parameter rv_is_idoc_segment | It's an IDoc segment or not METHODS is_idoc_segment RETURNING VALUE(rv_is_idoc_segment) TYPE abap_bool. METHODS clear_dd03p_fields_common CHANGING !cs_dd03p TYPE dd03p . METHODS clear_dd03p_fields_dataelement CHANGING !cs_dd03p TYPE dd03p . METHODS: serialize_texts IMPORTING io_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception, deserialize_texts IMPORTING io_xml TYPE REF TO zif_abapgit_xml_input is_dd02v TYPE dd02v RAISING zcx_abapgit_exception. ENDCLASS. CLASS zcl_abapgit_object_tabl IMPLEMENTATION. METHOD clear_dd03p_fields. CONSTANTS lc_comptype_dataelement TYPE comptype VALUE 'E'. DATA: lv_masklen TYPE c LENGTH 4. FIELD-SYMBOLS: TYPE dd03p. * remove nested structures DELETE ct_dd03p WHERE depth <> '00'. * remove fields from .INCLUDEs DELETE ct_dd03p WHERE adminfield <> '0'. LOOP AT ct_dd03p ASSIGNING WHERE NOT rollname IS INITIAL. clear_dd03p_fields_common( CHANGING cs_dd03p = ). lv_masklen = -masklen. IF lv_masklen = '' OR NOT lv_masklen CO '0123456789'. * make sure the field contains valid data, or the XML will dump CLEAR -masklen. ENDIF. IF -comptype = lc_comptype_dataelement. clear_dd03p_fields_dataelement( CHANGING cs_dd03p = ). ENDIF. IF -shlporigin = 'D'. * search help from domain CLEAR: -shlpfield, -shlpname. ENDIF. * XML output assumes correct field content IF -routputlen = ' '. CLEAR -routputlen. ENDIF. ENDLOOP. ENDMETHOD. METHOD clear_dd03p_fields_common. CLEAR: cs_dd03p-ddlanguage, cs_dd03p-dtelmaster, cs_dd03p-logflag, cs_dd03p-ddtext, cs_dd03p-reservedte, cs_dd03p-reptext, cs_dd03p-scrtext_s, cs_dd03p-scrtext_m, cs_dd03p-scrtext_l. ENDMETHOD. METHOD clear_dd03p_fields_dataelement. * type specified via data element CLEAR: cs_dd03p-domname, cs_dd03p-inttype, cs_dd03p-intlen, cs_dd03p-mask, cs_dd03p-memoryid, cs_dd03p-headlen, cs_dd03p-scrlen1, cs_dd03p-scrlen2, cs_dd03p-scrlen3, cs_dd03p-datatype, cs_dd03p-leng, cs_dd03p-outputlen, cs_dd03p-deffdname, cs_dd03p-convexit, cs_dd03p-entitytab, cs_dd03p-dommaster, cs_dd03p-domname3l, cs_dd03p-decimals, cs_dd03p-lowercase, cs_dd03p-signflag. ENDMETHOD. METHOD delete_extras. DELETE FROM tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD delete_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. IF is_idoc_segment( ) = abap_false. rv_deleted = abap_false. RETURN. ""previous XML version or no IDoc segment ENDIF. rv_deleted = abap_true. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_DELETE' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD deserialize_idoc_segment. DATA lv_result LIKE sy-subrc. DATA lt_segment_definitions TYPE ty_segment_definitions. DATA lv_package TYPE devclass. DATA lv_uname TYPE sy-uname. FIELD-SYMBOLS TYPE ty_segment_definition. rv_deserialized = abap_false. TRY. io_xml->read( EXPORTING iv_name = c_s_dataname-segment_definition CHANGING cg_data = lt_segment_definitions ). CATCH zcx_abapgit_exception. RETURN. ""previous XML version or no IDoc segment ENDTRY. IF lines( lt_segment_definitions ) = 0. RETURN. ""no IDoc segment ENDIF. rv_deserialized = abap_true. lv_package = iv_package. LOOP AT lt_segment_definitions ASSIGNING . -segmentheader-presp = -segmentheader-pwork = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = -segmentheader-segtyp IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. CALL FUNCTION 'SEGMENT_CREATE' IMPORTING segmentdefinition = -segmentdefinition TABLES segmentstructure = -segmentstructures CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. ELSE. CALL FUNCTION 'SEGMENT_MODIFY' CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. CALL FUNCTION 'SEGMENTDEFINITION_MODIFY' TABLES segmentstructure = -segmentstructures CHANGING segmentdefinition = -segmentdefinition EXCEPTIONS OTHERS = 1. ENDIF. ENDIF. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDLOOP. lv_uname = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_test_modus = abap_false wi_tadir_pgmid = 'R3TR' wi_tadir_object = ms_item-obj_type wi_tadir_obj_name = ms_item-obj_name wi_tadir_author = lv_uname wi_tadir_devclass = iv_package wi_tadir_masterlang = mv_language iv_set_edtflag = abap_true iv_delflag = abap_false EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from TR_TADIR_INTERFACE' ). ENDIF. ENDMETHOD. METHOD deserialize_texts. DATA: lv_name TYPE ddobjname, ls_dd02v_tmp TYPE dd02v, lt_i18n_langs TYPE TABLE OF langu, lt_dd02_texts TYPE tt_dd02_texts. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. lv_name = ms_item-obj_name. io_xml->read( EXPORTING iv_name = 'I18N_LANGS' CHANGING cg_data = lt_i18n_langs ). io_xml->read( EXPORTING iv_name = 'DD02_TEXTS' CHANGING cg_data = lt_dd02_texts ). SORT lt_i18n_langs. SORT lt_dd02_texts BY ddlanguage. "" Optimization LOOP AT lt_i18n_langs ASSIGNING . "" Table description ls_dd02v_tmp = is_dd02v. READ TABLE lt_dd02_texts ASSIGNING WITH KEY ddlanguage = . IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |DD02_TEXTS cannot find lang { } in XML| ). ENDIF. MOVE-CORRESPONDING TO ls_dd02v_tmp. CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v_tmp EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |error from DDIF_TABL_PUT @TEXTS, { sy-subrc }| ). ENDIF. ENDLOOP. ENDMETHOD. METHOD is_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. lv_segment_type = ms_item-obj_name. SELECT SINGLE segtyp FROM edisegment INTO lv_segment_type WHERE segtyp = lv_segment_type. rv_is_idoc_segment = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD read_extras. SELECT SINGLE * FROM tddat INTO rs_tabl_extras-tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD serialize_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. DATA lv_devclass TYPE devclass. DATA lt_segmentdefinitions TYPE STANDARD TABLE OF edisegmdef. DATA ls_segment_definition TYPE ty_segment_definition. DATA lt_segment_definitions TYPE ty_segment_definitions. FIELD-SYMBOLS: TYPE edisegmdef. IF is_idoc_segment( ) = abap_false. RETURN. ENDIF. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result TABLES segmentdefinition = lt_segmentdefinitions EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. LOOP AT lt_segmentdefinitions ASSIGNING . CLEAR ls_segment_definition. CALL FUNCTION 'SEGMENTDEFINITION_READ' EXPORTING segmenttyp = -segtyp IMPORTING result = lv_result devclass = lv_devclass segmentheader = ls_segment_definition-segmentheader segmentdefinition = ls_segment_definition-segmentdefinition TABLES segmentstructure = ls_segment_definition-segmentstructures CHANGING version = -version EXCEPTIONS no_authority = 1 segment_not_existing = 2 OTHERS = 3. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentdefinition ). zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentheader ). APPEND ls_segment_definition TO lt_segment_definitions. ENDLOOP. io_xml->add( iv_name = c_s_dataname-segment_definition ig_data = lt_segment_definitions ). ENDMETHOD. METHOD serialize_texts. DATA: lv_name TYPE ddobjname, lv_index TYPE i, ls_dd02v TYPE dd02v, lt_dd02_texts TYPE tt_dd02_texts, lt_i18n_langs TYPE TABLE OF langu. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. IF io_xml->i18n_params( )-serialize_master_lang_only = abap_true. RETURN. ENDIF. lv_name = ms_item-obj_name. "" Collect additional languages, skip master lang - it was serialized already SELECT DISTINCT ddlanguage AS langu INTO TABLE lt_i18n_langs FROM dd02v WHERE tabname = lv_name AND ddlanguage <> mv_language. ""#EC CI_SUBRC LOOP AT lt_i18n_langs ASSIGNING . lv_index = sy-tabix. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = IMPORTING dd02v_wa = ls_dd02v EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0 OR ls_dd02v-ddlanguage IS INITIAL. DELETE lt_i18n_langs INDEX lv_index. "" Don't save this lang CONTINUE. ENDIF. APPEND INITIAL LINE TO lt_dd02_texts ASSIGNING . MOVE-CORRESPONDING ls_dd02v TO . ENDLOOP. SORT lt_i18n_langs ASCENDING. SORT lt_dd02_texts BY ddlanguage ASCENDING. IF lines( lt_i18n_langs ) > 0. io_xml->add( iv_name = 'I18N_LANGS' ig_data = lt_i18n_langs ). io_xml->add( iv_name = 'DD02_TEXTS' ig_data = lt_dd02_texts ). ENDIF. ENDMETHOD. METHOD update_extras. IF is_tabl_extras-tddat IS INITIAL. delete_extras( iv_tabname = iv_tabname ). ELSE. MODIFY tddat FROM is_tabl_extras-tddat. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~changed_by. TYPES: BEGIN OF ty_data, as4user TYPE dd02l-as4user, as4date TYPE dd02l-as4date, as4time TYPE dd02l-as4time, END OF ty_data. DATA: lt_data TYPE STANDARD TABLE OF ty_data WITH DEFAULT KEY, ls_data LIKE LINE OF lt_data. SELECT as4user as4date as4time FROM dd02l INTO TABLE lt_data WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd09l WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd12l WHERE sqltab = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SORT lt_data BY as4date DESCENDING as4time DESCENDING. READ TABLE lt_data INDEX 1 INTO ls_data. IF sy-subrc = 0. rv_user = ls_data-as4user. ELSE. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lv_objname TYPE rsedd0-ddobjname, lv_tabclass TYPE dd02l-tabclass, lv_no_ask TYPE abap_bool, lv_subrc TYPE sy-subrc, lr_data TYPE REF TO data. FIELD-SYMBOLS: TYPE any. IF zif_abapgit_object~exists( ) = abap_false. "" Proxies e.g. delete on its own, nothing todo here then. RETURN. ENDIF. lv_objname = ms_item-obj_name. IF delete_idoc_segment( ) = abap_false. lv_no_ask = abap_true. SELECT SINGLE tabclass FROM dd02l INTO lv_tabclass WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. IF sy-subrc = 0 AND lv_tabclass = 'TRANSP'. "" Avoid dump in dynamic SELECT in case the table does not exist on database CALL FUNCTION 'DB_EXISTS_TABLE' EXPORTING tabname = lv_objname IMPORTING subrc = lv_subrc. IF lv_subrc = 0. "" it cannot delete table with data without asking CREATE DATA lr_data TYPE (lv_objname). ASSIGN lr_data->* TO . SELECT SINGLE * FROM (lv_objname) INTO . IF sy-subrc = 0. lv_no_ask = abap_false. ENDIF. ENDIF. ENDIF. delete_ddic( iv_objtype = 'T' iv_no_ask = lv_no_ask ). delete_longtexts( c_longtext_id_tabl ). delete_extras( iv_tabname = lv_objname ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lv_name TYPE ddobjname, lv_tname TYPE trobj_name, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE TABLE OF dd03p, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, ls_dd17v LIKE LINE OF lt_dd17v, lt_secondary LIKE lt_dd17v, lt_dd35v TYPE TABLE OF dd35v, lt_dd36m TYPE dd36mttyp, ls_dd12v LIKE LINE OF lt_dd12v, lv_refs TYPE abap_bool, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: TYPE dd03p. IF deserialize_idoc_segment( io_xml = io_xml iv_package = iv_package ) = abap_false. io_xml->read( EXPORTING iv_name = 'DD02V' CHANGING cg_data = ls_dd02v ). io_xml->read( EXPORTING iv_name = 'DD09L' CHANGING cg_data = ls_dd09l ). io_xml->read( EXPORTING iv_name = 'DD03P_TABLE' CHANGING cg_data = lt_dd03p ). "" DDIC Step: Replace REF TO class/interface with generic reference to avoid cyclic dependency LOOP AT lt_dd03p ASSIGNING WHERE datatype = 'REF'. IF iv_step = zif_abapgit_object=>gc_step_id-ddic. -rollname = 'OBJECT'. ELSE. lv_refs = abap_true. ENDIF. ENDLOOP. io_xml->read( EXPORTING iv_name = 'DD05M_TABLE' CHANGING cg_data = lt_dd05m ). io_xml->read( EXPORTING iv_name = 'DD08V_TABLE' CHANGING cg_data = lt_dd08v ). io_xml->read( EXPORTING iv_name = 'DD12V' CHANGING cg_data = lt_dd12v ). io_xml->read( EXPORTING iv_name = 'DD17V' CHANGING cg_data = lt_dd17v ). io_xml->read( EXPORTING iv_name = 'DD35V_TALE' CHANGING cg_data = lt_dd35v ). io_xml->read( EXPORTING iv_name = 'DD36M' CHANGING cg_data = lt_dd36m ). "" DDIC Step: Remove referenced to search helps IF iv_step = zif_abapgit_object=>gc_step_id-ddic. CLEAR: lt_dd35v, lt_dd36m. ENDIF. IF iv_step = zif_abapgit_object=>gc_step_id-late AND lv_refs = abap_false AND lines( lt_dd35v ) = 0. RETURN. "" already active ENDIF. corr_insert( iv_package = iv_package ig_object_class = 'DICT' ). lv_name = ms_item-obj_name. "" type conversion CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_TABL_PUT' ). ENDIF. zcl_abapgit_objects_activation=>add_item( ms_item ). * handle indexes LOOP AT lt_dd12v INTO ls_dd12v. * todo, call corr_insert? CLEAR lt_secondary. LOOP AT lt_dd17v INTO ls_dd17v WHERE sqltab = ls_dd12v-sqltab AND indexname = ls_dd12v-indexname. APPEND ls_dd17v TO lt_secondary. ENDLOOP. CALL FUNCTION 'DDIF_INDX_PUT' EXPORTING name = ls_dd12v-sqltab id = ls_dd12v-indexname dd12v_wa = ls_dd12v TABLES dd17v_tab = lt_secondary EXCEPTIONS indx_not_found = 1 name_inconsistent = 2 indx_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_INDX_PUT' ). ENDIF. CALL FUNCTION 'DD_DD_TO_E071' EXPORTING type = 'INDX' name = ls_dd12v-sqltab id = ls_dd12v-indexname IMPORTING obj_name = lv_tname. zcl_abapgit_objects_activation=>add( iv_type = 'INDX' iv_name = lv_tname ). ENDLOOP. deserialize_texts( io_xml = io_xml is_dd02v = ls_dd02v ). deserialize_longtexts( io_xml ). io_xml->read( EXPORTING iv_name = c_s_dataname-tabl_extras CHANGING cg_data = ls_extras ). update_extras( iv_tabname = lv_name is_tabl_extras = ls_extras ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_tabname TYPE dd02l-tabname. lv_tabname = ms_item-obj_name. CALL FUNCTION 'DD_GET_NAMETAB_HEADER' EXPORTING tabname = lv_tabname EXCEPTIONS not_found = 1 OTHERS = 2. rv_bool = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. DATA: li_local_version_output TYPE REF TO zif_abapgit_xml_output, li_local_version_input TYPE REF TO zif_abapgit_xml_input. CREATE OBJECT li_local_version_output TYPE zcl_abapgit_xml_output. me->zif_abapgit_object~serialize( li_local_version_output ). CREATE OBJECT li_local_version_input TYPE zcl_abapgit_xml_input EXPORTING iv_xml = li_local_version_output->render( ). CREATE OBJECT ri_comparator TYPE zcl_abapgit_object_tabl_compar EXPORTING ii_local = li_local_version_input. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-ddic TO rt_steps. APPEND zif_abapgit_object=>gc_step_id-late TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). rs_metadata-ddic = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'ESDICT' iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. jump_se11( iv_radio = 'RSRD1-DDTYPE' iv_field = 'RSRD1-DDTYPE_VAL' ). ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lv_name TYPE ddobjname, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE ty_dd03p_tt, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, lt_dd35v TYPE TABLE OF dd35v, lv_index LIKE sy-index, lt_dd36m TYPE dd36mttyp, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: LIKE LINE OF lt_dd12v, LIKE LINE OF lt_dd05m, LIKE LINE OF lt_dd36m, TYPE any. lv_name = ms_item-obj_name. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = mv_language IMPORTING dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd12v_tab = lt_dd12v dd17v_tab = lt_dd17v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_TABL_GET' ). ENDIF. IF ls_dd02v IS INITIAL. RETURN. "" object does not exits ENDIF. CLEAR: ls_dd02v-as4user, ls_dd02v-as4date, ls_dd02v-as4time. * reset numeric field, so XML does not crash IF ls_dd02v-prozpuff = ''. CLEAR ls_dd02v-prozpuff. ENDIF. IF ls_dd02v-datmin = ''. CLEAR ls_dd02v-datmin. ENDIF. IF ls_dd02v-datmax = ''. CLEAR ls_dd02v-datmax. ENDIF. IF ls_dd02v-datavg = ''. CLEAR ls_dd02v-datavg. ENDIF. CLEAR: ls_dd09l-as4user, ls_dd09l-as4date, ls_dd09l-as4time. ASSIGN COMPONENT 'ROWORCOLST' OF STRUCTURE ls_dd09l TO . IF sy-subrc = 0 AND = 'C'. CLEAR . ""To avoid diff errors. This field doesn't exists in all releases ENDIF. LOOP AT lt_dd12v ASSIGNING . CLEAR: -as4user, -as4date, -as4time. ENDLOOP. clear_dd03p_fields( CHANGING ct_dd03p = lt_dd03p ). * remove foreign keys inherited from .INCLUDEs DELETE lt_dd08v WHERE noinherit = 'N'. LOOP AT lt_dd05m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd08v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd05m INDEX lv_index. ENDIF. ENDLOOP. * remove inherited search helps DELETE lt_dd35v WHERE shlpinher = abap_true. LOOP AT lt_dd36m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd35v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd36m INDEX lv_index. ENDIF. ENDLOOP. io_xml->add( iv_name = 'DD02V' ig_data = ls_dd02v ). IF NOT ls_dd09l IS INITIAL. io_xml->add( iv_name = 'DD09L' ig_data = ls_dd09l ). ENDIF. io_xml->add( iv_name = 'DD03P_TABLE' ig_data = lt_dd03p ). io_xml->add( iv_name = 'DD05M_TABLE' ig_data = lt_dd05m ). io_xml->add( iv_name = 'DD08V_TABLE' ig_data = lt_dd08v ). io_xml->add( iv_name = 'DD12V' ig_data = lt_dd12v ). io_xml->add( iv_name = 'DD17V' ig_data = lt_dd17v ). io_xml->add( iv_name = 'DD35V_TALE' ig_data = lt_dd35v ). io_xml->add( iv_name = 'DD36M' ig_data = lt_dd36m ). serialize_texts( io_xml ). serialize_longtexts( ii_xml = io_xml iv_longtext_id = c_longtext_id_tabl ). serialize_idoc_segment( io_xml ). ls_extras = read_extras( iv_tabname = lv_name ). io_xml->add( iv_name = c_s_dataname-tabl_extras ig_data = ls_extras ). ENDMETHOD. ENDCLASS. ",8171,False,1732.007875113087,median "package snooker { import flash.utils.getTimer; /* * The dimensions used in the game engine are: * Table width (cushion-to-cushion): 1713.1 * Table height (cushion-to-cushion): 853.4 * Ball radius: 12.6 * Pocket radius: 22.5 * Baulk-line position: 353.8 (from left) * D-radius: 140.2 * * These are hardcoded into the engine code for performance reasons as the ActionScript * compiler does not substitute expressions involving 'const' variables. * * The coordinate system used by code in the game engine has the origin at the upper left corner * of the table's playable area (i.e. without the cushions) */ public final class GameEngine { /** * Set this to true to enable debug tracing of the table state on every shot. */ public static var enableShotDebugTracing: Boolean = false; /** * The positions of the balls at the start of the game. */ internal static const initialBallPositions: Vector. = new [ 255.0, 490.0, // Cue ball 353.8, 566.9, // Yellow 353.8, 286.5, // Green 353.8, 426.7, // Brown 856.6, 426.7, // Blue 1284.8, 426.7, // Pink 1557.6, 426.7, // Black // Reds... 1311.3, 426.7, 1333.2, 414.1, 1333.2, 439.3, 1355.1, 401.5, 1355.1, 426.7, 1355.1, 451.9, 1377.0, 388.9, 1377.0, 414.1, 1377.0, 439.3, 1377.0, 464.5, 1398.9, 376.3, 1398.9, 401.5, 1398.9, 426.7, 1398.9, 451.9, 1398.9, 477.1, ]; /** * The cushion data. */ public static const cushions: Vector. = new [ // Left new Cushion( new [-22.7, 849.6, 0.0, 801.6, 0.0, 51.8, -22.7, 3.8], new [0.90401, 0.42752, 1.00000, 0.00000, 0.90401, -0.42752, -1.00000, 0.00000] ), // Top left new Cushion( new [3.8, -22.7, 51.8, 0.0, 799.4, 0.0, 837.6, -22.7], new [-0.42752, 0.90401, 0.00000, 1.00000, 0.51085, 0.85967, 0.00000, -1.00000] ), // Top right new Cushion( new [875.5, -22.7, 913.7, 0.0, 1661.3, 0.0, 1709.3, -22.7], new [-0.51085, 0.85967, 0.00000, 1.00000, 0.42752, 0.90401, 0.00000, -1.00000] ), // Right new Cushion( new [1735.8, 3.8, 1713.1, 51.8, 1713.1, 801.6, 1735.8, 849.6], new [-0.90401, -0.42752, -1.00000, 0.00000, -0.90401, 0.42752, 1.00000, 0.00000] ), // Bottom right new Cushion( new [1709.3, 876.1, 1661.3, 853.4, 913.7, 853.4, 875.5, 876.1], new [0.42752, -0.90401, 0.00000, -1.00000, -0.51085, -0.85967, 0.00000, 1.00000] ), // Bottom left new Cushion( new [837.6, 876.1, 799.4, 853.4, 51.8, 853.4, 3.8, 876.1], new [0.51085, -0.85967, 0.00000, -1.00000, -0.42752, -0.90401, 0.00000, 1.00000] ), ]; /** * The positions of the pocket centres on the table. */ internal static var pocketCentres: Vector. = new [ // Top left Top centre Top right Bottom right Bottom centre Bottom left -5.8, -5.8, 856.6, -5.8, 1718.9, -5.8, 1718.9, 859.2, 856.6, 859.2, -5.8, 859.2, ]; private var m_gameState: int = GameState.CUEBALL_IN_HAND; /** * The state of the game. Refer the the GameState class for possible values. */ public function get gameState(): int { return m_gameState; } internal function setGameState(state: int): void { m_gameState = state; } private var m_scorePlayer1: int = 0; private var m_scorePlayer2: int = 0; /** * The score of the first player. */ public function get scorePlayer1(): int { return m_scorePlayer1; } /** * The score of the second player. */ public function get scorePlayer2(): int { return m_scorePlayer2; } private var m_framesWonPlayer1: int = 0; private var m_framesWonPlayer2: int = 0; /** * The number of frames won by the first player. */ public function get framesWonPlayer1(): int { return m_framesWonPlayer1; } /** * The number of frames won by the first player. */ public function get framesWonPlayer2(): int { return m_framesWonPlayer2; } private var m_targetFrames: int = 1; /** * The number of frames required to win the match. */ public function get targetFrames(): int { return m_targetFrames; } internal function setTargetFrames(value: int): void { m_targetFrames = (value === 0) ? 1 : value; } private var m_currentBreak: int = 0; /** * The points scored in the current break. */ public function get currentBreak(): int { return m_currentBreak; } private var m_bestBreak: int = 0; /** * The points scored in the best break in the game. */ public function get bestBreak(): int { return m_bestBreak; } private var m_currentPlayer: int = 0; /** * The current player (0=player1, 1=player2) */ public function get currentPlayer(): int { return m_currentPlayer; } internal function setCurrentPlayer(value: int): void { m_currentPlayer = value; } private var m_firstFrameOpenPlayer: int = 0; /** * The player opening the first frame (0=player1, 1=player2) */ public function get firstFrameOpenPlayer(): int { return m_firstFrameOpenPlayer; } internal function setFirstFrameOpenPlayer(player: int): void { m_firstFrameOpenPlayer = player; } private var m_currentColour: int = 1; /** * The colour of the target ball that must be hit by the cue ball in the current shot. */ public function get currentColour(): int { return m_currentColour; } internal function setCurrentColour(colour: int): void { m_currentColour = colour; } /** * An array containing the Ball objects representing the balls in the game (both those on the table * as well as potted). Balls on the table are always positioned before potted balls. * The cue ball is always the first element (index 0) in this array, except possibly when a shot * is in progress. */ public const balls: Vector. = new Vector.(22, true); private var m_ballsOnTableCount: int; /** * The number of balls currently on the table. */ public function get ballsOnTableCount(): int { return m_ballsOnTableCount; } /** * A set of bit flags indicating the state of the arrow keys (bit is set to 1 if the key is down, * 0 if it is up) * 1: Left arrow * 2: Up arrow * 4: Right arrow * 8: Down arrow */ private var m_arrowKeyState: int = 0; /** * A set of bit flags indicating whether the following keys have been pressed in the current frame: * (Bit is set to 1 is the key is pressed, cleared at the end of the frame) * 1: Left arrow * 2: Right arrow * 4: Enter key * 8: Backspace key */ private var m_keyFlags: int = 0; /** * A value representing the current time, relative to some reference value, in milliseconds. */ private var m_timeStamp: Number; /** * A value representing the time at which an arrow key was last pressed or released, in millizeconds, * relative to the same reference value used for _timeStamp. */ private var m_lastArrowKeyTimeStamp: Number; /** * A value representing the time at which the current shot ended with all balls stopped, in millizeconds, * relative to the same reference value used for m_timeStamp. * Applicable in states: SHOT_IN_PROGRESS(5), AFTER_SHOT_DELAY(10) */ private var m_shotEndTimeStamp: Number; /** * A value representing the time between the previous frame and the current frame, in millizeconds. */ private var m_elapsedTime: Number; /** * The point value of the colour of the ball last hit by the cue ball, or -1 is no ball is hit. * Applicable in states: SHOT_IN_PROGRESS(5) */ private var m_lastHitBallColour: int; /** * The number of balls of the current colour which have been potted in the current shot. * Applicable in states: SHOT_IN_PROGRESS(5) */ private var m_currentColourBallsPotted: int; /** * The total number of red balls which have been potted. */ private var m_totalRedsPotted: int; /** * The number of foul points (which are to be given to the opponent) which have been scored so far * in the current shot. * Applicable in states: SHOT_IN_PROGRESS(5) */ private var m_foulPointsScored: int; private var m_mouseX: Number = 0; private var m_mouseY: Number = 0; /** * The x coordinate of the mouse pointer's position in the current frame. */ public function get mouseX(): Number { return m_mouseX; } /** * The y coordinate of the mouse pointer's position in the current frame. */ public function get mouseY(): Number { return m_mouseY; } internal function setMousePosition(x: Number, y: Number): void { m_mouseX = x; m_mouseY = y; } /** * The x coordinate of the mouse pointer's position in the previous frame. */ private var m_lastMouseX: Number = 0; /** * The y coordinate of the mouse pointer's position in the previous frame. */ private var m_lastMouseY: Number = 0; /** * This is set to true if the current shot is for a colour ball after succesfully potting a red ball. */ private var m_shootingColourAfterRed: Boolean; private var m_ballInHandAfterFoul: Boolean; /** * This is set to true if the cue ball was potted in a foul, which would result in a ball-in-hand * in the next shot. * Applicable in states: CHOOSE_FOUL_PLAYER(6) */ public function get ballInHandAfterFoul(): Boolean { return m_ballInHandAfterFoul; } internal function setBallInHandAfterFoul(value: Boolean): void { m_ballInHandAfterFoul = value; } private var m_replayAfterFoul: Boolean; /** * This is set to true if a player committed a foul and the opponent requests the fouling player to * replay. * Applicable in states: CHOOSE_FOUL_PLAYER(6) */ public function get replayAfterFoul(): Boolean { return m_replayAfterFoul; } /** * The computed relative collision time (RCT) of the first collision in the frame or subframe. * RCT is a value between 0 and 1 indicating the time at which impact is predicted to occur * as a fraction of the remaining frame/subframe time. * Applicable in states: SHOT_IN_PROGRESS(5) */ private var m_minRCT: Number; private var m_cueTipDistance: Number = 0; private var m_cueDirX: Number; private var m_cueDirY: Number; /** * The distance of the cue tip from the centre of the cue ball. * Applicable in states: CUE_SHOT_POWER(3) */ public function get cueTipDistance(): Number { return m_cueTipDistance; } /** * The x component of the unit vector of the direction in which the cue ball will be hit. * Applicable in states: CUE_AIM(2), CUE_SHOT_POWER(3), CUE_SHOOT(4) */ public function get cueDirX(): Number { return m_cueDirX; } /** * The y component of the unit vector of the direction in which the cue ball will be hit. * Applicable in states: CUE_AIM(2), CUE_SHOT_POWER(3), CUE_SHOOT(4) */ public function get cueDirY(): Number { return m_cueDirY; } internal function setCueDir(x: Number, y: Number): void { m_cueDirX = x; m_cueDirY = y; } private var m_predictedTargetBall: Ball; private var m_predictedTargetDirX: Number; private var m_predictedTargetDirY: Number; private var m_predictedTargetImpactX: Number; private var m_predictedTargetImpactY: Number; /** * The target ball that is predicted to be hit by the cue ball first, given the direction * in which the cue ball is hit. Null if no ball is predicted to be hit. * Applicable in states: CUE_AIM(2), CUE_SHOT_POWER(3) */ public function get predictedTargetBall(): Ball { return m_predictedTargetBall; } /** * The x component of the unit vector of the predicted direction of the target ball after being * hit by the cue ball. Only applicable is predictedTargetBall is not null. * Applicable in states: CUE_AIM(2), CUE_SHOT_POWER(3) */ public function get predictedTargetDirX(): Number { return m_predictedTargetDirX; } /** * The x component of the unit vector of the predicted direction of the target ball after being * hit by the cue ball. Only applicable is predictedTargetBall is not null. * Applicable in states: CUE_AIM(2), CUE_SHOT_POWER(3) */ public function get predictedTargetDirY(): Number { return m_predictedTargetDirY; } /** * The x coordinate of the centre of the cue ball at the point of impact with the predicted target * ball. Only applicable is predictedTargetBall is not null. * Applicable in states: CUE_AIM(2), CUE_SHOT_POWER(3) */ public function get predictedTargetImpactX(): Number { return m_predictedTargetImpactX; } /** * The y coordinate of the centre of the cue ball at the point of impact with the predicted target * ball. Only applicable is predictedTargetBall is not null. * Applicable in states: CUE_AIM(2), CUE_SHOT_POWER(3) */ public function get predictedTargetImpactY(): Number { return m_predictedTargetImpactY; } /** * The speed of the cue tip. * Applicable in states: CUE_SHOT_POWER(3), CUE_SHOOT(4) */ private var m_cueTipSpeed: Number; public function GameEngine() { _initBalls(); m_timeStamp = getTimer(); } /** * Sets all the balls to their initial positions on the table. */ private function _initBalls(): void { var i: int; var initPositions: Vector. = initialBallPositions; for (i = 0; i < 22; i++) { var ball: Ball = balls[i]; if (ball === null) { ball = new Ball(); balls[i] = ball; } ball.potStatus = 0; if (i === 0) ball.colour = 0; else if (i <= 6) ball.colour = i + 1; else ball.colour = 1; ball.x = initPositions[int(i << 1)]; ball.y = initPositions[int((i << 1) + 1)]; ball.vx = 0; ball.vy = 0; } m_ballsOnTableCount = 22; m_totalRedsPotted = 0; spotCueBallInD(); } /** * Handles keyboard input. * * @param keyCode The keycode of the key pressed * @param keyState The state of the pressed key (1 for down, 0 for up) */ public function keyPress(keyCode: int, keyState: int): void { if (keyCode >= 37 && keyCode <= 40) { // Handle arrow keys var oldArrowKeyState: int = m_arrowKeyState; m_arrowKeyState = (m_arrowKeyState & ~(1 << (keyCode - 37))) | (keyState << (keyCode - 37)); if (m_arrowKeyState !== oldArrowKeyState) m_lastArrowKeyTimeStamp = getTimer() } if (keyState) { if (keyCode === 37) // Left arrow m_keyFlags |= 1; else if (keyCode === 39) // Right arrow m_keyFlags |= 2; else if (keyCode === 13 || keyCode === 108) // Enter m_keyFlags |= 4; else if (keyCode === 8) // Backspace m_keyFlags |= 8; } } /** * Sets the cue tip position for the required shot speed. * * @param speed The speed of the cue ball when struck. * NOTE: This is the strike speed of the cue ball, which may not be the same as that of the cue tip. */ internal function setCueBallSpeed(speed: Number): void { m_cueTipDistance = Math.sqrt(speed * 1.05263157894737 - 0.242) * 92.4500327042049 + 6.5; } /** * Update function called on every frame. This calls a state-specific update function. */ public function update(): void { m_elapsedTime = getTimer() - m_timeStamp; m_timeStamp += m_elapsedTime; // Call the state-specific update function switch (m_gameState) { case GameState.CUEBALL_IN_HAND: _updateState_cueballInHand(); break; case GameState.CUE_AIM: _updateState_cueAim(); break; case GameState.CUE_SHOT_POWER: _updateState_cueShotPower(); break; case GameState.CUE_SHOOT: _updateState_cueShoot(); break; case GameState.SHOT_IN_PROGRESS: _updateState_shotInProgress(); break; case GameState.CHOOSE_FOUL_PLAYER: _updateState_chooseFoulPlayer(); break; case GameState.CHOOSE_COLOUR: _updateState_chooseColour(); break; case GameState.CHOOSE_TIE_PLAYER: _updateState_chooseTiePlayer(); break; case GameState.GAME_OVER: _updateState_gameOver(); break; case GameState.AFTER_SHOT_DELAY: _updateState_afterShotDelay(); break; } m_lastMouseX = m_mouseX; m_lastMouseY = m_mouseY; m_keyFlags = 0; } private function _updateState_cueballInHand(): void { if (m_keyFlags & 4) { // Switch to next state if Enter key is pressed. _setDefaultCuePosition(); m_gameState = GameState.CUE_AIM; return; } var arrowKeys: int = m_arrowKeyState; if (!arrowKeys) return; var cueBall: Ball = balls[0]; // Calculate the new position of the cue ball based on the keyboard input. var ballSpeed: Number = 0.02 + 0.0003 * (m_timeStamp - m_lastArrowKeyTimeStamp); if (ballSpeed > 0.2) ballSpeed = 0.2; var newX: Number = cueBall.x + ballSpeed * m_elapsedTime * (((arrowKeys & 4) >> 2) - (arrowKeys & 1)); var newY: Number = cueBall.y + ballSpeed * m_elapsedTime * (((arrowKeys & 8) >> 3) - ((arrowKeys & 2) >> 1)); // If the ball is going outside the baulk line, position it on the line. if (newX > 353.8) newX = 353.8; // Check if the ball is going outside the 'D' var dd: Number = (newX - 353.8) * (newX - 353.8) + (newY - 426.7) * (newY - 426.7); var ratio: Number; if (dd > 19656.04) { // Position the ball on the 'D', at the intersection point of the line joining the // centre of the D with the new ball's position with the D itself. ratio = Math.sqrt(19656.04 / dd); newX = 353.8 + (newX - 353.8) * ratio; newY = 426.7 + (newY - 426.7) * ratio; } // Finally, check for collisions with other balls. If there is contact with any ball, don't move the // cue ball at all. However, a key press is mimicked (by setting the _lastArrowKeyTimeStamp // property) so that the ball's speed resets to the minimum and it gets as close as possible // to the colliding ball. if (_checkCollisionForSpotting(cueBall, newX, newY, true)) { m_lastArrowKeyTimeStamp = m_timeStamp; return; } cueBall.x = newX; cueBall.y = newY; } private function _updateState_cueAim(): void { if (m_keyFlags & 4) { // Switch to next state if Enter key is pressed m_gameState = GameState.CUE_SHOT_POWER; return; } var cueDirChanged: Boolean = false; if (m_arrowKeyState) { // Use left and right arrow keys to control cue angle. var cueAngleSpeed: Number = 0.00001 + 0.0000004 * (m_timeStamp - m_lastArrowKeyTimeStamp); if (cueAngleSpeed > 0.002) cueAngleSpeed = 0.002; var rotateAngle: Number = cueAngleSpeed * m_elapsedTime * (((m_arrowKeyState & 4) >> 2) - (m_arrowKeyState & 1)); var rotateCos: Number = Math.cos(rotateAngle); var rotateSin: Number = Math.sin(rotateAngle); var oldX: Number = m_cueDirX; m_cueDirX = oldX * rotateCos - m_cueDirY * rotateSin; m_cueDirY = oldX * rotateSin + m_cueDirY * rotateCos; cueDirChanged = true; } if (m_mouseX !== m_lastMouseX || m_mouseY !== m_lastMouseY) { // Aim the cue at where the mouse is pointing. var newDirX: Number = m_mouseX - balls[0].x; var newDirY: Number = m_mouseY - balls[0].y; var norm: Number = 1 / Math.sqrt(newDirX * newDirX + newDirY * newDirY); m_cueDirX = newDirX * norm; m_cueDirY = newDirY * norm; cueDirChanged = true; } if (cueDirChanged) _predictTargetBall(); } private function _updateState_cueShotPower(): void { if (m_keyFlags & 4) { // Enter key m_cueTipSpeed = (m_cueTipDistance - 6.5) * (m_cueTipDistance - 6.5) * 0.000117 + 0.242; m_gameState = GameState.CUE_SHOOT; return; } if (m_keyFlags & 8) { // Backspace key m_gameState = 2; return; } if (m_arrowKeyState) { // Use up and down arrow keys to control shot power. var speed: Number = 0.006 + 0.0003 * (m_timeStamp - m_lastArrowKeyTimeStamp); if (speed > 0.2) speed = 0.2; m_cueTipDistance += speed * m_elapsedTime * (((m_arrowKeyState & 8) >> 3) - ((m_arrowKeyState & 2) >> 1)); } if (m_mouseY !== m_lastMouseY) m_cueTipDistance += (m_mouseY - m_lastMouseY) * 0.25; if (m_cueTipDistance > 120) m_cueTipDistance = 120; else if (m_cueTipDistance < 20) m_cueTipDistance = 20; } private function _updateState_cueShoot(): void { m_cueTipDistance -= m_cueTipSpeed * m_elapsedTime; if (m_cueTipDistance < 12.6) { // Shoot the cue ball! var cueBall: Ball = balls[0]; cueBall.vx = m_cueTipSpeed * 0.95 * m_cueDirX; cueBall.vy = m_cueTipSpeed * 0.95 * m_cueDirY; if (enableShotDebugTracing) _logTableState(); m_lastHitBallColour = -1; m_currentColourBallsPotted = 0; m_foulPointsScored = 0; m_gameState = GameState.SHOT_IN_PROGRESS; } } private function _updateState_shotInProgress(): void { var vMaxSquared: Number = 0; var balls: Vector. = this.balls; var ball: Ball; var ballCount: int = m_ballsOnTableCount; var i: int, j: int; // To minimize the effects of linear interpolation approximation during collisions, the // frame is divided into multiple 'subframes', with each subframe being processed in order // (but only the last one rendered). The number of subframes required depends on the speed of // the fastest ball, as linear interpolation errors become more significant at higher speeds // for the same frame rate. for (i = 0; i < ballCount; i++) { ball = balls[i]; var vb: Number = ball.vx * ball.vx + ball.vy * ball.vy; if (vMaxSquared < vb) vMaxSquared = vb; } if (vMaxSquared === 0) { // All balls are at rest, so end the shot. // (The engine automatically sets balls' velocities to zero when they are very small, // so vmax can be compared directly with zero without using an epsilon) m_shotEndTimeStamp = m_timeStamp; m_gameState = GameState.AFTER_SHOT_DELAY; return; } var subFrames: int = int(Math.sqrt(vMaxSquared) * 2) + 1; var subFrameTime: Number = 0; m_timeStamp -= m_elapsedTime; var subFrameDuration: Number = m_elapsedTime / subFrames; while (subFrames) { m_timeStamp += subFrameDuration; subFrameTime = 0; // Begin sub frame while (true) { // Calculate the expected new state of each ball (assuming no collisions) // This expected state is stored in the x2, y2, vx2, vy2 fields of the Ball object. for (i = 0; i < ballCount; i++) { ball = balls[i]; if (ball.vx !== 0 || ball.vy !== 0) { _calculateExpectedBallState(ball, subFrameDuration * (1 - subFrameTime)); } else { ball.x2 = ball.x; ball.y2 = ball.y; ball.vx2 = ball.vy2 = 0; } } var collideBall1: Ball = null; var collideBall2: Ball = null; m_minRCT = 1; // First check for 'collisions' with the pockets (i.e. if balls have been potted) for (i = 0; i < ballCount; i++) { if (_checkBallPocketEntry(balls[i])) collideBall1 = balls[i]; } // Then check for collisions with the cushions. for (i = 0; i < ballCount; i++) { if (_checkBallCushionCollisions(balls[i])) collideBall1 = balls[i]; } // Finally, check for collisions between balls. for (i = 1; i < ballCount; i++) { for (j = 0; j < i; j++) { if (_checkTwoBallCollision(balls[i], balls[j])) { collideBall1 = balls[i]; collideBall2 = balls[j]; } } } if (!collideBall1 && !collideBall2) { // No collision, set the new ball states and end the sub frame. for (i = 0; i < ballCount; i++) { ball = balls[i]; ball.x = ball.x2; ball.y = ball.y2; ball.vx = ball.vx2; ball.vy = ball.vy2; } break; } // It is now known which collision has happened first. The _minRCT field has the relative // collision time for the first collision while collideBall1 and collideBall2 are the // ball(s) involved. var minRCT: Number = m_minRCT; for (i = 0; i < ballCount; i++) { ball = balls[i]; if (ball === collideBall1 && ball.potStatus !== 0) { // Ball has been potted, move it to the end of the balls array. ball.potStatus = 2; ballCount--; m_ballsOnTableCount = ballCount; balls[i] = balls[ballCount]; balls[ballCount] = ball; i--; if (ball.colour === m_currentColour) { m_currentColourBallsPotted++; } else { // If the ball potted is not of the active colour (or is the cue ball), // it is a foul. var foulValue: int = ball.colour ? ball.colour : 4; if (m_foulPointsScored < foulValue) m_foulPointsScored = foulValue; } if (ball.colour === 1) m_totalRedsPotted++; ball.vx = ball.vy = 0; // Set velocity of potted ball to zero } else { // Calculate the intermediate state of the ball. The position is found by // linear interpolation. If the ball is involved in the collision, its velocity // is set to the computed post-collision value, otherwise it is linearly interpolated. ball.potStatus = 0; ball.x += minRCT * (ball.x2 - ball.x); ball.y += minRCT * (ball.y2 - ball.y); if (ball === collideBall1 || ball === collideBall2) { ball.vx = ball.vxc; ball.vy = ball.vyc; if ((collideBall1.colour === 0 || (collideBall2 !== null && collideBall2.colour === 0)) && ball.colour !== 0) { // If the ball is an object ball which collided with the cue ball, check for fouls // (in particular, a ball not of the active colour being hit first) if (m_lastHitBallColour === -1 && ball.colour !== m_currentColour && m_foulPointsScored < ball.colour) m_foulPointsScored = ball.colour; m_lastHitBallColour = ball.colour; } } else { ball.vx += minRCT * (ball.vx2 - ball.vx); ball.vy += minRCT * (ball.vy2 - ball.vy); } } } // Advance the subframe time and check for further collisions. subFrameTime += minRCT * (1 - subFrameTime); } // End sub frame subFrames--; } } private function _updateState_chooseFoulPlayer(): void { if (m_keyFlags & 3) { // Left/right arrow m_replayAfterFoul = !m_replayAfterFoul; m_currentPlayer = 1 - m_currentPlayer; } else if (m_keyFlags & 4) { // Enter if (m_ballInHandAfterFoul) { m_ballInHandAfterFoul = false; m_gameState = GameState.CUEBALL_IN_HAND; } else { _setDefaultCuePosition(); m_gameState = GameState.CUE_AIM; } } } private function _updateState_chooseColour(): void { if (m_keyFlags & 4) { // Enter _setDefaultCuePosition(); m_gameState = GameState.CUE_AIM; } else { m_currentColour += ((m_keyFlags & 2) >> 1) - (m_keyFlags & 1); if (m_currentColour === 8) m_currentColour = 2; else if (m_currentColour === 1) m_currentColour = 7; } } private function _updateState_chooseTiePlayer(): void { if (m_keyFlags & 4) { // Enter m_ballInHandAfterFoul = false; m_gameState = 1; } else if (m_keyFlags & 3) { // Left/right arrow m_currentPlayer = 1 - m_currentPlayer; } } private function _updateState_gameOver(): void { if (m_keyFlags & 4) { // Enter - start new game m_scorePlayer1 = 0; m_scorePlayer2 = 0; if (m_framesWonPlayer1 === m_targetFrames || m_framesWonPlayer2 === m_targetFrames) { m_framesWonPlayer1 = 0; m_framesWonPlayer2 = 0; m_bestBreak = 0; m_currentPlayer = m_firstFrameOpenPlayer; } else { m_currentPlayer = (((m_framesWonPlayer1 + m_framesWonPlayer2) & 1) !== 0) ? 1 - m_firstFrameOpenPlayer : m_firstFrameOpenPlayer; } m_currentBreak = 0; m_currentColour = 1; m_ballInHandAfterFoul = false; _initBalls(); m_gameState = GameState.CUEBALL_IN_HAND; } } private function _updateState_afterShotDelay(): void { if (m_timeStamp - m_shotEndTimeStamp >= 2000) // 2 sec delay after shot _endShot(); } /** * This function is called at the end of a shot, when all balls have stopped. It determines * the next state of the game. */ private function _endShot(): void { // Calculate the players' scores after the shot. var pointsAwarded: int; var foulPointsScored: int = this.m_foulPointsScored; var currentColourPottedCount: int = this.m_currentColourBallsPotted; if (m_lastHitBallColour === -1) foulPointsScored = 4; // If no ball is hit, a 4-point foul is awarded. if (foulPointsScored !== 0) { // Minimum number of points that must be awarded to the opponent in case of // a foul is 4 points or the value of the current colour, whichever is higher. pointsAwarded = foulPointsScored; if (pointsAwarded < m_currentColour) pointsAwarded = m_currentColour; if (pointsAwarded < 4) pointsAwarded = 4; } else { pointsAwarded = m_currentColour * currentColourPottedCount; } if (m_currentPlayer === ((foulPointsScored !== 0) ? 1 : 0)) m_scorePlayer1 += pointsAwarded; else m_scorePlayer2 += pointsAwarded; // Keep track of the current break if (foulPointsScored === 0 && currentColourPottedCount !== 0) { m_currentBreak += pointsAwarded; if (m_bestBreak < m_currentBreak) m_bestBreak = m_currentBreak; } else { m_currentBreak = 0; } var balls: Vector. = this.balls; var ballsOnTableCount: Number = ballsOnTableCount; var i: int, j: int; var tempBall: Ball; if (m_currentColour === 7 && m_totalRedsPotted === 15 && !m_shootingColourAfterRed && (currentColourPottedCount !== 0 || foulPointsScored !== 0)) { // If black is the only ball remaining and it is potted (or a foul committed)... if (m_scorePlayer1 !== m_scorePlayer2) { // End of game m_gameState = GameState.GAME_OVER; if (m_scorePlayer1 > m_scorePlayer2) m_framesWonPlayer1++; else m_framesWonPlayer2++; } else { // Respot the cue ball and the black and enter a tiebreaker. if (balls[0].colour) { tempBall = balls[0]; balls[0] = balls[1]; balls[1] = tempBall; } spotCueBallInD(); _spotColourBall(balls[1]); ballsOnTableCount = 2; m_gameState = GameState.CHOOSE_TIE_PLAYER; } return; } // Determine the number of balls which are either on the table or have been // potted in the current shot. var ballsOnTableAndPottedCount: Number = ballsOnTableCount; for (i = ballsOnTableCount; i < 22; i++) ballsOnTableAndPottedCount += int(balls[i].potStatus === 2); if (ballsOnTableCount < ballsOnTableAndPottedCount && (foulPointsScored !== 0 || m_shootingColourAfterRed)) { // Respot balls if needed. // For respotting, sort the balls which have been potted in the current shot, // in descending order of point value with the cue ball having the highest value. for (i = ballsOnTableAndPottedCount - 1; i > ballsOnTableCount; i--) { var swapped: Boolean = false; for (j = ballsOnTableCount; j < i; j++) { var ballValue1: int = balls[j].colour; var ballValue2: int = balls[int(j + 1)].colour; if (ballValue1 && (!ballValue2 || ballValue1 < ballValue2)) { tempBall = balls[int(j + 1)]; balls[int(j + 1)] = balls[j]; balls[j] = tempBall; swapped = true; } } if (!swapped) break; } // If the cue ball has been potted, ensure that it is the first element in the balls // array and then respot it. if (!balls[ballsOnTableCount].colour) { tempBall = balls[0]; balls[0] = balls[ballsOnTableCount]; balls[ballsOnTableCount] = tempBall; ballsOnTableCount++; spotCueBallInD(); m_ballInHandAfterFoul = true; } // Now respot the colours in descending order of points. // Stop when a red ball is found. for (i = ballsOnTableCount; i < ballsOnTableAndPottedCount; i++) { if (balls[i].colour === 1) break; _spotColourBall(balls[i]); } ballsOnTableCount = i; this.m_ballsOnTableCount = ballsOnTableCount; } // After respotting, set the potStatus of all potted balls to 3 to indicate that // they have been potted permanently. for (i = ballsOnTableCount; i < ballsOnTableAndPottedCount; i++) balls[i].potStatus = 3; // Now determine the next state of the game. if (m_currentColour === 1) { // If red is the current colour... if (currentColourPottedCount === 0 || foulPointsScored !== 0) { // If a foul was committed or no balls were potted, the colour for the next shot is // red if there are reds remaining on the table, otherwise it is yellow. if (m_totalRedsPotted === 15) m_currentColour = 2; if (foulPointsScored !== 0) { m_replayAfterFoul = false; m_gameState = GameState.CHOOSE_FOUL_PLAYER; } else { _setDefaultCuePosition(); m_gameState = GameState.CUE_AIM; } } else { // Otherwise, allow the player to choose the colour (other than red) for the next shot. m_shootingColourAfterRed = true; m_currentColour = 2; m_gameState = GameState.CHOOSE_COLOUR; } } else { // If the current colour is not red... if (m_shootingColourAfterRed) { // If the player has attempted a shot at a colour ball after a red, the colour // for the next shot is red if there are reds on the table, otherwise it is yellow. m_shootingColourAfterRed = false; m_currentColour = (m_totalRedsPotted === 15) ? 2 : 1; } else { // If the shot at the colour ball is after all reds have been potted, the colour // for the next shot is the one of the next highest value if the colour is legally potted. // Otherwise the colour for the next shot is unchanged. m_currentColour += int(currentColourPottedCount !== 0 && foulPointsScored === 0); } if (foulPointsScored !== 0) { m_replayAfterFoul = false; m_gameState = GameState.CHOOSE_FOUL_PLAYER; } else { _setDefaultCuePosition(); m_gameState = GameState.CUE_AIM; } } if (foulPointsScored !== 0 || currentColourPottedCount === 0) { // Switch to the other player if a foul was committed or no balls of the active // colour potted. m_currentPlayer = 1 - m_currentPlayer; } } /** * Sets the cue tip position and angle to their default values. */ private function _setDefaultCuePosition(): void { m_cueTipDistance = 20; m_cueDirX = 1; m_cueDirY = 0; _predictTargetBall(); } /** * Determines which ball would be hit by the cue ball first, given the direction of * the shot. Also computes the predicted point of impact and direction of the target ball * when it is hit. */ private function _predictTargetBall(): void { var ball: Ball; var cueBall: Ball = balls[0]; var targetTDist: Number, targetNDist: Number; var rx: Number, ry: Number; m_predictedTargetBall = null; for (var i: int = 1; i < m_ballsOnTableCount; i++) { ball = balls[i]; rx = ball.x - cueBall.x; ry = ball.y - cueBall.y; var tDist: Number = rx * m_cueDirX + ry * m_cueDirY; var nDist: Number = Math.abs(rx * m_cueDirY - ry * m_cueDirX); if (tDist < 0 || nDist >= 25.2) continue; if (m_predictedTargetBall === null || targetTDist > tDist) { targetTDist = tDist; targetNDist = nDist; m_predictedTargetBall = ball; } } if (m_predictedTargetBall === null) return; var impactDist: Number = targetTDist - Math.sqrt(635.04 - targetNDist * targetNDist); m_predictedTargetImpactX = cueBall.x + m_cueDirX * impactDist; m_predictedTargetImpactY = cueBall.y + m_cueDirY * impactDist; m_predictedTargetDirX = (m_predictedTargetBall.x - m_predictedTargetImpactX) * 0.03968253968253967; m_predictedTargetDirY = (m_predictedTargetBall.y - m_predictedTargetImpactY) * 0.03968253968253967; } /** * Checks if the given ball can be placed at a particular spot on the table without colliding * with another ball. * * @param ball The ball which is to be placed on the new spot. * @param spotX The x coordinate of the spot to be checked. * @param newY The y coordinate of the spot to be checked. * @param baulkOnly Set to true to check only the balls in the baulk. * @return The ball with which the target ball may collide when placed on the spot, or null if * the spot is not occupied. */ private function _checkCollisionForSpotting(ball: Ball, spotX: Number, spotY: Number, baulkOnly: Boolean): Ball { var count: int = m_ballsOnTableCount; for (var i: int = 0; i < count; i++) { var targetBall: Ball = balls[i]; if (targetBall === ball || targetBall.potStatus !== 0 || (baulkOnly && targetBall.x > 366.4)) continue; var targetDistX: Number = targetBall.x - spotX; var targetDistY: Number = targetBall.y - spotY; if (targetDistX * targetDistX + targetDistY * targetDistY < 635.04) return targetBall; } return null; } /** * Spots the cue ball at a random unoccupied spot in the 'D'. (for example, after the * cue ball is potted in a foul, or at the start of a frame) */ public function spotCueBallInD(): void { var cueBall: Ball = balls[0]; while (true) { // This algorithm generates uniformly distributed random points in the semicircle and // checks if they are occupied, until it finds an unoccupied point. (The radius is actually // 140.2, but an allowance of .01 is kept here) var rad: Number = Math.sqrt(Math.random()) * 140.19; var sinTheta: Number = Math.sin((Math.random() * 2 - 1) * 1.570796326794897); var newX: Number = 353.8 - rad * Math.sqrt(1 - sinTheta * sinTheta); var newY: Number = 426.7 + rad * sinTheta; if (!_checkCollisionForSpotting(cueBall, newX, newY, true)) { cueBall.x = newX; cueBall.y = newY; cueBall.potStatus = 0; return; } } } /** * Spots a colour ball. * * @param ball The colour ball to be spotted. */ private function _spotColourBall(colourBall: Ball): void { var occupiedBall: Ball = null; var colour: int = colourBall.colour; var spotX: Number, spotY: Number; var i: int, j: int; // First check if the ball's original spot is occupied. spotX = initialBallPositions[int((colour - 1) << 1)]; spotY = initialBallPositions[int(((colour - 1) << 1) + 1)]; occupiedBall = _checkCollisionForSpotting(colourBall, spotX, spotY, false); if (occupiedBall) { // Ball's original spot is occupied. Check all other colour spots in descending order. for (j = 7; j >= 2; j--) { if (j === colour) continue; spotX = initialBallPositions[int((j - 1) << 1)]; spotY = initialBallPositions[int(((j - 1) << 1) + 1)]; if (!_checkCollisionForSpotting(colourBall, spotX, spotY, false)) break; } if (j === 1) { // None of the colour spots are available. // According to the rules, the ball now has to be spotted on the horizontal line // from the ball's original spot to the right end of the table, as close as // possible to the original spot. spotY = initialBallPositions[int(((colour - 1) << 1) + 1)]; var dy: Number; while (occupiedBall !== null) { dy = spotY - occupiedBall.y; // An allowance of 0.01 is kept here to ensure that no collision is detected with // the same ball (due to floating point error) that would result in an infinite loop. spotX = occupiedBall.x + Math.sqrt(635.04 - dy * dy) + 0.01; if (spotX > 1700.5) // Reached the edge of the table! break; occupiedBall = _checkCollisionForSpotting(colourBall, spotX, spotY, false); } if (occupiedBall !== null) { // If the ball is still unable to be spotted (this can happen only for pink // and black balls), it must as a last resort be spotted on the centre line, // to the left of the original spot and as close to it as possible. spotY = 426.7; spotX = initialBallPositions[int((colour - 1) << 1)]; occupiedBall = _checkCollisionForSpotting(colourBall, spotX, spotY, false); while (occupiedBall) { dy = spotY - occupiedBall.y; spotX = occupiedBall.x - Math.sqrt(635.04 - dy * dy) - 0.01; occupiedBall = _checkCollisionForSpotting(colourBall, spotX, spotY, false); } } } } colourBall.x = spotX; colourBall.y = spotY; colourBall.potStatus = 0; } /** * Calculates the future state of the ball after a time interval, taking into account friction * with the table. The state after the time interval is stored in the ball's x2, y2, vx2 and vy2 * fields. * * @param ball The Ball object. * @param dt The time interval. */ private function _calculateExpectedBallState(ball: Ball, dt: Number): void { // The friction model used by this function: // dv/dt = -(a0*vt + a1*(v-vt)) [v > vt] // dv/dt = -a0*v [v < vt] // The parameter values used are: // a0 = 0.048, a1 = 0.000045, vt = 0.006 // Derived values: // (a0-a1)*vt = 0.00028773 var speed: Number = Math.sqrt(ball.vx * ball.vx + ball.vy * ball.vy); var accX: Number, accY: Number, temp: Number; if (speed < 0.006) { accX = -0.048 * ball.vx; accY = -0.048 * ball.vy; } else { temp = -0.00028773 / speed - 0.000045; accX = temp * ball.vx; accY = temp * ball.vy; } temp = 0.5 * dt * dt; ball.x2 = ball.x + ball.vx * dt + accX * temp; ball.y2 = ball.y + ball.vy * dt + accY * temp; ball.vx2 = ball.vx + accX * dt; ball.vy2 = ball.vy + accY * dt; // Truncate very small velocities to zero. if (Math.abs(ball.vx2) < 1E-6) ball.vx2 = 0; if (Math.abs(ball.vy2) < 1E-6) ball.vy2 = 0; } /** * A function used for solving quadratic equations to compute collision RCTs. * This checks for a root of the quadratic equation ax^2+bx+c such that 0<=x<=1. If both * roots are in this range, the lesser value is returned. * * @return The root of the quadratic equation ax^2+bx+c such that 0<=x<=1. If no root in this range * can be found, -1 is returned. */ private static function _quadSolve(a: Number, b: Number, c: Number): Number { var root: Number; if (Math.abs(a) < 1E-12) { if (Math.abs(b) < 1E-12) return -1; if (b < 0) { b = -b; c = -c; } if (c > 0 || -c > b) return -1; root = -c / b; } else { if ((c > 0 && b > 0) || (b < -2 * a && a + b + c > 0)) return -1; var d: Number = b * b - 4 * a * c; if (d < 0) return -1; d = Math.sqrt(d); root = -(b + d) if (root < -1E-8) root = d - b; if (root > 2 * a) return -1; root /= 2 * a; } if (root < 0 && root >= -1E-8) root = 0; return root; } /** * Check for collisions between a ball and a cushion. * If a collision was detected, the ball's vxc and vyc fields and the _minRCT field are set to * the appropriate values. * * @param ball The ball to check. * * @return True if a collision was detected, false otherwise. */ private function _checkBallCushionCollisions(ball: Ball): Boolean { // Determine which cushion the ball can possibly collide with. var cushionIndex: int = -1; if (ball.x2 <= 12.6) cushionIndex = 0; // Left cushion else if (ball.x2 >= 1700.5) cushionIndex = 3; // Right cushion else if (ball.y2 <= 12.6) cushionIndex = 2 - int(ball.x2 < 856.55) // Top-left or top-right, depending on table half else if (ball.y2 >= 840.8) cushionIndex = 4 + int(ball.x2 < 856.55) // Bottom-left or bottom-right, depending on table half if (cushionIndex === -1) // Ball cannot possibly collide with any cushion return false; var cushion: Cushion = cushions[cushionIndex]; var i: int; var startX: Number, startY: Number, endRX: Number, endRY: Number, normalX: Number, normalY: Number; var impactX: Number, impactY: Number; // COR for ball-cushion collisions is set as 0.87 for (i = 0; i < 6; i += 2) { startX = cushion.points[i] startY = cushion.points[int(i + 1)] normalX = cushion.normals[i]; normalY = cushion.normals[int(i + 1)]; // Compute the distance from the centre of the ball to each cushion segment. var p1: Number = (ball.x - startX) * normalX + (ball.y - startY) * normalY; var p2: Number = (ball.x2 - startX) * normalX + (ball.y2 - startY) * normalY; // No collision if the final distance is greater than the ball radius, greater then // the initial distance or the change is insignificant. if (p2 > 12.6 || p2 > p1 || p1 - p2 <= 1E-8) continue; // Use linear interpolation to compute the relative collision time. // Only account for this collision if no other collision occured earlier. var rct: Number = (12.6 - p1) / (p2 - p1); if (rct >= m_minRCT || rct < -1E-8) continue; // For a cushion segment, say AB, calculate the point of impact P on the line // containing AB. To check if P lies inside the segment AB, use the two conditions // |AP| <= |AB| and AP.AB >= 0 (where '.' is the dot product) impactX = ball.x + rct * (ball.x2 - ball.x); impactY = ball.y + rct * (ball.y2 - ball.y); var impactRX: Number = impactX - 12.6 * normalX - startX; var impactRY: Number = impactY - 12.6 * normalY - startY; endRX = cushion.points[int(i + 2)] - startX; endRY = cushion.points[int(i + 3)] - startY; if (impactRX * impactRX + impactRY * impactRY <= endRX * endRX + endRY * endRY && impactRX * endRX + impactRY * endRY >= 0) { // Collision detected! m_minRCT = rct; ball.vxc = ball.vx + rct * (ball.vx2 - ball.vx); ball.vyc = ball.vy + rct * (ball.vy2 - ball.vy); p2 = (ball.vxc * normalX + ball.vyc * normalY) * -1.87; ball.vxc += p2 * normalX; ball.vyc += p2 * normalY; ball.potStatus = 0; return true; } } // Check cushion corners... endRX = ball.x2 - ball.x; endRY = ball.y2 - ball.y; for (i = 2; i < 6; i += 2) { startX = ball.x - cushion.points[i]; startY = ball.y - cushion.points[int(i + 1)]; rct = _quadSolve( endRX * endRX + endRY * endRY, 2 * (startX * endRX + startY * endRY), startX * startX + startY * startY - 158.76 ); if (rct !== -1 && rct < m_minRCT) { // Ball has collided with the corner. Check if it is moving towards or away from it. normalX = cushion.cornerNormals[i]; normalY = cushion.cornerNormals[int(i + 1)]; ball.vxc = ball.vx + rct * (ball.vx2 - ball.vx); ball.vyc = ball.vy + rct * (ball.vy2 - ball.vy); p2 = ball.vxc * normalX + ball.vyc * normalY; if (p2 <= -1E-8) { // Ball is going towards the corner normal, so a collision is detected. ball.vxc -= p2 * normalX * 1.87; ball.vyc -= p2 * normalY * 1.87; ball.potStatus = 0; m_minRCT = rct; return true; } } } return false; } /** * Checks for a ball entering a pocket. * If a pocket entry is detected, the _minRCT field will be set to the appropriate values. * * @param ball The ball to check. * * @return True if the ball will enter any of the pockets, false otherwise. */ private function _checkBallPocketEntry(ball: Ball): Boolean { var centres: Vector. = pocketCentres; var dx: Number = ball.x2 - ball.x; var dy: Number = ball.y2 - ball.y; var a: Number = dx * dx + dy * dy; for (var i: int = 0, n: int = pocketCentres.length; i < n; i += 2) { // Check for collision with each pocket. A potting occurs if the distance // between the ball centre and pocket centre is less than the pocket radius. var x1: Number = ball.x - centres[i]; var y1: Number = ball.y - centres[int(i + 1)]; var rct: Number = _quadSolve(a, 2 * (x1 * dx + y1 * dy), x1 * x1 + y1 * y1 - 506.25); if (rct !== -1) { if (rct < m_minRCT) { m_minRCT = rct; ball.potStatus = 1; return true; } // A ball can never contact two pockets simultaneously, so exit. return false; } } return false; } /** * Checks for collisions between two balls. * If a collision is detected, the vxc and vyc fields of both Ball objects and the _minRCT field * will be set to the appropriate values. * * @param ball1 The first ball * @param ball2 The second ball. * * @return True if there is a collision between the two balls, false if there is no collision. */ private function _checkTwoBallCollision(ball1: Ball, ball2: Ball): Boolean { if (ball1.vx === 0 && ball1.vy === 0 && ball2.vx === 0 && ball2.vy === 0) return false; // Find the relative collision time. var r1x: Number = ball2.x - ball1.x; var r1y: Number = ball2.y - ball1.y; var drx: Number = (ball2.x2 - ball1.x2) - r1x; var dry: Number = (ball2.y2 - ball1.y2) - r1y; var rct: Number; if (r1x * r1x + r1y * r1y < 635.04) { rct = 0; } else { rct = _quadSolve( drx * drx + dry * dry, 2 * (r1x * drx + r1y * dry), r1x * r1x + r1y * r1y - 635.04 ); } if (rct === -1 || rct > m_minRCT) return false; // Calculate the (pre-collision) velocities of the two balls normal to the line // of contact. var normalX: Number = (r1x + rct * drx); var normalY: Number = (r1y + rct * dry); var k: Number = 1 / Math.sqrt(normalX * normalX + normalY * normalY); normalX *= k; normalY *= k; var u1x: Number = ball1.vx + rct * (ball1.vx2 - ball1.vx); var u1y: Number = ball1.vy + rct * (ball1.vy2 - ball1.vy); var u2x: Number = ball2.vx + rct * (ball2.vx2 - ball2.vx); var u2y: Number = ball2.vy + rct * (ball2.vy2 - ball2.vy); var u1n: Number = u1x * normalX + u1y * normalY; var u2n: Number = u2x * normalX + u2y * normalY; if (u2n >= u1n) return false; // Balls are moving away from each other, so no collision // The COR for ball-ball collisions is currently set as e=0.8 // (1-0.8)/2 = 0.1, (1+0.8)/2 = 0.9 // Now calculate the post-collision velocities var v1n: Number = u1n * 0.1 + u2n * 0.9; var v2n: Number = u1n * 0.9 + u2n * 0.1; ball1.vxc = u1x + (v1n - u1n) * normalX; ball1.vyc = u1y + (v1n - u1n) * normalY; ball2.vxc = u2x + (v2n - u2n) * normalX; ball2.vyc = u2y + (v2n - u2n) * normalY; m_minRCT = rct; return true; } /* FOR DEBUGGING ONLY */ private function _logTableState(): void { var balls: Vector. = this.balls; trace(""------- Table log ---------""); for (var i: int = 0; i < 22; i++) { var b: Ball = balls[i]; if (b.potStatus === 0) { trace( ""Ball #"" + i + "" (colour "" + b.colour + "") x = "" + b.x.toFixed(15) + "", y = "" + b.y.toFixed(15) + "", vx = "" + b.vx.toFixed(15) + "", vy = "" + b.vy.toFixed(15) ); } else { trace(""Ball #"" + i + "" (colour "" + b.colour + ""): potted""); } } trace(); } } }",16330,True,2530.3693473419453,median "package laya.webgl.canvas { import laya.display.Sprite; import laya.maths.Bezier; import laya.maths.Matrix; import laya.maths.Point; import laya.maths.Rectangle; import laya.renders.Render; import laya.resource.Bitmap; import laya.resource.Context; import laya.resource.HTMLCanvas; import laya.resource.Texture; import laya.utils.Color; import laya.utils.HTMLChar; import laya.utils.RunDriver; import laya.utils.Stat; import laya.utils.VectorGraphManager; import laya.webgl.canvas.save.SaveClipRectStencil; import laya.webgl.WebGL; import laya.webgl.WebGLContext; import laya.webgl.atlas.AtlasResourceManager; import laya.webgl.canvas.save.ISaveData; import laya.webgl.canvas.save.SaveBase; import laya.webgl.canvas.save.SaveClipRect; import laya.webgl.canvas.save.SaveMark; import laya.webgl.canvas.save.SaveTransform; import laya.webgl.canvas.save.SaveTranslate; import laya.webgl.resource.RenderTargetMAX; import laya.webgl.resource.WebGLImage; import laya.webgl.shader.Shader; import laya.webgl.shader.d2.Shader2D; import laya.webgl.shader.d2.ShaderDefines2D; import laya.webgl.shader.d2.skinAnishader.SkinMeshBuffer; import laya.webgl.shader.d2.value.FillTextureSV; import laya.webgl.shader.d2.value.PrimitiveSV; import laya.webgl.shader.d2.value.TextSV; import laya.webgl.shader.d2.value.Value2D; import laya.webgl.shapes.IShape; import laya.webgl.submit.ISubmit; import laya.webgl.submit.Submit; import laya.webgl.submit.SubmitCanvas; import laya.webgl.submit.SubmitOtherIBVB; import laya.webgl.submit.SubmitScissor; import laya.webgl.submit.SubmitStencil; import laya.webgl.submit.SubmitTarget; import laya.webgl.submit.SubmitTexture; import laya.webgl.text.DrawText; import laya.webgl.text.FontInContext; import laya.webgl.utils.Buffer2D; import laya.webgl.utils.GlUtils; import laya.webgl.utils.IndexBuffer2D; import laya.webgl.utils.RenderState2D; import laya.webgl.utils.VertexBuffer2D; public class WebGLContext2D extends Context { /*[DISABLE-ADD-VARIABLE-DEFAULT-VALUE]*/ public static const _SUBMITVBSIZE:int = 32000; public static const _MAXSIZE:int = 99999999; public static const _RECTVBSIZE:int = 16; public static const MAXCLIPRECT:Rectangle = /*[STATIC SAFE]*/ new Rectangle(0, 0, _MAXSIZE, _MAXSIZE); public static var _COUNT:int = 0; public static var _tmpMatrix:Matrix = /*[STATIC SAFE]*/ new Matrix(); private static var _fontTemp:FontInContext = new FontInContext(); private static var _drawStyleTemp:DrawStyle = new DrawStyle(null); public static function __init__():void { ContextParams.DEFAULT = new ContextParams(); } public var _x:Number = 0; public var _y:Number = 0; public var _id:int = ++_COUNT; private var _other:ContextParams; private var _path:Path = null; private var _primitiveValue2D:Value2D; private var _drawCount:int = 1; private var _maxNumEle:int = 0; private var _clear:Boolean = false; private var _width:Number = _MAXSIZE; private var _height:Number = _MAXSIZE; private var _isMain:Boolean = false; private var _atlasResourceChange:int = 0; public var _submits:* = []; public var _curSubmit:* = null; public var _ib:IndexBuffer2D = null; public var _vb:VertexBuffer2D = null; // 不同的顶点格式,使用不同的顶点缓冲区 public var _clipRect:Rectangle = MAXCLIPRECT; public var _curMat:Matrix; public var _nBlendType:int = 0; public var _save:*; public var _targets:RenderTargetMAX; public var _renderKey:Number; public var _saveMark:SaveMark = null; public var _shader2D:Shader2D = new Shader2D(); /**所cacheAs精灵*/ public var sprite:Sprite; public function WebGLContext2D(c:HTMLCanvas) { //__JS__('this.drawTexture = this._drawTextureM'); _canvas = c; _curMat = Matrix.create(); if (Render.isFlash) { _ib = IndexBuffer2D.create(WebGLContext.STATIC_DRAW); GlUtils.fillIBQuadrangle(_ib, 16); } else _ib = IndexBuffer2D.QuadrangleIB; _vb = VertexBuffer2D.create(-1); _other = ContextParams.DEFAULT; _save = [SaveMark.Create(this)]; _save.length = 10; clear(); } public override function setIsMainContext():void { this._isMain = true; } public function clearBG(r:Number, g:Number, b:Number, a:Number):void { var gl:WebGLContext = WebGL.mainContext; gl.clearColor(r, g, b, a); gl.clear(WebGLContext.COLOR_BUFFER_BIT); } public function _getSubmits():Array { return _submits; } override public function destroy():void { sprite = null; _curMat && _curMat.destroy(); _targets && _targets.destroy(); _targets = null; for (var i:int = 0, n:int = _submits._length; i < n; i++) _submits[i].releaseRender(); _submits.length = 0; _submits._length = 0; _curSubmit = null; _path && _path.recover(); _path = null; if (_vb) { _vb.releaseResource(); _vb.dispose(); _vb.destory(); _vb = null; } _canvas = null; _ib && (_ib != IndexBuffer2D.QuadrangleIB) && _ib.releaseResource(); } override public function clear():void { _vb.clear(); _targets && (_targets.repaint = true); _other = ContextParams.DEFAULT; _clear = true; _repaint = false; _drawCount = 1; _renderKey = 0; _other.lineWidth = _shader2D.ALPHA = 1.0; _nBlendType = 0; // BlendMode.NORMAL; _clipRect = MAXCLIPRECT; _curSubmit = Submit.RENDERBASE; _shader2D.glTexture = null; _shader2D.fillStyle = _shader2D.strokeStyle = DrawStyle.DEFAULT; for (var i:int = 0, n:int = _submits._length; i < n; i++) _submits[i].releaseRender(); _submits._length = 0; _curMat.identity(); _other.clear(); _saveMark = _save[0]; _save._length = 1; } public function size(w:Number, h:Number):void { if (_width != w || _height != h) { if (w == 0 || h == 0) { if (_vb._byteLength != 0) { _width = w; _height = h; _vb.clear(); _vb.upload(); } for (var i:int = 0, n:int = _submits._length; i < n; i++) _submits[i].releaseRender(); _submits.length = 0; _submits._length = 0; _curSubmit = null; _path && _path.recover(); _path = null; sprite = null; _targets && (_targets.destroy()); _targets = null; } else { _width = w; _height = h; _targets && (_targets.size(w, h)); _canvas.memorySize -= _canvas.memorySize;//webGLCanvas为0; } } } public function set asBitmap(value:Boolean):void { if (value) { _targets || (_targets = new RenderTargetMAX()); _targets.repaint = true; if (!_width || !_height) throw Error(""asBitmap no size!""); _targets.setSP(sprite); _targets.size(_width, _height); } else _targets = null; } public function _getTransformMatrix():Matrix { return this._curMat; } override public function set fillStyle(value:*):void { _shader2D.fillStyle.equal(value) || (SaveBase.save(this, SaveBase.TYPE_FILESTYLE, _shader2D, false), _shader2D.fillStyle = DrawStyle.create(value)); } public function get fillStyle():* { return _shader2D.fillStyle; } override public function set globalAlpha(value:Number):void { value = Math.floor(value * 1000) / 1000; if (value != _shader2D.ALPHA) { SaveBase.save(this, SaveBase.TYPE_ALPHA, _shader2D, true); _shader2D.ALPHA = value; } } override public function get globalAlpha():Number { return _shader2D.ALPHA; } public function set textAlign(value:String):void { (_other.textAlign === value) || (_other = _other.make(), SaveBase.save(this, SaveBase.TYPE_TEXTALIGN, _other, false), _other.textAlign = value); } public function get textAlign():String { return _other.textAlign; } override public function set textBaseline(value:String):void { (_other.textBaseline === value) || (_other = _other.make(), SaveBase.save(this, SaveBase.TYPE_TEXTBASELINE, _other, false), _other.textBaseline = value); } public function get textBaseline():String { return _other.textBaseline; } override public function set globalCompositeOperation(value:String):void { var n:* = BlendMode.TOINT[value]; n == null || (_nBlendType === n) || (SaveBase.save(this, SaveBase.TYPE_GLOBALCOMPOSITEOPERATION, this, true), _curSubmit = Submit.RENDERBASE, _renderKey = 0, _nBlendType = n /*, _shader2D.ALPHA = 1*/); } override public function get globalCompositeOperation():String { return BlendMode.NAMES[_nBlendType]; } override public function set strokeStyle(value:*):void { _shader2D.strokeStyle.equal(value) || (SaveBase.save(this, SaveBase.TYPE_STROKESTYLE, _shader2D, false), _shader2D.strokeStyle = DrawStyle.create(value)); } public function get strokeStyle():* { return _shader2D.strokeStyle; } override public function translate(x:Number, y:Number):void { if (x !== 0 || y !== 0) { SaveTranslate.save(this); if (_curMat.bTransform) { SaveTransform.save(this); _curMat.transformPointN(Point.TEMP.setTo(x, y)); x = Point.TEMP.x; y = Point.TEMP.y; } this._x += x; this._y += y; } } public function set lineWidth(value:Number):void { (_other.lineWidth === value) || (_other = _other.make(), SaveBase.save(this, SaveBase.TYPE_LINEWIDTH, _other, false), _other.lineWidth = value); } public function get lineWidth():Number { return _other.lineWidth; } override public function save():void { _save[_save._length++] = SaveMark.Create(this); } override public function restore():void { var sz:int = _save._length; if (sz < 1) return; for (var i:int = sz - 1; i >= 0; i--) { var o:ISaveData = _save[i]; o.restore(this); if (o.isSaveMark()) { _save._length = i; return; } } } override public function set font(str:String):void { if (str == _other.font.toString()) return; _other = _other.make(); SaveBase.save(this, SaveBase.TYPE_FONT, _other, false); _other.font === FontInContext.EMPTY ? (_other.font = new FontInContext(str)) : (_other.font.setFont(str)); } private function _fillText(txt:*, words:Vector., x:Number, y:Number, fontStr:String, color:String, strokeColor:String, lineWidth:int, textAlign:String):void { var shader:Shader2D = _shader2D; var curShader:Value2D = _curSubmit.shaderValue; var font:FontInContext = fontStr ? FontInContext.create(fontStr) : _other.font; if (AtlasResourceManager.enabled) { if (shader.ALPHA !== curShader.ALPHA) shader.glTexture = null; DrawText.drawText(this, txt, words, _curMat, font, textAlign || _other.textAlign, color, strokeColor, lineWidth, x, y); } else { var preDef:int = _shader2D.defines.getValue(); var colorAdd:Array = color ? Color.create(color)._color : shader.colorAdd; if (shader.ALPHA !== curShader.ALPHA || colorAdd !== shader.colorAdd || curShader.colorAdd !== shader.colorAdd) { shader.glTexture = null; shader.colorAdd = colorAdd; } //shader.defines.add(ShaderDefines2D.COLORADD); DrawText.drawText(this, txt, words, _curMat, font, textAlign || _other.textAlign, color, strokeColor, lineWidth, x, y); //shader.defines.setValue(preDef); } } public override function fillWords(words:Vector., x:Number, y:Number, fontStr:String, color:String):void { _fillText(null, words, x, y, fontStr, color, null, -1, null); } override public function fillText(txt:*, x:Number, y:Number, fontStr:String, color:String, textAlign:String):void { _fillText(txt, null, x, y, fontStr, color, null, -1, textAlign); } override public function strokeText(txt:*, x:Number, y:Number, fontStr:String, color:String, lineWidth:Number, textAlign:String):void { _fillText(txt, null, x, y, fontStr, null, color, lineWidth || 1, textAlign); } override public function fillBorderText(txt:*, x:Number, y:Number, fontStr:String, fillColor:String, borderColor:String, lineWidth:int, textAlign:String):void { _fillBorderText(txt, null, x, y, fontStr, fillColor, borderColor, lineWidth, textAlign); } private function _fillBorderText(txt:*, words:Vector., x:Number, y:Number, fontStr:String, fillColor:String, borderColor:String, lineWidth:int, textAlign:String):void { if (!AtlasResourceManager.enabled) { _fillText(txt, words, x, y, fontStr, null, borderColor, lineWidth || 1, textAlign); _fillText(txt, words, x, y, fontStr, fillColor, null, -1, textAlign); return; } //判断是否大图合集 var shader:Shader2D = _shader2D; var curShader:Value2D = _curSubmit.shaderValue; if (shader.ALPHA !== curShader.ALPHA) shader.glTexture = null; var font:FontInContext = fontStr ? (_fontTemp.setFont(fontStr), _fontTemp) : _other.font; DrawText.drawText(this, txt, words, _curMat, font, textAlign || _other.textAlign, fillColor, borderColor, lineWidth || 1, x, y); } override public function fillBorderWords(words:Vector., x:Number, y:Number, font:String, color:String, borderColor:String, lineWidth:int):void { _fillBorderText(null, words, x, y, font, color, borderColor, lineWidth, null); } override public function fillRect(x:Number, y:Number, width:Number, height:Number, fillStyle:*):void { var vb:VertexBuffer2D = _vb; if (GlUtils.fillRectImgVb(vb, _clipRect, x, y, width, height, Texture.DEF_UV, _curMat, _x, _y, 0, 0)) { _renderKey = 0; var pre:DrawStyle = _shader2D.fillStyle; fillStyle && (_shader2D.fillStyle = DrawStyle.create(fillStyle)); var shader:Shader2D = _shader2D; var curShader:Value2D = _curSubmit.shaderValue; if (shader.fillStyle !== curShader.fillStyle || shader.ALPHA !== curShader.ALPHA) { shader.glTexture = null; var submit:Submit = _curSubmit = Submit.createSubmit(this, _ib, vb, ((vb._byteLength - _RECTVBSIZE * Buffer2D.FLOAT32) / 32) * 3, Value2D.create(ShaderDefines2D.COLOR2D, 0)); submit.shaderValue.color = shader.fillStyle._color._color; submit.shaderValue.ALPHA = shader.ALPHA; _submits[_submits._length++] = submit; } _curSubmit._numEle += 6; _shader2D.fillStyle = pre; } } public override function fillTexture(texture:Texture, x:Number, y:Number, width:Number, height:Number, type:String, offset:Point, other:*):void { if (!(texture.loaded && texture.bitmap && texture.source)) { if (this.sprite) { Laya.timer.callLater(this, this._repaintSprite); } return; } ; var vb:VertexBuffer2D = _vb; var w:Number = texture.bitmap.width, h:Number = texture.bitmap.height, uv:Array = texture.uv; var ox:Number = offset.x % texture.width, oy:Number = offset.y % texture.height; if (w != other.w || h != other.h) { if (!other.w && !other.h) { other.oy = other.ox = 0; switch (type) { case ""repeat"": other.width = width; other.height = height; break; case ""repeat-x"": other.width = width; if (oy < 0) { if (texture.height + oy > height) { other.height = height; } else { other.height = texture.height + oy; } } else { other.oy = oy; if (texture.height + oy > height) { other.height = height - oy; } else { other.height = texture.height; } } break; case ""repeat-y"": if (ox < 0) { if (texture.width + ox > width) { other.width = width; } else { other.width = texture.width + ox; } } else { other.ox = ox; if (texture.width + ox > width) { other.width = width - ox; } else { other.width = texture.width; } } other.height = height; break; default: other.width = width; other.height = height; break; } } other.w = w; other.h = h; other.uv = [0, 0, other.width / w, 0, other.width / w, other.height / h, 0, other.height / h]; } x += other.ox; y += other.oy; ox -= other.ox; oy -= other.oy; if (GlUtils.fillRectImgVb(vb, _clipRect, x, y, other.width, other.height, other.uv, _curMat, _x, _y, 0, 0)) { _renderKey = 0; var submit:SubmitTexture = SubmitTexture.create(this, _ib, vb, ((vb._byteLength - _RECTVBSIZE * Buffer2D.FLOAT32) / 32) * 3, Value2D.create(ShaderDefines2D.FILLTEXTURE, 0)); _submits[_submits._length++] = submit; var shaderValue:FillTextureSV = submit.shaderValue as FillTextureSV; shaderValue.textureHost = texture; var tTextureX:Number = uv[0] * w; var tTextureY:Number = uv[1] * h; var tTextureW:Number = (uv[2] - uv[0]) * w; var tTextureH:Number = (uv[5] - uv[3]) * h; var tx:Number = -ox / w; var ty:Number = -oy / h; shaderValue.u_TexRange[0] = tTextureX / w; shaderValue.u_TexRange[1] = tTextureW / w; shaderValue.u_TexRange[2] = tTextureY / h; shaderValue.u_TexRange[3] = tTextureH / h; shaderValue.u_offset[0] = tx; shaderValue.u_offset[1] = ty; //var curShader:Value2D = _curSubmit.shaderValue; //var shader:Shader2D = _shader2D; if (AtlasResourceManager.enabled && !this._isMain) //而且不是主画布 submit.addTexture(texture, (vb._byteLength >> 2) - WebGLContext2D._RECTVBSIZE); //submit._preIsSameTextureShader = _curSubmit._renderType === Submit.TYPE_FILLTEXTURE && shader.ALPHA === curShader.ALPHA; _curSubmit = submit; submit._renderType = Submit.TYPE_FILLTEXTURE; submit._numEle += 6; } } public function setShader(shader:Shader):void { SaveBase.save(this, SaveBase.TYPE_SHADER, _shader2D, true); _shader2D.shader = shader; } public function setFilters(value:Array):void { SaveBase.save(this, SaveBase.TYPE_FILTERS, _shader2D, true); _shader2D.filters = value; _curSubmit = Submit.RENDERBASE; _renderKey = 0; _drawCount++; } public override function drawTexture(tex:Texture, x:Number, y:Number, width:Number, height:Number, tx:Number, ty:Number):void { _drawTextureM(tex, x, y, width, height, tx, ty, null, 1); } public function addTextureVb(invb:Array, x:Number, y:Number):void { var finalVB:VertexBuffer2D = _curSubmit._vb || _vb; var vpos:int = (finalVB._byteLength >> 2) /*FLOAT32*/; // + WebGLContext2D._RECTVBSIZE; finalVB.byteLength = ((vpos + WebGLContext2D._RECTVBSIZE) << 2); var vbdata:* = finalVB.getFloat32Array(); for (var i:int = 0, ci:int = 0; i < 16; i += 4) { vbdata[vpos++] = invb[i] + x; vbdata[vpos++] = invb[i + 1] + y; vbdata[vpos++] = invb[i + 2]; vbdata[vpos++] = invb[i + 3]; } _curSubmit._numEle += 6; _maxNumEle = Math.max(_maxNumEle, _curSubmit._numEle); finalVB._upload = true; } public function willDrawTexture(tex:Texture, alpha:Number):Number { if (!(tex.loaded && tex.bitmap && tex.source)) //source内调用tex.active(); { if (sprite) { Laya.timer.callLater(this, _repaintSprite); } return 0; } var webGLImg:Bitmap = tex.bitmap as Bitmap; var rid:Number = webGLImg.id + _shader2D.ALPHA * alpha + Submit.TYPE_TEXTURE; if (rid == _renderKey) return rid; var shader:Shader2D = _shader2D; var preAlpha:Number = shader.ALPHA; var curShader:Value2D = _curSubmit.shaderValue; shader.ALPHA *= alpha; _renderKey = rid; _drawCount++; shader.glTexture = webGLImg; var vb:VertexBuffer2D = _vb; var submit:SubmitTexture = null; var vbSize:int = (vb._byteLength / 32) * 3; submit = SubmitTexture.create(this, _ib, vb, vbSize, Value2D.create(ShaderDefines2D.TEXTURE2D, 0)); _submits[_submits._length++] = submit; submit.shaderValue.textureHost = tex; submit._renderType = Submit.TYPE_TEXTURE; submit._preIsSameTextureShader = _curSubmit._renderType === Submit.TYPE_TEXTURE && shader.ALPHA === curShader.ALPHA; _curSubmit = submit; shader.ALPHA = preAlpha; return rid; } public override function drawTextures(tex:Texture, pos:Array, tx:Number, ty:Number):void { if (!(tex.loaded && tex.bitmap && tex.source)) //source内调用tex.active(); { sprite && Laya.timer.callLater(this, _repaintSprite); return; } var pre:Rectangle = _clipRect; _clipRect = MAXCLIPRECT; if (!_drawTextureM(tex, pos[0], pos[1], tex.width, tex.height, tx, ty, null, 1)) { alert(""drawTextures err""); return; } _clipRect = pre; Stat.drawCall++;//= pos.length / 2; if (pos.length < 4) return; var finalVB:VertexBuffer2D = _curSubmit._vb || _vb; var sx:Number = _curMat.a, sy:Number = _curMat.d; for (var i:int = 2, sz:int = pos.length; i < sz; i += 2) { GlUtils.copyPreImgVb(finalVB, (pos[i] - pos[i - 2]) * sx, (pos[i + 1] - pos[i - 1]) * sy); _curSubmit._numEle += 6; } _maxNumEle = Math.max(_maxNumEle, _curSubmit._numEle); } private function _drawTextureM(tex:Texture, x:Number, y:Number, width:Number, height:Number, tx:Number, ty:Number, m:Matrix, alpha:Number):Boolean { if (!(tex.loaded && tex.source)) //source内调用tex.active(); { if (sprite) { Laya.timer.callLater(this, _repaintSprite); } return false; } var finalVB:VertexBuffer2D = _curSubmit._vb || _vb; var webGLImg:Bitmap = tex.bitmap as Bitmap; x += tx; y += ty; _drawCount++; var rid:Number = webGLImg.id + _shader2D.ALPHA * alpha + Submit.TYPE_TEXTURE; if (rid != _renderKey) { _renderKey = rid; var curShader:Value2D = _curSubmit.shaderValue; var shader:Shader2D = _shader2D; var alphaBack:Number = shader.ALPHA; shader.ALPHA *= alpha; shader.glTexture = webGLImg; var vb:VertexBuffer2D = _vb; var submit:SubmitTexture = null; var vbSize:int = (vb._byteLength / 32) * 3; submit = SubmitTexture.create(this, _ib, vb, vbSize, Value2D.create(ShaderDefines2D.TEXTURE2D, 0)); _submits[_submits._length++] = submit; submit.shaderValue.textureHost = tex; submit._renderType = Submit.TYPE_TEXTURE; submit._preIsSameTextureShader = _curSubmit._renderType === Submit.TYPE_TEXTURE && shader.ALPHA === curShader.ALPHA; _curSubmit = submit; finalVB = _curSubmit._vb || _vb; shader.ALPHA = alphaBack; } if (GlUtils.fillRectImgVb(finalVB, _clipRect, x, y, width || tex.width, height || tex.height, tex.uv, m || _curMat, _x, _y, 0, 0)) { if (AtlasResourceManager.enabled && !this._isMain) //而且不是主画布 (_curSubmit as SubmitTexture).addTexture(tex, (finalVB._byteLength >> 2) - WebGLContext2D._RECTVBSIZE); _curSubmit._numEle += 6; _maxNumEle = Math.max(_maxNumEle, _curSubmit._numEle); return true; } return false; } private function _repaintSprite():void { sprite.repaint(); } ///** //* 请保证图片已经在内存 //* @param ... args //*/ //public override function drawImage(... args):void { //var img:* = args[0]; //var tex:Texture = (img.__texture || (img.__texture = new Texture(new WebGLImage(img)))) as Texture; //tex.uv = Texture.DEF_UV; //switch (args.length) { //case 3: //if (!img.__width) { //img.__width = img.width; //img.__height = img.height //} //drawTexture(tex, args[1], args[2], img.__width, img.__height, 0, 0); //break; //case 5: //drawTexture(tex, args[1], args[2], args[3], args[4], 0, 0); //break; //case 9: //var x1:Number = args[1] / img.__width; //var x2:Number = (args[1] + args[3]) / img.__width; //var y1:Number = args[2] / img.__height; //var y2:Number = (args[2] + args[4]) / img.__height; //tex.uv = [x1, y1, x2, y1, x2, y2, x1, y2]; //drawTexture(tex, args[5], args[6], args[7], args[8], 0, 0); //break; //} //} public function _drawText(tex:Texture, x:Number, y:Number, width:Number, height:Number, m:Matrix, tx:Number, ty:Number, dx:Number, dy:Number):void { var webGLImg:Bitmap = tex.bitmap as Bitmap; _drawCount++; var rid:Number = webGLImg.id + _shader2D.ALPHA + Submit.TYPE_TEXTURE; if (rid != _renderKey) { _renderKey = rid; var curShader:Value2D = _curSubmit.shaderValue; var shader:Shader2D = _shader2D; shader.glTexture = webGLImg; var vb:VertexBuffer2D = _vb; var submit:SubmitTexture = null; var submitID:Number; var vbSize:int = (vb._byteLength / 32) * 3; if (AtlasResourceManager.enabled) { //开启了大图合集 submit = SubmitTexture.create(this, _ib, vb, vbSize, Value2D.create(ShaderDefines2D.TEXTURE2D, 0)); } else { submit = SubmitTexture.create(this, _ib, vb, vbSize, TextSV.create()); //submit.shaderValue.colorAdd = shader.colorAdd; //submit.shaderValue.defines.add(ShaderDefines2D.COLORADD); } submit._preIsSameTextureShader = _curSubmit._renderType === Submit.TYPE_TEXTURE && shader.ALPHA === curShader.ALPHA; _submits[_submits._length++] = submit; submit.shaderValue.textureHost = tex; submit._renderType = Submit.TYPE_TEXTURE; _curSubmit = submit; } tex.active(); var finalVB:VertexBuffer2D = _curSubmit._vb || _vb; if (GlUtils.fillRectImgVb(finalVB, _clipRect, x + tx, y + ty, width || tex.width, height || tex.height, tex.uv, m || _curMat, _x, _y, dx, dy, true)) { if (AtlasResourceManager.enabled && !this._isMain) { (_curSubmit as SubmitTexture).addTexture(tex, (finalVB._byteLength >> 2) - WebGLContext2D._RECTVBSIZE); } _curSubmit._numEle += 6; _maxNumEle = Math.max(_maxNumEle, _curSubmit._numEle); } } override public function drawTextureWithTransform(tex:Texture, x:Number, y:Number, width:Number, height:Number, transform:Matrix, tx:Number, ty:Number, alpha:Number):void { if (!transform) { _drawTextureM(tex, x, y, width, height, tx, ty, null, alpha); return; } var curMat:Matrix = _curMat; var prex:Number = _x; var prey:Number = _y; (tx !== 0 || ty !== 0) && (_x = tx * curMat.a + ty * curMat.c, _y = ty * curMat.d + tx * curMat.b); if (transform && curMat.bTransform) { Matrix.mul(transform, curMat, _tmpMatrix); transform = _tmpMatrix; transform._checkTransform(); } else { _x += curMat.tx; _y += curMat.ty; } _drawTextureM(tex, x, y, width, height, 0, 0, transform, alpha); _x = prex; _y = prey; } public function fillQuadrangle(tex:Texture, x:Number, y:Number, point4:Array, m:Matrix):void { var submit:Submit = this._curSubmit; var vb:VertexBuffer2D = _vb; var shader:Shader2D = _shader2D; var curShader:Value2D = submit.shaderValue; _renderKey = 0; if (tex.bitmap) { var t_tex:WebGLImage = tex.bitmap as WebGLImage; if (shader.glTexture != t_tex || shader.ALPHA !== curShader.ALPHA) { shader.glTexture = t_tex; submit = _curSubmit = Submit.createSubmit(this, _ib, vb, ((vb._byteLength) / 32) * 3, Value2D.create(ShaderDefines2D.TEXTURE2D, 0)); submit.shaderValue.glTexture = t_tex; _submits[_submits._length++] = submit; } GlUtils.fillQuadrangleImgVb(vb, x, y, point4, tex.uv, m || _curMat, _x, _y); } else { if (!submit.shaderValue.fillStyle || !submit.shaderValue.fillStyle.equal(tex) || shader.ALPHA !== curShader.ALPHA) { shader.glTexture = null; submit = _curSubmit = Submit.createSubmit(this, _ib, vb, ((vb._byteLength) / 32) * 3, Value2D.create(ShaderDefines2D.COLOR2D, 0)); submit.shaderValue.defines.add(ShaderDefines2D.COLOR2D); submit.shaderValue.fillStyle = DrawStyle.create(tex); _submits[_submits._length++] = submit; } GlUtils.fillQuadrangleImgVb(vb, x, y, point4, Texture.DEF_UV, m || _curMat, _x, _y); } submit._numEle += 6; } override public function drawTexture2(x:Number, y:Number, pivotX:Number, pivotY:Number, transform:Matrix, alpha:Number, blendMode:String, args:Array):void { if (alpha == 0) return; var curMat:Matrix = _curMat; _x = x * curMat.a + y * curMat.c; _y = y * curMat.d + x * curMat.b; if (transform) { if (curMat.bTransform || transform.bTransform) { Matrix.mul(transform, curMat, _tmpMatrix); transform = _tmpMatrix; } else { _x += transform.tx + curMat.tx; _y += transform.ty + curMat.ty; transform = Matrix.EMPTY; } } if (alpha === 1 && !blendMode) //tx:Texture, x:Number, y:Number, width:Number, height:Number _drawTextureM(args[0], args[1] - pivotX, args[2] - pivotY, args[3], args[4], 0, 0, transform, 1); else { var preAlpha:Number = _shader2D.ALPHA; var preblendType:int = _nBlendType; _shader2D.ALPHA = alpha; blendMode && (_nBlendType = BlendMode.TOINT(blendMode)); _drawTextureM(args[0], args[1] - pivotX, args[2] - pivotY, args[3], args[4], 0, 0, transform, 1); _shader2D.ALPHA = preAlpha; _nBlendType = preblendType; } _x = _y = 0; } override public function drawCanvas(canvas:HTMLCanvas, x:Number, y:Number, width:Number, height:Number):void { var src:WebGLContext2D = canvas.context as WebGLContext2D; _renderKey = 0; if (src._targets) { this._submits[this._submits._length++] = SubmitCanvas.create(src, 0, null); //src._targets.flush(src); _curSubmit = Submit.RENDERBASE; src._targets.drawTo(this, x, y, width, height); } else { var submit:SubmitCanvas = this._submits[this._submits._length++] = SubmitCanvas.create(src, _shader2D.ALPHA, _shader2D.filters); var sx:Number = width / canvas.width; var sy:Number = height / canvas.height; var mat:Matrix = submit._matrix; _curMat.copyTo(mat); sx != 1 && sy != 1 && mat.scale(sx, sy); var tx:Number = mat.tx, ty:Number = mat.ty; mat.tx = mat.ty = 0; mat.transformPoint(Point.TEMP.setTo(x, y)); mat.translate(Point.TEMP.x + tx, Point.TEMP.y + ty); _curSubmit = Submit.RENDERBASE; } if (Config.showCanvasMark) { save(); lineWidth = 4; strokeStyle = src._targets ? ""yellow"" : ""green""; strokeRect(x - 1, y - 1, width + 2, height + 2, 1); strokeRect(x, y, width, height, 1); restore(); } } public function drawTarget(scope:*, x:Number, y:Number, width:Number, height:Number, m:Matrix, proName:String, shaderValue:Value2D, uv:Array = null, blend:int = -1):void { var vb:VertexBuffer2D = _vb; if (GlUtils.fillRectImgVb(vb, _clipRect, x, y, width, height, uv || Texture.DEF_UV, m || _curMat, _x, _y, 0, 0)) { _renderKey = 0; var shader:Shader2D = _shader2D; shader.glTexture = null; var curShader:Value2D = _curSubmit.shaderValue; var submit:SubmitTarget = _curSubmit = SubmitTarget.create(this, _ib, vb, ((vb._byteLength - _RECTVBSIZE * Buffer2D.FLOAT32) / 32) * 3, shaderValue, proName); if (blend == -1) { submit.blendType = _nBlendType; } else { submit.blendType = blend; } submit.scope = scope; _submits[_submits._length++] = submit; _curSubmit._numEle += 6; } } override public function transform(a:Number, b:Number, c:Number, d:Number, tx:Number, ty:Number):void { SaveTransform.save(this); Matrix.mul(Matrix.TEMP.setTo(a, b, c, d, tx, ty), _curMat, _curMat); _curMat._checkTransform(); } override public function setTransformByMatrix(value:Matrix):void { value.copyTo(_curMat); } override public function transformByMatrix(value:Matrix):void { SaveTransform.save(this); Matrix.mul(value, _curMat, _curMat); _curMat._checkTransform(); } public function rotate(angle:Number):void { SaveTransform.save(this); _curMat.rotateEx(angle); } override public function scale(scaleX:Number, scaleY:Number):void { SaveTransform.save(this); _curMat.scaleEx(scaleX, scaleY); } override public function clipRect(x:Number, y:Number, width:Number, height:Number):void { if (_curMat.b != 0 || _curMat.c != 0) { _renderKey = 0; //1、创建模板缓冲区 var submitStencil0:SubmitStencil = SubmitStencil.create(4); addRenderObject(submitStencil0); //2、创建Rect顶点并绘制Rect var vb:VertexBuffer2D = _vb; var nPos:int = (vb._byteLength >> 2); if (GlUtils.fillRectImgVb(vb, null, x, y, width, height, Texture.DEF_UV, _curMat, _x, _y, 0, 0)) { var shader:Shader2D = _shader2D; shader.glTexture = null; var submit:Submit = _curSubmit = Submit.createSubmit(this, _ib, vb, ((vb._byteLength - _RECTVBSIZE * Buffer2D.FLOAT32) / 32) * 3, Value2D.create(ShaderDefines2D.COLOR2D, 0)); submit.shaderValue.ALPHA = 1.0; _submits[_submits._length++] = submit; _curSubmit._numEle += 6; } else { alert(""clipRect calc stencil rect error""); } //3、设置模板缓冲区 var submitStencil1:SubmitStencil = SubmitStencil.create(5); addRenderObject(submitStencil1); /* //4、计算clipRect var vbdata:* = vb.getFloat32Array(); var minx:Number = Math.min(Math.min(Math.min(vbdata[nPos + 0], vbdata[nPos + 4]), vbdata[nPos + 8]), vbdata[nPos + 12]); var maxx:Number = Math.max(Math.max(Math.max(vbdata[nPos + 0], vbdata[nPos + 4]), vbdata[nPos + 8]), vbdata[nPos + 12]); var miny:Number = Math.min(Math.min(Math.min(vbdata[nPos + 1], vbdata[nPos + 5]), vbdata[nPos + 9]), vbdata[nPos + 13]); var maxy:Number = Math.max(Math.max(Math.max(vbdata[nPos + 1], vbdata[nPos + 5]), vbdata[nPos + 9]), vbdata[nPos + 13]); SaveClipRectStencil.save(this, submitStencil1); _clipRect.x = minx; _clipRect.y = miny; _clipRect.width = maxx - minx; _clipRect.height = maxy - miny; */ _clipRect.x = x; _clipRect.y = y; _clipRect.width = width; _clipRect.height = height; SaveClipRectStencil.save(this, submitStencil1); _curSubmit = Submit.RENDERBASE; //5、在restore中进行恢复 //代码在SaveClipRectStencil.as中,进行恢复的模板缓冲区 } else { width *= _curMat.a; height *= _curMat.d; var p:Point = Point.TEMP; this._curMat.transformPoint(p.setTo(x, y)); _renderKey = 0; var submitSc:SubmitScissor = _curSubmit = SubmitScissor.create(this); _submits[this._submits._length++] = submitSc; submitSc.submitIndex = this._submits._length; submitSc.submitLength = 9999999; SaveClipRect.save(this, submitSc); var clip:Rectangle = this._clipRect; var x1:Number = clip.x, y1:Number = clip.y; var r:Number = p.x + width, b:Number = p.y + height; x1 < p.x && (clip.x = p.x); y1 < p.y && (clip.y = p.y); clip.width = Math.min(r, x1 + clip.width) - clip.x; clip.height = Math.min(b, y1 + clip.height) - clip.y; _shader2D.glTexture = null; submitSc.clipRect.copyFrom(clip); _curSubmit = Submit.RENDERBASE; } } public function setIBVB(x:Number, y:Number, ib:IndexBuffer2D, vb:VertexBuffer2D, numElement:int, mat:Matrix, shader:Shader, shaderValues:Value2D, startIndex:int = 0, offset:int = 0, type:int = 0):void { if (ib === null) { if (!Render.isFlash) { ib = _ib; } else { var falshVB:* = vb; (falshVB._selfIB) || (falshVB._selfIB = IndexBuffer2D.create(WebGLContext.STATIC_DRAW)); falshVB._selfIB.clear(); ib = falshVB._selfIB; } GlUtils.expandIBQuadrangle(ib, (vb._byteLength / (Buffer2D.FLOAT32 * vb.vertexStride * 4))); } if (!shaderValues || !shader) throw Error(""setIBVB must input:shader shaderValues""); var submit:SubmitOtherIBVB = SubmitOtherIBVB.create(this, vb, ib, numElement, shader, shaderValues, startIndex, offset, type); mat || (mat = Matrix.EMPTY); mat.translate(x, y); Matrix.mul(mat, _curMat, submit._mat); mat.translate(-x, -y); _submits[this._submits._length++] = submit; _curSubmit = Submit.RENDERBASE; _renderKey = 0; } public function addRenderObject(o:ISubmit):void { this._submits[this._submits._length++] = o; } public function fillTrangles(tex:Texture, x:Number, y:Number, points:Array, m:Matrix):void { var submit:Submit = this._curSubmit; var vb:VertexBuffer2D = _vb; var shader:Shader2D = _shader2D; var curShader:Value2D = submit.shaderValue; var length:int = points.length >> 4 /*16*/; var t_tex:WebGLImage = tex.bitmap as WebGLImage; _renderKey = 0; if (shader.glTexture != t_tex || shader.ALPHA !== curShader.ALPHA) { submit = _curSubmit = Submit.createSubmit(this, _ib, vb, ((vb._byteLength) / 32) * 3, Value2D.create(ShaderDefines2D.TEXTURE2D, 0)); submit.shaderValue.textureHost = tex; _submits[_submits._length++] = submit; } GlUtils.fillTranglesVB(vb, x, y, points, m || _curMat, _x, _y); submit._numEle += length * 6; } public function submitElement(start:int, end:int):void { var renderList:Array = this._submits; end < 0 && (end = renderList._length); while (start < end) { start += renderList[start].renderSubmit(); } } public function finish():void { WebGL.mainContext.finish(); } override public function flush():int { var maxNum:int = Math.max(_vb._byteLength / (Buffer2D.FLOAT32 * 16), _maxNumEle / 6) + 8; if (maxNum > (_ib.bufferLength / (6 * Buffer2D.SHORT))) { GlUtils.expandIBQuadrangle(_ib, maxNum); } if (!this._isMain && AtlasResourceManager.enabled && AtlasResourceManager._atlasRestore > _atlasResourceChange) //这里还要判断大图合集是否修改 { _atlasResourceChange = AtlasResourceManager._atlasRestore; var renderList:Array = this._submits; for (var i:int = 0, s:int = renderList._length; i < s; i++) { var submit:ISubmit = renderList[i] as ISubmit; if (submit.getRenderType() === Submit.TYPE_TEXTURE) (submit as SubmitTexture).checkTexture(); } } //_vb.bind_upload(_ib);//重复绑定 submitElement(0, _submits._length); _path && _path.reset(); SkinMeshBuffer.instance && SkinMeshBuffer.getInstance().reset(); _curSubmit = Submit.RENDERBASE; _renderKey = 0; return _submits._length; } /*******************************************start矢量绘制***************************************************/ private var mId:int = -1; private var mHaveKey:Boolean = false; private var mHaveLineKey:Boolean = false; private var mX:Number = 0; private var mY:Number = 0; private var mOutPoint:Point public function setPathId(id:int):void { mId = id; if (mId != -1) { mHaveKey = false; var tVGM:VectorGraphManager = VectorGraphManager.getInstance(); if (tVGM.shapeDic[mId]) { mHaveKey = true; } mHaveLineKey = false; if (tVGM.shapeLineDic[mId]) { mHaveLineKey = true; } } } public function movePath(x:Number, y:Number):void { var _x1:Number = x, _y1:Number = y; x = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; mX += x; mY += y; } override public function beginPath():void { var tPath:Path = _getPath(); tPath.tempArray.length = 0; tPath.closePath = false; mX = 0; mY = 0; } public function closePath():void { _path.closePath = true; } public function fill(isConvexPolygon:Boolean = false):void { var tPath:Path = _getPath(); this.drawPoly(0, 0, tPath.tempArray, fillStyle._color.numColor, 0, 0, isConvexPolygon); } override public function stroke():void { var tPath:Path = _getPath(); if (lineWidth > 0) { if (mId == -1) { tPath.drawLine(0, 0, tPath.tempArray, lineWidth, this.strokeStyle._color.numColor); } else { if (mHaveLineKey) { var tShapeLine:IShape = VectorGraphManager.getInstance().shapeLineDic[mId]; tShapeLine.rebuild(tPath.tempArray); tPath.setGeomtry(tShapeLine); } else { VectorGraphManager.getInstance().addLine(mId, tPath.drawLine(0, 0, tPath.tempArray, lineWidth, this.strokeStyle._color.numColor)); } } tPath.update(); //var tArray:Array = RenderState2D.getMatrArray(); //RenderState2D.mat2MatArray(_curMat, tArray); var tPosArray:Array = [mX, mY]; var tempSubmit:Submit = Submit.createShape(this, tPath.ib, tPath.vb, tPath.count, tPath.offset, Value2D.create(ShaderDefines2D.PRIMITIVE, 0)); tempSubmit.shaderValue.ALPHA = _shader2D.ALPHA; (tempSubmit.shaderValue as PrimitiveSV).u_pos = tPosArray; tempSubmit.shaderValue.u_mmat2 = RenderState2D.TEMPMAT4_ARRAY; _submits[_submits._length++] = tempSubmit; } } public function line(fromX:Number, fromY:Number, toX:Number, toY:Number, lineWidth:Number, mat:Matrix):void { var submit:Submit = _curSubmit; var vb:VertexBuffer2D = _vb; if (GlUtils.fillLineVb(vb, _clipRect, fromX, fromY, toX, toY, lineWidth, mat)) { _renderKey = 0; var shader:Shader2D = _shader2D; var curShader:Value2D = submit.shaderValue; if (shader.strokeStyle !== curShader.strokeStyle || shader.ALPHA !== curShader.ALPHA) { shader.glTexture = null; submit = _curSubmit = Submit.createSubmit(this, _ib, vb, ((vb._byteLength - _RECTVBSIZE * Buffer2D.FLOAT32) / 32) * 3, Value2D.create(ShaderDefines2D.COLOR2D, 0)); submit.shaderValue.strokeStyle = shader.strokeStyle; submit.shaderValue.mainID = ShaderDefines2D.COLOR2D; submit.shaderValue.ALPHA = shader.ALPHA; _submits[_submits._length++] = submit; } submit._numEle += 6; } } public function moveTo(x:Number, y:Number, b:Boolean = true):void { var tPath:Path = _getPath(); if (b) { var _x1:Number = x, _y1:Number = y; x = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; } tPath.addPoint(x, y); } public function lineTo(x:Number, y:Number, b:Boolean = true):void { var tPath:Path = _getPath(); if (b) { var _x1:Number = x, _y1:Number = y; x = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; } tPath.addPoint(x, y); } override public function drawCurves(x:Number, y:Number, args:Array):void { setPathId(-1); beginPath(); strokeStyle = args[3]; lineWidth = args[4]; var points:Array = args[2]; x += args[0], y += args[1]; //movePath(x, y); moveTo(x + points[0], y + points[1]); var i:int = 2, n:int = points.length; while (i < n) { quadraticCurveTo(x + points[i++], y + points[i++], x + points[i++], y + points[i++]); } stroke(); } override public function arcTo(x1:Number, y1:Number, x2:Number, y2:Number, r:Number):void { if (mId != -1) { if (mHaveKey) { return; } } var tPath:Path = _getPath(); var x0:Number = tPath.getEndPointX(); var y0:Number = tPath.getEndPointY(); var dx0:Number, dy0:Number, dx1:Number, dy1:Number, a:Number, d:Number, cx:Number, cy:Number, a0:Number, a1:Number; var dir:Boolean; // Calculate tangential circle to lines (x0,y0)-(x1,y1) and (x1,y1)-(x2,y2). var _x1:Number = x1, _y1:Number = y1; x1 = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y1 = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; _x1 = x2, _y1 = y2; x2 = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y2 = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; r = _curMat.a * r + _curMat.c * r; dx0 = x0 - x1; dy0 = y0 - y1; dx1 = x2 - x1; dy1 = y2 - y1; Point.TEMP.setTo(dx0, dy0); Point.TEMP.normalize(); dx0 = Point.TEMP.x; dy0 = Point.TEMP.y; Point.TEMP.setTo(dx1, dy1); Point.TEMP.normalize(); dx1 = Point.TEMP.x; dy1 = Point.TEMP.y; a = Math.acos(dx0 * dx1 + dy0 * dy1); var tTemp:Number = Math.tan(a / 2.0); d = r / tTemp; if (d > 10000) { lineTo(x1, y1); return; } if (dx0 * dy1 - dx1 * dy0 <= 0.0) { cx = x1 + dx0 * d + dy0 * r; cy = y1 + dy0 * d - dx0 * r; a0 = Math.atan2(dx0, -dy0); a1 = Math.atan2(-dx1, dy1); dir = false; } else { cx = x1 + dx0 * d - dy0 * r; cy = y1 + dy0 * d + dx0 * r; a0 = Math.atan2(-dx0, dy0); a1 = Math.atan2(dx1, -dy1); dir = true; } arc(cx, cy, r, a0, a1, dir, false); } public function arc(cx:Number, cy:Number, r:Number, startAngle:Number, endAngle:Number, counterclockwise:Boolean = false, b:Boolean = true):void { if (mId != -1) { var tShape:IShape = VectorGraphManager.getInstance().shapeDic[this.mId]; if (tShape) { if (mHaveKey && !tShape.needUpdate(_curMat)) return; } cx = 0; cy = 0; } var a:Number = 0, da:Number = 0, hda:Number = 0, kappa:Number = 0; var dx:Number = 0, dy:Number = 0, x:Number = 0, y:Number = 0, tanx:Number = 0, tany:Number = 0; var px:Number = 0, py:Number = 0, ptanx:Number = 0, ptany:Number = 0; var i:int, ndivs:int, nvals:int; // Clamp angles da = endAngle - startAngle; if (!counterclockwise) { if (Math.abs(da) >= Math.PI * 2) { da = Math.PI * 2; } else { while (da < 0.0) { da += Math.PI * 2; } } } else { if (Math.abs(da) >= Math.PI * 2) { da = -Math.PI * 2; } else { while (da > 0.0) { da -= Math.PI * 2; } } } if (r < 101) { ndivs = Math.max(10, da * r / 5); } else if (r < 201) { ndivs = Math.max(10, da * r / 20); } else { ndivs = Math.max(10, da * r / 40); } hda = (da / ndivs) / 2.0; kappa = Math.abs(4 / 3 * (1 - Math.cos(hda)) / Math.sin(hda)); if (counterclockwise) kappa = -kappa; nvals = 0; var tPath:Path = _getPath(); var _x1:Number, _y1:Number; for (i = 0; i <= ndivs; i++) { a = startAngle + da * (i / ndivs); dx = Math.cos(a); dy = Math.sin(a); x = cx + dx * r; y = cy + dy * r; if (b) { _x1 = x, _y1 = y; x = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; } if (x != _path.getEndPointX() || y != _path.getEndPointY()) { tPath.addPoint(x, y); } } dx = Math.cos(endAngle); dy = Math.sin(endAngle); x = cx + dx * r; y = cy + dy * r; if (b) { _x1 = x, _y1 = y; x = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; } if (x != _path.getEndPointX() || y != _path.getEndPointY()) { tPath.addPoint(x, y); } } override public function quadraticCurveTo(cpx:Number, cpy:Number, x:Number, y:Number):void { var tBezier:Bezier = Bezier.I; var tResultArray:Array = []; var _x1:Number = x, _y1:Number = y; x = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; y = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; _x1 = cpx, _y1 = cpy; cpx = _curMat.a * _x1 + _curMat.c * _y1 + _curMat.tx; cpy = _curMat.b * _x1 + _curMat.d * _y1 + _curMat.ty; var tArray:Array = tBezier.getBezierPoints([_path.getEndPointX(), _path.getEndPointY(), cpx, cpy, x, y], 30, 2); for (var i:int = 0, n:int = tArray.length / 2; i < n; i++) { lineTo(tArray[i * 2], tArray[i * 2 + 1], false); } lineTo(x, y, false); } override public function rect(x:Number, y:Number, width:Number, height:Number):void { _other = _other.make(); _other.path || (_other.path = new Path()); _other.path.rect(x, y, width, height); } public function strokeRect(x:Number, y:Number, width:Number, height:Number, parameterLineWidth:Number):void { var tW:Number = parameterLineWidth * 0.5; line(x - tW, y, x + width + tW, y, parameterLineWidth, _curMat); line(x + width, y, x + width, y + height, parameterLineWidth, _curMat); line(x, y, x, y + height, parameterLineWidth, _curMat); line(x - tW, y + height, x + width + tW, y + height, parameterLineWidth, _curMat); } override public function clip():void { } /** * 画多边形(用) * @param x * @param y * @param points */ public function drawPoly(x:Number, y:Number, points:Array, color:uint, lineWidth:Number, boderColor:uint, isConvexPolygon:Boolean = false):void { _renderKey = 0; _shader2D.glTexture = null; //置空下,打断纹理相同合并 var tPath:Path = _getPath(); if (mId == -1) { tPath.polygon(x, y, points, color, lineWidth ? lineWidth : 1, boderColor) } else { if (mHaveKey) { var tShape:IShape = VectorGraphManager.getInstance().shapeDic[mId]; tShape.setMatrix(_curMat); tShape.rebuild(tPath.tempArray); tPath.setGeomtry(tShape); } else { var t:IShape = tPath.polygon(x, y, points, color, lineWidth ? lineWidth : 1, boderColor); VectorGraphManager.getInstance().addShape(mId, t); t.setMatrix(_curMat); } } tPath.update(); var tPosArray:Array = [mX, mY]; //var tArray:Array = RenderState2D.getMatrArray(); //RenderState2D.mat2MatArray(_curMat, tArray); var tempSubmit:Submit; if (!isConvexPolygon) { //开启模板缓冲,把模板操作设为GL_INVERT //开启模板缓冲,填充模板数据 var submit:SubmitStencil = SubmitStencil.create(4); addRenderObject(submit); tempSubmit = Submit.createShape(this, tPath.ib, tPath.vb, tPath.count, tPath.offset, Value2D.create(ShaderDefines2D.PRIMITIVE, 0)); tempSubmit.shaderValue.ALPHA = _shader2D.ALPHA; (tempSubmit.shaderValue as PrimitiveSV).u_pos = tPosArray; tempSubmit.shaderValue.u_mmat2 = RenderState2D.EMPTYMAT4_ARRAY; _submits[_submits._length++] = tempSubmit; submit = SubmitStencil.create(5); addRenderObject(submit); } //通过模板数据来开始真实的绘制 tempSubmit = Submit.createShape(this, tPath.ib, tPath.vb, tPath.count, tPath.offset, Value2D.create(ShaderDefines2D.PRIMITIVE, 0)); tempSubmit.shaderValue.ALPHA = _shader2D.ALPHA; (tempSubmit.shaderValue as PrimitiveSV).u_pos = tPosArray; tempSubmit.shaderValue.u_mmat2 = RenderState2D.EMPTYMAT4_ARRAY; _submits[_submits._length++] = tempSubmit; if (!isConvexPolygon) { tempSubmit = Submit.createShape(this, tPath.ib, tPath.vb, tPath.count, tPath.offset, Value2D.create(ShaderDefines2D.PRIMITIVE, 0)); tempSubmit.shaderValue.ALPHA = _shader2D.ALPHA; (tempSubmit.shaderValue as PrimitiveSV).u_pos = tPosArray; tempSubmit.shaderValue.u_mmat2 = RenderState2D.EMPTYMAT4_ARRAY; SubmitStencil.restore2(this,tempSubmit); } //画闭合线 if (lineWidth > 0) { if (mHaveLineKey) { var tShapeLine:IShape = VectorGraphManager.getInstance().shapeLineDic[mId]; tShapeLine.rebuild(tPath.tempArray); tPath.setGeomtry(tShapeLine); } else { VectorGraphManager.getInstance().addShape(mId, tPath.drawLine(x, y, points, lineWidth, boderColor)); } tPath.update(); tempSubmit = Submit.createShape(this, tPath.ib, tPath.vb, tPath.count, tPath.offset, Value2D.create(ShaderDefines2D.PRIMITIVE, 0)); tempSubmit.shaderValue.ALPHA = _shader2D.ALPHA; tempSubmit.shaderValue.u_mmat2 = RenderState2D.EMPTYMAT4_ARRAY; _submits[_submits._length++] = tempSubmit; } } /*******************************************end矢量绘制***************************************************/ public function drawParticle(x:Number, y:Number, pt:*):void { pt.x = x; pt.y = y; _submits[_submits._length++] = pt; } private function _getPath():Path { return _path || (_path = new Path()); } } } import laya.webgl.text.FontInContext; class ContextParams { public static var DEFAULT:ContextParams; public var lineWidth:int = 1; public var path:*; public var textAlign:String; public var textBaseline:String; public var font:FontInContext = FontInContext.EMPTY; public function clear():void { lineWidth = 1; path && path.clear(); textAlign = textBaseline = null; font = FontInContext.EMPTY; } public function make():ContextParams { return this === DEFAULT ? new ContextParams() : this; } }",16191,True,2898.742708732407,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, 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( ). 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. ",12189,True,2538.1747815854255,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 { 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: *
    *
  • selects an item in the drop-down list
  • *
  • clicks outside of the drop-down list
  • *
  • clicks the drop-down button while the drop-down list is * displayed
  • *
  • presses the ESC key while the drop-down list is displayed
  • *
* * @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 { var item:Object = selectedItem; return itemToLabel(item); } //-------------------------------------------------------------------------- // // 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.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.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; } } } ",16286,True,2835.838270296003,median "CLASS zcl_abapgit_gui_router DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES zif_abapgit_gui_event_handler. PROTECTED SECTION. PRIVATE SECTION. METHODS general_page_routing IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . METHODS abapgit_services_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . METHODS db_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . CLASS-METHODS file_download IMPORTING !iv_package TYPE devclass !iv_xstr TYPE xstring RAISING zcx_abapgit_exception . METHODS git_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . METHODS sap_gui_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . METHODS other_utilities IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . METHODS zip_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . METHODS repository_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception . METHODS get_page_diff IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_branch_overview IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_stage IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . CLASS-METHODS jump_display_transport IMPORTING !iv_transport TYPE trkorr RAISING zcx_abapgit_exception . CLASS-METHODS jump_display_user IMPORTING !iv_username TYPE xubname RAISING zcx_abapgit_exception . METHODS call_browser IMPORTING !iv_url TYPE csequence RAISING zcx_abapgit_exception . METHODS get_state_settings IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i . METHODS get_state_diff IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i . METHODS get_state_db_edit IMPORTING ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i . METHODS main_page RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception. ENDCLASS. CLASS zcl_abapgit_gui_router IMPLEMENTATION. METHOD abapgit_services_actions. DATA li_main_page TYPE REF TO zcl_abapgit_gui_page_main. IF ii_event->mv_action = zif_abapgit_definitions=>c_action-abapgit_home. CREATE OBJECT li_main_page EXPORTING iv_only_favorites = abap_true. rs_handled-page = li_main_page. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ENDIF. ENDMETHOD. METHOD call_browser. cl_gui_frontend_services=>execute( EXPORTING document = |{ iv_url }| EXCEPTIONS cntl_error = 1 error_no_gui = 2 bad_parameter = 3 file_not_found = 4 path_not_found = 5 file_extension_unknown = 6 error_execute_failed = 7 synchronous_failed = 8 not_supported_by_gui = 9 OTHERS = 10 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD db_actions. DATA ls_db_key TYPE zif_abapgit_persistence=>ty_content. DATA lo_query TYPE REF TO zcl_abapgit_string_map. lo_query = ii_event->query( ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-db_edit. lo_query->to_abap( CHANGING cs_container = ls_db_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db_edit EXPORTING is_key = ls_db_key. rs_handled-state = get_state_db_edit( ii_event ). WHEN zif_abapgit_definitions=>c_action-db_display. lo_query->to_abap( CHANGING cs_container = ls_db_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db_dis EXPORTING is_key = ls_db_key. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ENDCASE. ENDMETHOD. METHOD file_download. DATA: lv_path TYPE string, lv_default TYPE string, li_fe_serv TYPE REF TO zif_abapgit_frontend_services, lv_package TYPE devclass. lv_package = iv_package. TRANSLATE lv_package USING '/#'. CONCATENATE lv_package '_' sy-datlo '_' sy-timlo INTO lv_default. li_fe_serv = zcl_abapgit_ui_factory=>get_frontend_services( ). lv_path = li_fe_serv->show_file_save_dialog( iv_title = 'Export ZIP' iv_extension = 'zip' iv_default_filename = lv_default ). li_fe_serv->file_download( iv_path = lv_path iv_xstr = iv_xstr ). ENDMETHOD. METHOD general_page_routing. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_last_repo_key TYPE zif_abapgit_persistence=>ty_repo-key, lt_repo_fav_list TYPE zif_abapgit_repo_srv=>ty_repo_list, lt_repo_all_list TYPE zif_abapgit_repo_srv=>ty_repo_list. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zcl_abapgit_gui=>c_action-go_home. lv_last_repo_key = zcl_abapgit_persistence_user=>get_instance( )->get_repo_show( ). IF lv_last_repo_key IS NOT INITIAL. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lv_last_repo_key. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ELSE. rs_handled-page = main_page( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ENDIF. WHEN zif_abapgit_definitions=>c_action-go_db. "" Go DB util page CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_debuginfo. "" Go debug info rs_handled-page = zcl_abapgit_gui_page_debuginfo=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_settings. "" Go global settings rs_handled-page = zcl_abapgit_gui_page_sett_glob=>create( ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_settings_personal. "" Go personal settings rs_handled-page = zcl_abapgit_gui_page_sett_pers=>create( ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_background_run. "" Go background run page rs_handled-page = zcl_abapgit_gui_page_run_bckg=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_repo_diff "" Go Diff page OR zif_abapgit_definitions=>c_action-go_file_diff. rs_handled-page = get_page_diff( ii_event ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. WHEN zif_abapgit_definitions=>c_action-go_stage. "" Go Staging page rs_handled-page = get_page_stage( ii_event ). rs_handled-state = get_state_diff( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_branch_overview. "" Go repo branch overview rs_handled-page = get_page_branch_overview( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_tutorial. "" Go to tutorial rs_handled-page = zcl_abapgit_gui_page_tutorial=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-documentation. "" abapGit docs zcl_abapgit_services_abapgit=>open_abapgit_wikipage( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-go_explore. "" dotabap zcl_abapgit_services_abapgit=>open_dotabap_homepage( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-changelog. "" abapGit full changelog zcl_abapgit_services_abapgit=>open_abapgit_changelog( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD main_page. DATA lt_repo_fav_list TYPE zif_abapgit_repo_srv=>ty_repo_list. DATA lt_repo_all_list TYPE zif_abapgit_repo_srv=>ty_repo_list. "" for performance reasons, only load favorites lt_repo_fav_list = zcl_abapgit_repo_srv=>get_instance( )->list_favorites( ). IF lt_repo_fav_list IS INITIAL. "" if there are no favorites, check if there are any repositories at all "" if not, go to tutorial where the user can create the first repository lt_repo_all_list = zcl_abapgit_repo_srv=>get_instance( )->list( ). IF lt_repo_all_list IS NOT INITIAL. CREATE OBJECT ri_page TYPE zcl_abapgit_gui_page_main EXPORTING iv_only_favorites = abap_false. ELSE. ri_page = zcl_abapgit_gui_page_tutorial=>create( ). ENDIF. ELSE. CREATE OBJECT ri_page TYPE zcl_abapgit_gui_page_main EXPORTING iv_only_favorites = abap_true. ENDIF. ENDMETHOD. METHOD get_page_branch_overview. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lo_page TYPE REF TO zcl_abapgit_gui_page_boverview. lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). CREATE OBJECT lo_page EXPORTING io_repo = lo_repo. ri_page = lo_page. ENDMETHOD. METHOD get_page_diff. DATA: ls_file TYPE zif_abapgit_definitions=>ty_file, ls_object TYPE zif_abapgit_definitions=>ty_item, lo_page TYPE REF TO zcl_abapgit_gui_page_diff, lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). ls_file-path = ii_event->query( )->get( 'PATH' ). ls_file-filename = ii_event->query( )->get( 'FILENAME' ). "" unescape ? ls_object-obj_type = ii_event->query( )->get( 'OBJ_TYPE' ). ls_object-obj_name = ii_event->query( )->get( 'OBJ_NAME' ). "" unescape ? CREATE OBJECT lo_page EXPORTING iv_key = lv_key is_file = ls_file is_object = ls_object. ri_page = lo_page. ENDMETHOD. METHOD get_page_stage. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_seed TYPE string, lo_stage_page TYPE REF TO zcl_abapgit_gui_page_stage, lo_code_inspector_page TYPE REF TO zcl_abapgit_gui_page_code_insp, lo_page_repo TYPE REF TO zcl_abapgit_gui_page_repo_view, lv_answer TYPE c LENGTH 1, lv_question_text TYPE string, lv_question_title TYPE string, lv_show_create_branch_popup TYPE c LENGTH 1, lx_error TYPE REF TO cx_sy_move_cast_error. lv_key = ii_event->query( )->get( 'KEY' ). lv_seed = ii_event->query( )->get( 'SEED' ). TRY. lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). CATCH cx_sy_move_cast_error INTO lx_error. zcx_abapgit_exception=>raise( `Staging is only possible for online repositories.` ). ENDTRY. IF lo_repo->get_local_settings( )-code_inspector_check_variant IS NOT INITIAL. CREATE OBJECT lo_code_inspector_page EXPORTING io_repo = lo_repo. ri_page = lo_code_inspector_page. ELSEIF lo_repo->get_selected_branch( ) CP zif_abapgit_definitions=>c_git_branch-tags. lv_show_create_branch_popup = abap_true. lv_question_title = 'Staging on a tag'. lv_question_text = 'You are currently working on a tag.'. lv_question_text = |{ lv_question_text } You must be on a branch to stage.|. lv_question_text = |{ lv_question_text } Create new branch?|. ELSEIF lo_repo->get_selected_commit( ) IS NOT INITIAL. lv_show_create_branch_popup = abap_true. lv_question_title = 'Staging on a checked out commit'. lv_question_text = 'You are currently checked out in a commit.'. lv_question_text = |{ lv_question_text } You must be on a branch to stage.|. lv_question_text = |{ lv_question_text } Create new branch?|. ELSE. "" force refresh on stage, to make sure the latest local and remote files are used lo_repo->refresh( ). CREATE OBJECT lo_stage_page EXPORTING io_repo = lo_repo iv_seed = lv_seed. ri_page = lo_stage_page. ENDIF. IF lv_show_create_branch_popup = abap_true. lv_answer = zcl_abapgit_ui_factory=>get_popups( )->popup_to_confirm( iv_titlebar = lv_question_title iv_text_question = lv_question_text iv_text_button_1 = 'New branch' ""Ideally the button name would be Create branch, but it did not fit iv_icon_button_1 = 'ICON_OKAY' iv_text_button_2 = 'Cancel' iv_icon_button_2 = 'ICON_CANCEL' iv_default_button = '2' iv_display_cancel_button = abap_false ). IF lv_answer = '1'. TRY. zcl_abapgit_services_git=>create_branch( iv_key = lo_repo->get_key( ) ). CATCH zcx_abapgit_cancel. ""Continue processing so we can return to the correct page ENDTRY. ENDIF. CREATE OBJECT lo_page_repo TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lo_repo->get_key( ). ri_page = lo_page_repo. ENDIF. ENDMETHOD. METHOD get_state_db_edit. "" In display mode, replace the page IF ii_event->mv_current_page_name = 'ZCL_ABAPGIT_GUI_PAGE_DB_DIS'. rv_state = zcl_abapgit_gui=>c_event_state-new_page_replacing. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page. ENDIF. ENDMETHOD. METHOD get_state_diff. "" Bookmark current page before jumping to diff page IF ii_event->mv_current_page_name CP 'ZCL_ABAPGIT_GUI_PAGE_DIFF'. rv_state = zcl_abapgit_gui=>c_event_state-new_page. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. ENDIF. ENDMETHOD. METHOD get_state_settings. "" Bookmark current page before jumping to any settings page IF ii_event->mv_current_page_name CP 'ZCL_ABAPGIT_GUI_PAGE_SETT_*'. rv_state = zcl_abapgit_gui=>c_event_state-new_page_replacing. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. ENDIF. ENDMETHOD. METHOD git_services. DATA lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-git_pull. "" GIT Pull zcl_abapgit_services_git=>pull( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_reset. "" GIT Reset zcl_abapgit_services_git=>reset( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_create. "" GIT Create new branch zcl_abapgit_services_git=>create_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_delete. "" GIT Delete remote branch zcl_abapgit_services_git=>delete_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_switch. "" GIT Switch branch zcl_abapgit_services_git=>switch_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-go_tag_overview. "" GIT Tag overview zcl_abapgit_services_git=>tag_overview( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_create. "" GIT Tag create CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_tag EXPORTING io_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-git_tag_delete. "" GIT Tag create zcl_abapgit_services_git=>delete_tag( lv_key ). zcl_abapgit_services_repo=>refresh( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_switch. "" GIT Switch Tag zcl_abapgit_services_git=>switch_tag( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD jump_display_transport. DATA: lv_transport_adt_uri TYPE string, lv_adt_link TYPE string, lv_adt_jump_enabled TYPE abap_bool. lv_adt_jump_enabled = zcl_abapgit_persist_factory=>get_settings( )->read( )->get_adt_jump_enabled( ). IF lv_adt_jump_enabled = abap_true. TRY. CALL METHOD ('CL_CTS_ADT_TM_URI_BUILDER')=>('CREATE_ADT_URI') EXPORTING trnumber = iv_transport RECEIVING result = lv_transport_adt_uri. lv_adt_link = |adt://{ sy-sysid }{ lv_transport_adt_uri }|. cl_gui_frontend_services=>execute( EXPORTING document = lv_adt_link EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'ADT Jump Error' ). ENDIF. CATCH cx_root. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = iv_transport. ENDTRY. ELSE. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = iv_transport. ENDIF. ENDMETHOD. METHOD jump_display_user. "" todo, user display in ADT CALL FUNCTION 'BAPI_USER_DISPLAY' EXPORTING username = iv_username. ENDMETHOD. METHOD other_utilities. IF ii_event->mv_action = zif_abapgit_definitions=>c_action-ie_devtools. zcl_abapgit_services_basis=>open_ie_devtools( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDIF. ENDMETHOD. METHOD repository_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_repo TYPE REF TO zcl_abapgit_repo, li_log TYPE REF TO zif_abapgit_log. lv_key = ii_event->query( )->get( 'KEY' ). IF lv_key IS NOT INITIAL. lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). ENDIF. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-repo_newoffline. "" New offline repo rs_handled-page = zcl_abapgit_gui_page_addofflin=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req. "" Add objects to transport zcl_abapgit_transport=>add_all_objects_to_trans_req( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_refresh. "" Repo refresh zcl_abapgit_services_repo=>refresh( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_syntax_check. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_syntax "" Syntax check EXPORTING io_repo = lo_repo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_code_inspector. "" Code inspector CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_code_insp EXPORTING io_repo = lo_repo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_purge. "" Repo purge all objects (uninstall) zcl_abapgit_services_repo=>purge( lv_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main EXPORTING iv_only_favorites = abap_true. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN zif_abapgit_definitions=>c_action-repo_remove. "" Repo remove zcl_abapgit_services_repo=>remove( lv_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main EXPORTING iv_only_favorites = abap_true. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN zif_abapgit_definitions=>c_action-repo_newonline. "" New offline repo rs_handled-page = zcl_abapgit_gui_page_addonline=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_refresh_checksums. "" Rebuild local checksums zcl_abapgit_services_repo=>refresh_local_checksums( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_toggle_fav. "" Toggle repo as favorite zcl_abapgit_services_repo=>toggle_favorite( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_transport_to_branch. "" Transport to branch zcl_abapgit_services_repo=>transport_to_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_settings. "" Repo settings rs_handled-page = zcl_abapgit_gui_page_sett_repo=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_local_settings. "" Local repo settings rs_handled-page = zcl_abapgit_gui_page_sett_locl=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_remote_settings. "" Remote repo settings rs_handled-page = zcl_abapgit_gui_page_sett_remo=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_background. "" Repo background mode rs_handled-page = zcl_abapgit_gui_page_sett_bckg=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_infos. "" Repo infos rs_handled-page = zcl_abapgit_gui_page_sett_info=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_log. "" Repo log li_log = lo_repo->get_log( ). zcl_abapgit_log_viewer=>show_log( li_log ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD sap_gui_actions. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, lx_ex TYPE REF TO zcx_abapgit_exception, li_html_viewer TYPE REF TO zif_abapgit_html_viewer. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-jump. "" Open object editor ls_item-obj_type = ii_event->query( )->get( 'TYPE' ). ls_item-obj_name = ii_event->query( )->get( 'NAME' ). ls_item-obj_name = cl_http_utility=>unescape_url( |{ ls_item-obj_name }| ). li_html_viewer = zcl_abapgit_ui_factory=>get_html_viewer( ). TRY. "" Hide HTML Viewer in dummy screen0 for direct CALL SCREEN to work li_html_viewer->set_visiblity( abap_false ). zcl_abapgit_objects=>jump( ls_item ). li_html_viewer->set_visiblity( abap_true ). CATCH zcx_abapgit_exception INTO lx_ex. li_html_viewer->set_visiblity( abap_true ). RAISE EXCEPTION lx_ex. ENDTRY. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-jump_transport. jump_display_transport( |{ ii_event->query( )->get( 'TRANSPORT' ) }| ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-jump_user. jump_display_user( |{ ii_event->query( )->get( 'USER' ) }| ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-url. call_browser( ii_event->query( )->get( 'URL' ) ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. rs_handled = zcl_abapgit_exit=>get_instance( )->on_event( ii_event ). IF rs_handled-state IS INITIAL. rs_handled = general_page_routing( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = repository_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = git_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = zip_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = db_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = abapgit_services_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = sap_gui_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = other_utilities( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled-state = zcl_abapgit_gui=>c_event_state-not_handled. ENDIF. ENDMETHOD. METHOD zip_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_repo TYPE REF TO zcl_abapgit_repo, lv_path TYPE string, lv_dest TYPE rfcdest, lv_msg TYPE c LENGTH 200, lv_xstr TYPE xstring, lv_package TYPE zif_abapgit_persistence=>ty_repo-package, lv_folder_logic TYPE string, lv_main_lang_only TYPE zif_abapgit_persistence=>ty_local_settings-main_language_only. CONSTANTS: BEGIN OF lc_page, main_view TYPE string VALUE 'ZCL_ABAPGIT_GUI_PAGE_MAIN', repo_view TYPE string VALUE 'ZCL_ABAPGIT_GUI_PAGE_REPO_VIEW', END OF lc_page. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-zip_import "" Import repo from ZIP OR zif_abapgit_definitions=>c_action-rfc_compare. "" Compare repo via RFC lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). IF ii_event->mv_action = zif_abapgit_definitions=>c_action-zip_import. lv_path = zcl_abapgit_ui_factory=>get_frontend_services( )->show_file_open_dialog( iv_title = 'Import ZIP' iv_extension = 'zip' iv_default_filename = '*.zip' ). lv_xstr = zcl_abapgit_ui_factory=>get_frontend_services( )->file_upload( lv_path ). ELSE. lv_dest = zcl_abapgit_ui_factory=>get_popups( )->popup_search_help( 'RFCDES-RFCDEST' ). IF lv_dest IS INITIAL. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. RETURN. ENDIF. lv_package = lo_repo->get_package( ). lv_folder_logic = lo_repo->get_dot_abapgit( )->get_folder_logic( ). lv_main_lang_only = lo_repo->get_local_settings( )-main_language_only. CALL FUNCTION 'Z_ABAPGIT_SERIALIZE_PACKAGE' DESTINATION lv_dest EXPORTING iv_package = lv_package iv_folder_logic = lv_folder_logic iv_main_lang_only = lv_main_lang_only IMPORTING ev_xstring = lv_xstr EXCEPTIONS system_failure = 1 MESSAGE lv_msg communication_failure = 2 MESSAGE lv_msg OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |RFC import error: { lv_msg }| ). ENDIF. ENDIF. lo_repo->set_files_remote( zcl_abapgit_zip=>load( lv_xstr ) ). zcl_abapgit_services_repo=>refresh( lv_key ). CASE ii_event->mv_current_page_name. WHEN lc_page-repo_view. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN lc_page-main_view. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lo_repo->get_key( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN OTHERS. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. WHEN zif_abapgit_definitions=>c_action-zip_export. "" Export repo as ZIP lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). lv_xstr = zcl_abapgit_zip=>encode_files( lo_repo->get_files_local( ) ). file_download( iv_package = lo_repo->get_package( ) iv_xstr = lv_xstr ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_package. "" Export package as ZIP rs_handled-page = zcl_abapgit_gui_page_ex_pckage=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-zip_transport. "" Export transports as ZIP zcl_abapgit_transport_mass=>run( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_object. "" Export object as ZIP rs_handled-page = zcl_abapgit_gui_page_ex_object=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ENDCASE. ENDMETHOD. ENDCLASS. ",8198,False,1942.8898492457895,median "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 d, 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_corresponding, tdate type d, tchar type c length 8, _another type i, end of ty_dummy_corresponding, tt_dummy_corresponding type standard table of ty_dummy_corresponding 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 d, 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. constants c_dummy_corresponding type ty_dummy_corresponding 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_positive for testing raising zcx_text2tab_error. methods parse_field_negative for testing raising zcx_text2tab_error. methods parse_field_special for testing raising zcx_text2tab_error. methods map_head_structure for testing. methods map_head_structure_corresp for testing raising zcx_text2tab_error. 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 raising zcx_text2tab_error. methods parse_time for testing raising zcx_text2tab_error. methods parse_float for testing raising zcx_text2tab_error. methods parse_ignore_convexit for testing raising zcx_text2tab_error. methods parse_typeless for testing. methods with_renames for testing. methods deep_structures for testing. methods parse_corresponding for testing raising zcx_text2tab_error. * ==== HELPERS === data mt_dummy_tmp type tt_dummy. data mt_dummy_str_tmp type tt_dummy_str. data mt_strict_tmp type abap_bool. data mt_field_components type zcl_text2tab_utils=>tt_comp_descr. 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_corresp type int4_table 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. methods _append_dummy importing iv_str type string changing ct_tab type standard table. methods append_dummy importing iv_str type string. methods append_dummy_s importing iv_str type string. methods test_parse importing positive type abap_bool f type string v type string exp type any optional err type string optional. methods test_parse_positive importing f type string v type string exp type any. methods test_parse_negative importing f type string v type string err type string. endclass. class zcl_text2tab_parser definition local friends ltcl_text2tab_parser_test. class ltcl_deep_helper definition final for testing. public section. interfaces zif_text2tab_deep_provider. methods constructor importing i_tab type ltcl_text2tab_parser_test=>tt_deep_sub. data mt_tab type ltcl_text2tab_parser_test=>tt_deep_sub. endclass. class ltcl_deep_helper implementation. method constructor. mt_tab = i_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. method create. data: lo type ref to zcl_text2tab_parser, lx type ref to zcx_text2tab_error, lv_date_format type zcl_text2tab_parser=>ty_date_format, 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. 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. 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 ). "" Parse to sorted and hashed tables *************** 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 ). "" 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. 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 ). "" 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. 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 ). endmethod. 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. method parse_negative. data: begin of wrong_struc ##NEEDED, mandt type mandt, tdate type d, tchar type c length 8, 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 7 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: strict = false and has_head = false 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 ). when 6. "" Wrong params: strict = true and corresponding = true l_exp_code = 'WP'. o->parse( exporting i_data = l_string i_strict = abap_true i_corresponding = abap_true importing e_container = dummy_tab_act ). when 7. "" Wrong params: strict = true and has_head = false l_exp_code = 'WP'. o->parse( exporting i_data = l_string i_strict = abap_false i_has_head = abap_false i_corresponding = abap_true importing e_container = dummy_tab_act ). 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. 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. method test_parse. data ls_dummy type ty_dummy. data ls_component like line of mt_field_components. data lx type ref to zcx_text2tab_error. field-symbols type any. read table mt_field_components into ls_component with key name = f. cl_abap_unit_assert=>assert_subrc( ). assign component f of structure ls_dummy to . cl_abap_unit_assert=>assert_subrc( ). try. o->parse_field( exporting is_component = ls_component i_value = v importing e_field = ). if positive = abap_true. cl_abap_unit_assert=>assert_equals( act = exp = exp msg = |Parse field positive: { f }| ). else. cl_abap_unit_assert=>fail( |Parse field negative didn''t raise: { f }| ). endif. catch zcx_text2tab_error into lx. if positive = abap_true. cl_abap_unit_assert=>fail( |Parse field positive must not raise: { f }| ). else. cl_abap_unit_assert=>assert_equals( act = lx->code exp = err msg = |Parse field negative wrong code: { f } [{ lx->code }]| ). endif. endtry. endmethod. method test_parse_positive. test_parse( positive = abap_true f = f v = v exp = exp ). endmethod. method test_parse_negative. test_parse( positive = abap_false f = f v = v err = err ). endmethod. method parse_field_positive. data ls_dummy type ty_dummy. data lo_struc_descr type ref to cl_abap_structdescr. lo_struc_descr ?= cl_abap_structdescr=>describe_by_data( ls_dummy ). mt_field_components = zcl_text2tab_utils=>describe_struct( i_struc = lo_struc_descr i_ignore_nonflat = abap_false ). "" Positive tests ****************************** test_parse_positive( f = 'TDATE' v = '01.02.2015' exp = '20150201' ). test_parse_positive( f = 'TDATE' v = '1.2.2015' exp = '20150201' ). test_parse_positive( f = 'TCHAR' v = 'ABC' exp = 'ABC' ). test_parse_positive( f = 'TSTRING' v = 'The string test' exp = 'The string test' ). test_parse_positive( f = 'TALPHA' v = '100000' exp = '0000100000' ). test_parse_positive( f = 'TNUMBER' v = '2015' exp = '2015' ). test_parse_positive( f = 'TINTEGER' v = '123' exp = 123 ). test_parse_positive( f = 'TRAW' v = '8E' exp = '8E' ). test_parse_positive( f = 'TFLOAT' v = '1,123456789' exp = '1.123456789' ). test_parse_positive( f = 'TFLOAT' v = '""1,123456789""' exp = '1.123456789' ). "" Quoted data, issue#6 test_parse_positive( f = 'TNUMBER' v = '""2015""' exp = '2015' ). "" Quoted data "" Decimal converion tests ********************* test_parse_positive( f = 'TDECIMAL' v = '1234,12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '-1234,12' exp = '-1234.12' ). "" Different amount formats test_parse_positive( f = 'TDECIMAL' v = '-1234,12' exp = '-1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '1234,12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '1234' exp = '1234' ). test_parse_positive( f = 'TDECIMAL' v = '1 234' exp = '1234' ). test_parse_positive( f = 'TDECIMAL' v = '1 234,12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '14,12' exp = '14.12' ). test_parse_positive( f = 'TDECIMAL' v = '1 234 567,12' exp = '1234567.12' ). test_parse_positive( f = 'TDECIMAL' v = '0' exp = '0' ). test_parse_positive( f = 'TDECIMAL' v = '0,0' exp = '0' ). test_parse_positive( f = 'TDECIMAL' v = '' exp = '0' ). test_parse_positive( f = 'TDECIMAL' v = '15' exp = '15' ). o->mv_amount_format = '.,'. test_parse_positive( f = 'TDECIMAL' v = '1234,12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '1 234,12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '1.234,12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '1.234' exp = '1234' ). test_parse_positive( f = 'TDECIMAL' v = '14,12' exp = '14.12' ). test_parse_positive( f = 'TDECIMAL' v = '1.234.567,12' exp = '1234567.12' ). o->mv_amount_format = ',.'. test_parse_positive( f = 'TDECIMAL' v = '1234.12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '1 234.12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '1,234.12' exp = '1234.12' ). test_parse_positive( f = 'TDECIMAL' v = '14.12' exp = '14.12' ). test_parse_positive( f = 'TDECIMAL' v = '1,234,567.12' exp = '1234567.12' ). "" Date tests ********************************** o->mv_date_format = 'MDY'. test_parse_positive( f = 'TDATE' v = '02012015' exp = '20150201' ). o->mv_date_format = 'YMD'. test_parse_positive( f = 'TDATE' v = '20150201' exp = '20150201' ). o->mv_date_format = 'YMD-'. test_parse_positive( f = 'TDATE' v = '2015-02-01' exp = '20150201' ). test_parse_positive( f = 'TDATE' v = '2015-2-1' exp = '20150201' ). test_parse_positive( f = 'TDATE' v = ` ` exp = '00000000' ). test_parse_positive( f = 'TDATE' v = '' exp = '00000000' ). o->mv_date_format = 'DMY.'. "" Back to default endmethod. method parse_field_negative. 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 ). mt_field_components = zcl_text2tab_utils=>describe_struct( i_struc = lo_struc_descr i_ignore_nonflat = abap_false ). "" Negative tests ****************************** test_parse_negative( f = 'TNUMBER' v = '20ha' err = 'PF' ). "" Negative decimal tests o->mv_amount_format = ' ,'. "" Set defaults test_parse_negative( f = 'TDECIMAL' v = '1 234.12' err = 'PF' ). test_parse_negative( f = 'TDECIMAL' v = '1 234_12' err = 'PF' ). test_parse_negative( f = 'TDECIMAL' v = '1234,123' err = 'PF' ). "" 3 decimal digits into amount which has just 2 test_parse_negative( f = 'TDECIMAL' v = '1234,12_' err = 'PF' ). test_parse_negative( f = 'TDECIMAL' v = 'Not-a-number' err = 'PF' ). o->mv_amount_format = '.,'. test_parse_negative( f = 'TDECIMAL' v = '1 234.12' err = 'PF' ). test_parse_negative( f = 'TDECIMAL' v = '1,234.12' err = 'PF' ). o->mv_amount_format = ',.'. test_parse_negative( f = 'TDECIMAL' v = '1 234,12' err = 'PF' ). test_parse_negative( f = 'TDECIMAL' v = '1.234,12' err = 'PF' ). "" Date tests ********************************** "" Negative tests o->mv_date_format = 'YMD'. test_parse_negative( f = 'TDATE' v = '2015020' err = 'DL' ). "" Too short o->mv_date_format = 'DMY.'. "" Back to default test_parse_negative( f = 'TDATE' v = '01.02.20156' err = 'DL' ). "" Too long test_parse_negative( f = 'TDATE' v = 'AB022015' err = 'DY' ). "" Wrong symbols test_parse_negative( f = 'TDATE' v = '01.02-2015' err = 'DY' ). "" Wrong separators test_parse_negative( f = 'TDATE' v = '1.2.201567' err = 'DP' ). "" Wrong part length test_parse_negative( f = 'TDATE' v = '123.2.2015' err = 'DP' ). "" Wrong part length test_parse_negative( f = 'TDATE' v = '01022015' err = 'DS' ). "" No separators test_parse_negative( f = 'TDATE' v = '01.012015' err = 'DS' ). "" No second separator test_parse_negative( f = 'TDATE' v = '40.01.2015' err = 'DU' ). "" Incorrect day test_parse_negative( f = 'TDATE' v = '01.13.2015' err = 'DU' ). "" Incorrect month "" Overflow ************************************ test_parse_negative( f = 'TCHAR' v = 'ABCDEFGH123' err = 'FS' ). test_parse_negative( f = 'TNUMBER' v = '201567' err = 'FS' ). test_parse_negative( f = 'TRAW' v = '8E8F' err = 'FS' ). test_parse_negative( f = 'TRAW' v = '8E8' err = 'FS' ). endmethod. method parse_field_special. data lx type ref to zcx_text2tab_error. data lv_meins type meins. data ls_comp like line of mt_field_components. "" CONV EXITS 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' ). try. 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 ). cl_abap_unit_assert=>fail( ). catch zcx_text2tab_error into lx. cl_abap_unit_assert=>assert_equals( act = lx->code exp = 'EF' ). endtry. endmethod. method parse_float. data lv_act type p length 6 decimals 2. o->parse_float( exporting i_value = '1,23' i_decimals = 2 importing e_field = lv_act ). cl_abap_unit_assert=>assert_equals( act = lv_act exp = '1.23' ). o->parse_float( exporting i_value = '1' i_decimals = 0 importing e_field = lv_act ). cl_abap_unit_assert=>assert_equals( act = lv_act exp = '1' ). endmethod. 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 i_corresponding = 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 i_corresponding = 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 i_corresponding = 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 ). "" 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_corresponding = abap_false 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_corresponding = abap_false 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. method map_head_structure_corresp. data: l_header type string, l_act_map type int4_table, l_exp_map type int4_table, l_ren_map type zcl_text2tab_utils=>th_field_name_map. get_dummy_data( importing e_map_corresp = l_exp_map e_dummy_header = l_header ). o = zcl_text2tab_parser=>create( c_dummy_corresponding ). o->map_head_structure( exporting i_rename_map = l_ren_map i_header = l_header i_strict = abap_false i_corresponding = abap_true importing et_map = l_act_map ). cl_abap_unit_assert=>assert_equals( act = l_act_map exp = l_exp_map ). endmethod. 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. 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. method _append_dummy. data lt_vals type string_table. data lo_table type ref to cl_abap_tabledescr. data lo_struc type ref to cl_abap_structdescr. data lr type ref to data. field-symbols like line of lo_struc->components. field-symbols like line of lt_vals. field-symbols type any. field-symbols type any. lo_table ?= cl_abap_typedescr=>describe_by_data( ct_tab ). lo_struc ?= lo_table->get_table_line_type( ). create data lr like line of ct_tab. assign lr->* to . split iv_str at '|' into table lt_vals. loop at lo_struc->components assigning . read table lt_vals index sy-tabix assigning . cl_abap_unit_assert=>assert_subrc( ). assign component -name of structure to . = condense( ). endloop. append to ct_tab. endmethod. method append_dummy. _append_dummy( exporting iv_str = iv_str changing ct_tab = mt_dummy_tmp ). endmethod. method append_dummy_s. _append_dummy( exporting iv_str = iv_str changing ct_tab = mt_dummy_str_tmp ). endmethod. method get_dummy_data. data: l_dummy_s type ty_dummy_str, l_offs type i, l_fields type i, l_string type string. field-symbols like line of e_dummy_tab. field-symbols like line of e_dummy_tab_s. 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. append -1 to e_map_corresp. append 1 to e_map_corresp. append 2 to e_map_corresp. do 7 times. append -1 to e_map_corresp. 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. append 1 to e_map_corresp. append -1 to e_map_corresp. append 3 to e_map_corresp. append -1 to e_map_corresp. append -1 to e_map_corresp. endif. replace all occurrences of '\\t' in l_string with c_tab. replace all occurrences of '\\n' in l_string with c_crlf. clear mt_dummy_tmp. "" |TDATE |TCHAR |TRAW |TSTRING |TALPHA |TDECIMAL |TNUM |TINT |TFLOAT append_dummy( '|20150101 |Trololo1 |8A |String1 |0000100000 |1234567.81 |2015 |1111 |1.12345' ). append_dummy( '|20160102 |Trololo2 |8B |String2 |0000200000 |1234567.82 |2016 |2222 |1.00' ). append_dummy( '|20160103 |Trololo3 |8C |String3 |0000300000 |1234567.83 |2015 |3333 |1.00' ). e_dummy_tab = mt_dummy_tmp. if i_strict = abap_false. loop at e_dummy_tab assigning . clear: -traw, -tinteger, -talpha, -tfloat. endloop. endif. clear mt_dummy_str_tmp. "" |TDATE |TCHAR |TRAW |TSTRING |TALPHA |TDECIMAL |TNUM |TINT |TFLOAT append_dummy_s( '|01.01.2015 |Trololo1 |8A |String1 |100000 |1234567,81 |2015 |1111 |1,12345' ). append_dummy_s( '|02.01.2016 |Trololo2 |8B |String2 |200000 |1234567,82 |2016 |2222 |1,00' ). append_dummy_s( '|03.01.2016 |Trololo3 |8C |String3 |300000 |1234567,83 |2015 |3333 |1' ). e_dummy_tab_s = mt_dummy_str_tmp. if i_strict = abap_false. loop at e_dummy_tab_s assigning . clear: -traw, -tinteger, -talpha, -tfloat. endloop. endif. 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. 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. 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_corresponding = abap_false 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_corresponding = abap_false 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 ltcl_deep_helper. create object lo_deep_provider exporting i_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. method parse_corresponding. data src_text type string. data exp_base type tt_dummy. data exp_tab type tt_dummy_corresponding. data act_tab like exp_tab. field-symbols like line of exp_base. field-symbols like line of exp_tab. get_dummy_data( importing e_dummy_tab = exp_base e_dummy_string = src_text ). loop at exp_base assigning . append initial line to exp_tab assigning . move-corresponding to . endloop. o = zcl_text2tab_parser=>create( c_dummy_corresponding ). o->parse( exporting i_data = src_text i_corresponding = abap_true i_strict = abap_false importing e_container = act_tab ). cl_abap_unit_assert=>assert_equals( act = act_tab exp = exp_tab ). endmethod. method parse_ignore_convexit. types: begin of lty_dummy, uom type msehi, end of lty_dummy. data lt_exp type table of lty_dummy. data lt_act type table of lty_dummy. data lv_src type string. lv_src = 'UOM\\nKG\\nPC'. "" => KG, ST replace all occurrences of '\\n' in lv_src with c_crlf. "" IMPORTANT !! PC -> ST may not present in all systems ! "" If this method fails, probably just comment first part of the test (without ignore) "" Part 1 - no ignore zcl_text2tab_parser=>create( lt_act )->parse( exporting i_data = lv_src importing e_container = lt_act ). clear lt_exp. append 'KG' to lt_exp. append 'ST' to lt_exp. cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). "" Part 2 - ignore CUNIT zcl_text2tab_parser=>create( lt_act )->ignore_conv_exit( 'CUNIT' )->parse( exporting i_data = lv_src importing e_container = lt_act ). clear lt_exp. append 'KG' to lt_exp. append 'PC' to lt_exp. "" No conversion cl_abap_unit_assert=>assert_equals( act = lt_act exp = lt_exp ). endmethod. endclass. ",14741,True,3122.111195891714,median """!

SAP Job (report)

CLASS /gal/job_sap DEFINITION PUBLIC INHERITING FROM /gal/job FINAL CREATE PRIVATE . *""* public components of class /GAL/JOB_SAP *""* do not include other source files here!!! PUBLIC SECTION. TYPE-POOLS abap . ""!

ABAP Program: Current Main Program

DATA program_name TYPE syrepid READ-ONLY . ""!

rsparams Table

DATA selection_table TYPE rsparams_tt READ-ONLY . ""!

System ID

DATA execution_system TYPE /gal/system_id . ""!

Create Job from Parameters

""! ""! @parameter job_name |

Job name

""! @parameter destination |

RFC Route from central system to execution target

""! @parameter execution_system |

System ID

""! @parameter program_name |

ABAP Program: Current Main Program

""! @parameter selection_table |

rsparams Table

""! @parameter job |

SAP Job (report)

""! @raising /gal/cx_js_exception |

Exception from Job Scheduler

CLASS-METHODS create_job IMPORTING !job_name TYPE btcjob DEFAULT 'BACKGROUND_JOB' !destination TYPE string OPTIONAL !execution_system TYPE /gal/system_id OPTIONAL !program_name TYPE syrepid !selection_table TYPE rsparams_tt OPTIONAL !uc4_mode TYPE /gal/uc4_mode DEFAULT space RETURNING VALUE(job) TYPE REF TO /gal/job_sap RAISING /gal/cx_js_exception . ""!

Beschreibugn für Jobtyp zurückgeben

""! ""! @parameter classname |

Classname of Job

""! @parameter description |

Description of Jobtype

CLASS-METHODS get_jobtype_descr_jobspec IMPORTING !classname TYPE classname EXPORTING !description TYPE string . ""!

Create Job from Database

""! ""! @parameter id |

Job ID

""! @parameter undelete_before_init |

Perform an Undelete before the init

""! @parameter job |

SAP Job (report)

""! @raising /gal/cx_js_exception |

Exception from Job Scheduler

CLASS-METHODS read_job_from_db_jobspec IMPORTING !id TYPE /gal/job_id !undelete_before_init TYPE abap_bool DEFAULT abap_false RETURNING VALUE(job) TYPE REF TO /gal/job_sap RAISING /gal/cx_js_exception . METHODS delete_from_db REDEFINITION . METHODS execute_async REDEFINITION . METHODS get_program_name REDEFINITION . METHODS store_to_db REDEFINITION . PROTECTED SECTION. *""* protected components of class /GAL/JOB_SAP *""* do not include other source files here!!! ""!

Init attributes from Parameters (subclass)

""! ""! @parameter execution_system |

System ID

""! @parameter program_name |

ABAP Program: Current Main Program

""! @parameter selection_table |

rsparams Table

METHODS init_attrs_create_sap IMPORTING !execution_system TYPE /gal/system_id OPTIONAL !program_name TYPE syrepid !selection_table TYPE rsparams_tt OPTIONAL . METHODS init_attrs_from_db REDEFINITION . PRIVATE SECTION. *""* private components of class /GAL/JOB_SAP *""* do not include other source files here!!! ""!

Create Job from Database

""! ""! @parameter id |

Job ID

""! @parameter undelete_before_init |

Perform an Undelete before the init

""! @parameter job |

SAP Job (report)

""! @raising /gal/cx_js_exception |

Exception from Job Scheduler

CLASS-METHODS read_job_from_db_sap IMPORTING !id TYPE /gal/job_id !undelete_before_init TYPE abap_bool DEFAULT abap_false RETURNING VALUE(job) TYPE REF TO /gal/job_sap RAISING /gal/cx_js_exception . ENDCLASS. CLASS /gal/job_sap IMPLEMENTATION. METHOD create_job. DATA l_ex TYPE REF TO /gal/cx_js_exception. IF NOT destination IS INITIAL AND execution_system IS INITIAL. RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>sap_job_dest_wo_exec_sys. ENDIF. * Create job CREATE OBJECT job. * Initialize base class job->init_attrs_create( job_name = job_name destination = destination uc4_mode = uc4_mode ). * Initialize SAP job job->init_attrs_create_sap( execution_system = execution_system program_name = program_name selection_table = selection_table ). * Store job in database job->enqueue( refresh = abap_false ). TRY. job->store_to_db( ). CATCH /gal/cx_js_exception INTO l_ex. job->dequeue( ). RAISE EXCEPTION l_ex. ENDTRY. job->dequeue( ). ENDMETHOD. METHOD delete_from_db. DATA: l_message TYPE string, l_var1 TYPE string, l_ex TYPE REF TO /gal/cx_js_exception, l_key_value TYPE string. enqueue( ). l_key_value = id. CALL FUNCTION '/GAL/JS_DB_COPY_ENTRY_TO_HIST' EXPORTING rfc_route_info = store_rfc_route_info hist_table_name = '/GAL/JD01S_HIST' table_name = '/GAL/JOBDATA01S' key_field = 'ID' key_value = l_key_value EXCEPTIONS rfc_exception = 1 cannot_create_hist_entry = 2 OTHERS = 3. IF sy-subrc <> 0. /gal/trace=>write_error( ). ENDIF. CALL FUNCTION '/GAL/JS_DB_DELETE' EXPORTING rfc_route_info = store_rfc_route_info table_name = '/GAL/JOBDATA01S' id = id EXCEPTIONS rfc_exception = 1 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 INTO l_message. dequeue( ). l_var1 = id. RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>cannot_delete_job_from_db var1 = l_var1 var2 = '/GAL/JOBDATA01S' var3 = l_message. ENDIF. TRY. CALL METHOD super->delete_from_db EXPORTING force = force. CATCH /gal/cx_js_exception INTO l_ex. dequeue( ). RAISE EXCEPTION l_ex. ENDTRY. dequeue( ). ENDMETHOD. METHOD execute_async. DATA l_ex TYPE REF TO /gal/cx_js_exception. DATA l_var1 TYPE string. DATA l_list_object TYPE STANDARD TABLE OF abaplist. DATA l_progname TYPE progname. enqueue( ). TRY. super->execute_async( ). SELECT SINGLE name INTO l_progname FROM trdir WHERE name = program_name. ""#EC CI_SUBRC IF l_progname IS INITIAL. l_var1 = program_name. RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>programm_does_not_exist var1 = l_var1. ENDIF. * Execute report and save list SUBMIT (program_name) WITH SELECTION-TABLE selection_table EXPORTING LIST TO MEMORY AND RETURN. ""#EC CI_SUBMIT * Write list to spool (if any) CALL FUNCTION 'LIST_FROM_MEMORY' TABLES listobject = l_list_object EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. CALL FUNCTION 'WRITE_LIST' TABLES listobject = l_list_object EXCEPTIONS OTHERS = 0. ENDIF. * Perform post processing post_process( ). /gal/job=>run_job_scheduler( ). CATCH /gal/cx_js_exception INTO l_ex. dequeue( ). RAISE EXCEPTION l_ex. ENDTRY. dequeue( ). ENDMETHOD. METHOD get_jobtype_descr_jobspec. description = TEXT-000. ENDMETHOD. METHOD get_program_name. program_name = me->program_name. ENDMETHOD. METHOD init_attrs_create_sap. me->execution_system = execution_system. me->program_name = program_name. me->selection_table = selection_table. classname = '/GAL/JOB_SAP'. ENDMETHOD. METHOD init_attrs_from_db. DATA: l_table_line TYPE /gal/db_datas, l_table_line_elem TYPE /gal/db_data, l_message TYPE string, l_var1 TYPE string, l_xml_ex TYPE REF TO cx_transformation_error, l_key_value TYPE string. super->init_attrs_from_db( undelete_before_init = undelete_before_init id = id ). classname = '/GAL/JOB_SAP'. IF undelete_before_init = abap_true. l_key_value = id. CALL FUNCTION '/GAL/JS_DB_MOVE_HIST_E_TO_DB' EXPORTING rfc_route_info = store_rfc_route_info hist_table_name = '/GAL/JD01S_HIST' table_name = '/GAL/JOBDATA01S' key_field = 'ID' key_value = l_key_value EXCEPTIONS rfc_exception = 1 cannot_create_entry = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO l_message. l_var1 = id. RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>cannot_undelete_job var1 = l_var1 var2 = l_message. ENDIF. ENDIF. IF read_from_hist = abap_false. CALL FUNCTION '/GAL/JS_DB_SELECT_SINGLE' EXPORTING rfc_route_info = store_rfc_route_info table_name = '/GAL/JOBDATA01S' id = id IMPORTING table_line = l_table_line EXCEPTIONS no_data_found = 1 OTHERS = 2. ELSE. CALL FUNCTION '/GAL/JS_DB_SELECT_SINGLE' EXPORTING rfc_route_info = store_rfc_route_info table_name = '/GAL/JD01S_HIST' id = id IMPORTING table_line = l_table_line EXCEPTIONS no_data_found = 1 OTHERS = 2. ENDIF. IF sy-subrc = 1. RAISE EXCEPTION TYPE /gal/cx_js_no_job_data_found EXPORTING textid = /gal/cx_js_no_job_data_found=>/gal/cx_js_no_job_data_found var1 = l_var1 var2 = '/GAL/JOBDATA01S'. ELSEIF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO l_message. l_var1 = id. RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>cannot_read_job_from_db var1 = l_var1 var2 = '/GAL/JOBDATA01S' var3 = l_message. ENDIF. IF l_table_line IS INITIAL. l_var1 = id. RAISE EXCEPTION TYPE /gal/cx_js_no_job_data_found EXPORTING textid = /gal/cx_js_no_job_data_found=>/gal/cx_js_no_job_data_found var1 = l_var1. ENDIF. CLEAR l_table_line_elem. READ TABLE l_table_line WITH KEY attribute = 'PROGRAM_NAME' INTO l_table_line_elem. IF sy-subrc = 0. program_name = l_table_line_elem-value. ENDIF. READ TABLE l_table_line WITH KEY attribute = 'EXECUTION_SYSTEM' INTO l_table_line_elem. IF sy-subrc = 0. execution_system = l_table_line_elem-value. ENDIF. TRY. CLEAR l_table_line_elem. READ TABLE l_table_line WITH KEY attribute = 'SEL_TABLE_SER' INTO l_table_line_elem. IF sy-subrc = 0. CALL TRANSFORMATION id OPTIONS value_handling = 'default' SOURCE XML l_table_line_elem-value RESULT selection_table = selection_table. ""#EC NOTEXT ENDIF. CATCH cx_transformation_error INTO l_xml_ex. CALL METHOD l_xml_ex->if_message~get_text RECEIVING result = l_var1. RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>error_deserializing_xml var1 = l_var1. ENDTRY. ENDMETHOD. METHOD read_job_from_db_jobspec. read_job_from_db_sap( EXPORTING id = id undelete_before_init = undelete_before_init RECEIVING job = job ). ENDMETHOD. METHOD read_job_from_db_sap. CREATE OBJECT job. job->init_attrs_from_db( undelete_before_init = undelete_before_init id = id ). ENDMETHOD. METHOD store_to_db. DATA l_var1 TYPE string. DATA lt_table_line TYPE /gal/db_datas. DATA l_table_line_elem TYPE /gal/db_data. DATA l_message TYPE string. DATA l_xml_ex TYPE REF TO cx_transformation_error. l_table_line_elem-attribute = 'ID'. l_table_line_elem-value = id. INSERT l_table_line_elem INTO TABLE lt_table_line. l_table_line_elem-attribute = 'EXECUTION_SYSTEM'. l_table_line_elem-value = execution_system. INSERT l_table_line_elem INTO TABLE lt_table_line. l_table_line_elem-attribute = 'PROGRAM_NAME'. l_table_line_elem-value = program_name. INSERT l_table_line_elem INTO TABLE lt_table_line. TRY. l_table_line_elem-attribute = 'SEL_TABLE_SER'. CALL TRANSFORMATION id OPTIONS data_refs = 'heap-or-create' initial_components = 'include' technical_types = 'error' value_handling = 'default' xml_header = 'full' SOURCE selection_table = selection_table RESULT XML l_table_line_elem-value. ""#EC NOTEXT INSERT l_table_line_elem INTO TABLE lt_table_line. CATCH cx_transformation_error INTO l_xml_ex. l_var1 = l_xml_ex->if_message~get_text( ). RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>error_creating_xml var1 = l_var1. ENDTRY. CALL FUNCTION '/GAL/JS_DB_WRITE' EXPORTING rfc_route_info = store_rfc_route_info table_name = '/GAL/JOBDATA01S' table_line = lt_table_line EXCEPTIONS rfc_exception = 1 wrong_content_data = 2 cannot_write_to_db = 3 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 INTO l_message. l_var1 = id. RAISE EXCEPTION TYPE /gal/cx_js_exception EXPORTING textid = /gal/cx_js_exception=>cannot_create_job_in_db var1 = l_var1 var2 = '/GAL/JOBDATA01S' var3 = l_message. ENDIF. super->store_to_db( ). ENDMETHOD. ENDCLASS. ",4154,False,758.2403234543606,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 left to right * in multiple rows. Constrained to the suggested width, the tiled rows * layout will change in height as the number of items increases or * decreases. * * @see http://wiki.starling-framework.org/feathers/tiled-rows-layout */ public class TiledRowsLayout 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 rows without gaps. * * @see #paging */ public static const PAGING_NONE:String = ""none""; /** * Constructor. */ public function TiledRowsLayout() { } /** * @private */ protected var _discoveredItemsCache:Vector. = new []; /** * Quickly sets both horizontalGap and verticalGap * to the same value. The gap getter always returns the * value of horizontalGap, but the value of * verticalGap may be different. * * @default 0 * * @see #horizontalGap * @see #verticalGap */ public function get gap():Number { return this._horizontalGap; } /** * @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 _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 _requestedRowCount:int = 0; /** * Requests that the layout uses a specific number of rows, 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 _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 TiledRowsLayout.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 TiledRowsLayout.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 TiledRowsLayout.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 TiledRowsLayout.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 height of the rows is larger than the height * of the view port, the layout will be split into pages where each * page is filled with the maximum number of rows that may be displayed * without cutting off any items. * * @default TiledRowsLayout.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; this.dispatchEventWith(Event.CHANGE); } /** * @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 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 { //put everything in one row horizontalTileCount = itemCount; } 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 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 { //using the horizontal tile count, calculate how many rows will //be required for the total number of items. verticalTileCount = Math.ceil(itemCount / horizontalTileCount); } 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 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 pageStartX:Number = startX; 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 && itemIndex % horizontalTileCount == 0) { positionX = pageStartX; positionY += tileHeight + this._verticalGap; } 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 = pageStartX = startX + availableWidth * pageIndex; positionY = startY; } else if(this._paging == PAGING_VERTICAL) { positionY = 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++; } } positionX += tileWidth + this._horizontalGap; 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 ? (discoveredItems.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 = totalPageWidth; if(availableWidth === availableWidth && //!isNaN this._paging == PAGING_HORIZONTAL) { totalWidth = Math.ceil(itemCount / perPage) * availableWidth; } var totalHeight:Number = positionY + tileHeight + this._paddingBottom; if(availableHeight === availableHeight) //!isNaN { if(this._paging == PAGING_HORIZONTAL) { totalHeight = availableHeight; } else if(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; 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 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 = itemCount; } 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 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 = Math.ceil(itemCount / horizontalTileCount); } 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 totalPageWidth:Number = horizontalTileCount * (tileWidth + this._horizontalGap) - this._horizontalGap + this._paddingLeft + this._paddingRight; 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 pageStartX:Number = startX; var positionX:Number = startX; var positionY:Number = startY; for(var i:int = 0; i < itemCount; i++) { if(i != 0 && i % horizontalTileCount == 0) { positionX = pageStartX; positionY += tileHeight + this._verticalGap; } 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 = pageStartX = startX + availableWidth * pageIndex; positionY = startY; } else if(this._paging == PAGING_VERTICAL) { positionY = startY + availableHeight * pageIndex; } } } var totalWidth:Number = totalPageWidth; if(availableWidth === availableWidth && //!isNaN this._paging == PAGING_HORIZONTAL) { totalWidth = Math.ceil(itemCount / perPage) * availableWidth; } var totalHeight:Number = positionY + tileHeight + this._paddingBottom; if(availableHeight === availableHeight) //!isNaN { if(this._paging == PAGING_HORIZONTAL) { totalHeight = availableHeight; } else if(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; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } 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 += -perPage + horizontalTileCount + columnOffset; } else if(partialPageSize > 0) { partialPageSize = partialPageSize - this._paddingLeft - leftSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } columnOffset = Math.floor(partialPageSize / (tileWidth + this._horizontalGap)); minimum += columnOffset; } if(minimum < 0) { minimum = 0; columnOffset = 0; } if(minimum + minimumItemCount >= itemCount) { var resultPushIndex:int = result.length; //an optimized path when we're on or near the last page minimum = itemCount - minimumItemCount; for(var i:int = minimum; i < itemCount; i++) { result[resultPushIndex] = i; resultPushIndex++; } } else { var rowIndex:int = 0; var columnIndex:int = (horizontalTileCount + columnOffset) % horizontalTileCount; var pageStart:int = int(minimum / perPage) * perPage; i = minimum; var resultLength:int = 0; do { if(i < itemCount) { result[resultLength] = i; resultLength++; } rowIndex++; if(rowIndex == verticalTileCount) { rowIndex = 0; columnIndex++; if(columnIndex == horizontalTileCount) { columnIndex = 0; pageStart += perPage; } i = pageStart + columnIndex - horizontalTileCount; } i += horizontalTileCount; } while(resultLength < minimumItemCount && pageStart < itemCount) } } /** * @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; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 1; } var perPage:int = horizontalTileCount * verticalTileCount; var minimumItemCount:int = perPage + 2 * horizontalTileCount; 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._verticalAlign == VERTICAL_ALIGN_MIDDLE) { topSideOffset = bottomSideOffset = Math.round((height - this._paddingTop - this._paddingBottom - totalColumnHeight) / 2); } else if(this._verticalAlign == 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 / (tileHeight + this._verticalGap)) - 1; minimum += horizontalTileCount * rowOffset; } else if(partialPageSize > 0) { partialPageSize = partialPageSize - this._paddingTop - topSideOffset; if(partialPageSize < 0) { partialPageSize = 0; } rowOffset = Math.floor(partialPageSize / (tileHeight + this._verticalGap)); minimum += horizontalTileCount * rowOffset; } if(minimum < 0) { minimum = 0; rowOffset = 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 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 horizontalTileCount:int = (width - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); if(horizontalTileCount < 1) { horizontalTileCount = 1; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } var verticalTileCount:int = Math.ceil((height + this._verticalGap) / (tileHeight + this._verticalGap)) + 1; var minimumItemCount:int = verticalTileCount * horizontalTileCount; if(minimumItemCount > itemCount) { minimumItemCount = itemCount; } var rowIndexOffset:int = 0; var totalRowHeight:Number = Math.ceil(itemCount / horizontalTileCount) * (tileHeight + this._verticalGap) - this._verticalGap; if(totalRowHeight < height) { if(this._verticalAlign == VERTICAL_ALIGN_BOTTOM) { rowIndexOffset = Math.ceil((height - totalRowHeight) / (tileHeight + this._verticalGap)); } else if(this._verticalAlign == VERTICAL_ALIGN_MIDDLE) { rowIndexOffset = Math.ceil((height - totalRowHeight) / (tileHeight + this._verticalGap) / 2); } } var rowIndex:int = -rowIndexOffset + Math.floor((scrollY - this._paddingTop + this._verticalGap) / (tileHeight + this._verticalGap)); var minimum:int = rowIndex * horizontalTileCount; 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(); } } /** * @inheritDoc */ public 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 horizontalTileCount:int = (width - this._paddingLeft - this._paddingRight + this._horizontalGap) / (tileWidth + this._horizontalGap); if(horizontalTileCount < 1) { horizontalTileCount = 1; } else if(this._requestedColumnCount > 0 && horizontalTileCount > this._requestedColumnCount) { horizontalTileCount = this._requestedColumnCount; } if(this._paging != PAGING_NONE) { var verticalTileCount:int = (height - this._paddingTop - this._paddingBottom + this._verticalGap) / (tileHeight + this._verticalGap); if(verticalTileCount < 1) { verticalTileCount = 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 resultY:Number = this._paddingTop + ((tileHeight + this._verticalGap) * int(index / horizontalTileCount)); if(nearest) { var bottomPosition:Number = resultY - (height - tileHeight); if(scrollY >= bottomPosition && scrollY <= resultY) { //keep the current scroll position because the item is already //fully visible resultY = scrollY; } else { var topDifference:Number = Math.abs(resultY - scrollY); var bottomDifference:Number = Math.abs(bottomPosition - scrollY); if(bottomDifference < topDifference) { resultY = bottomPosition; } } } else { resultY -= Math.round((height - tileHeight) / 2); } result.x = 0; result.y = resultY; } return result; } } } ",16185,True,2954.5679553160776,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 . 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 !io_html TYPE REF TO zcl_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(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(ri_html) TYPE REF TO zif_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(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(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 ). 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 ro_html. ro_html->add( |
| ). ro_html->add( render_diff_head( is_diff ) ). "" Content IF is_diff-type <> 'binary'. ro_html->add( '
' ). ro_html->add( || ). ro_html->add( render_table_head( is_diff ) ). ro_html->add( render_lines( is_diff ) ). ro_html->add( '
' ). ELSE. ro_html->add( '
' ). ro_html->add( 'The content seems to be binary.' ). ro_html->add( 'Cannot display as diff.' ). ENDIF. ro_html->add( '
' ). ro_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 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 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 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( '' ). ro_html->add( |-old_num }"">| && || && |-| && |{ -old }| ). ro_html->add( '' ). ENDLOOP. LOOP AT mt_delayed_lines ASSIGNING . ro_html->add( '' ). ro_html->add( || && |-new_num }"">| && |+| && |{ -new }| ). ro_html->add( '' ). ENDLOOP. CLEAR mt_delayed_lines. ENDIF. ro_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. 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( '' ). 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( '' ). io_html->add( '' ). io_html->add( 'LOCAL' ). io_html->add( '' ). io_html->add( '' ). io_html->add( 'REMOTE' ). ENDMETHOD. METHOD render_table_head_unified. io_html->add( 'old' ). io_html->add( 'new' ). io_html->add( '' ). io_html->add( 'code' ). 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. ENDCLASS. ",8072,False,1499.0189027947429,median "CLASS zcl_excel_style_changer DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_excel_style_changer. CLASS-METHODS create IMPORTING excel TYPE REF TO zcl_excel RETURNING VALUE(result) TYPE REF TO zif_excel_style_changer RAISING zcx_excel. PROTECTED SECTION. PRIVATE SECTION. METHODS clear_initial_colorxfields IMPORTING is_color TYPE zexcel_s_style_color CHANGING cs_xcolor TYPE zexcel_s_cstylex_color. METHODS move_supplied_borders IMPORTING iv_border_supplied TYPE abap_bool is_border TYPE zexcel_s_cstyle_border iv_xborder_supplied TYPE abap_bool is_xborder TYPE zexcel_s_cstylex_border CHANGING cs_complete_style_border TYPE zexcel_s_cstyle_border cs_complete_stylex_border TYPE zexcel_s_cstylex_border. DATA: excel TYPE REF TO zcl_excel, lv_xborder_supplied TYPE abap_bool, single_change_requested TYPE zexcel_s_cstylex_complete, BEGIN OF multiple_change_requested, complete TYPE abap_bool, font TYPE abap_bool, fill TYPE abap_bool, BEGIN OF borders, complete TYPE abap_bool, allborders TYPE abap_bool, diagonal TYPE abap_bool, down TYPE abap_bool, left TYPE abap_bool, right TYPE abap_bool, top TYPE abap_bool, END OF borders, alignment TYPE abap_bool, protection TYPE abap_bool, END OF multiple_change_requested. CONSTANTS: lv_border_supplied TYPE abap_bool VALUE abap_true. ALIASES: complete_style FOR zif_excel_style_changer~complete_style, complete_stylex FOR zif_excel_style_changer~complete_stylex. ENDCLASS. CLASS ZCL_EXCEL_STYLE_CHANGER IMPLEMENTATION. METHOD clear_initial_colorxfields. IF is_color-rgb IS INITIAL. CLEAR cs_xcolor-rgb. ENDIF. IF is_color-indexed IS INITIAL. CLEAR cs_xcolor-indexed. ENDIF. IF is_color-theme IS INITIAL. CLEAR cs_xcolor-theme. ENDIF. IF is_color-tint IS INITIAL. CLEAR cs_xcolor-tint. ENDIF. ENDMETHOD. METHOD create. DATA: style TYPE REF TO zcl_excel_style_changer. CREATE OBJECT style. style->excel = excel. result = style. ENDMETHOD. METHOD move_supplied_borders. DATA: cs_borderx TYPE zexcel_s_cstylex_border. IF iv_border_supplied = abap_true. "" only act if parameter was supplied IF iv_xborder_supplied = abap_true. "" cs_borderx = is_xborder. "" use supplied x-parameter ELSE. CLEAR cs_borderx WITH 'X'. "" <============================== DDIC structure enh. category to set? "" clear in a way that would be expected to work easily IF is_border-border_style IS INITIAL. CLEAR cs_borderx-border_style. ENDIF. clear_initial_colorxfields( EXPORTING is_color = is_border-border_color CHANGING cs_xcolor = cs_borderx-border_color ). ENDIF. cs_complete_style_border = is_border. cs_complete_stylex_border = cs_borderx. ENDIF. ENDMETHOD. METHOD zif_excel_style_changer~apply. DATA: stylemapping TYPE zexcel_s_stylemapping, lo_worksheet TYPE REF TO zcl_excel_worksheet, l_guid TYPE zexcel_cell_style. lo_worksheet = excel->get_worksheet_by_name( ip_sheet_name = ip_worksheet->get_title( ) ). IF lo_worksheet <> ip_worksheet. zcx_excel=>raise_text( 'Worksheet doesn''t correspond to workbook of style changer'(001) ). ENDIF. TRY. ip_worksheet->get_cell( EXPORTING ip_column = ip_column ip_row = ip_row IMPORTING ep_guid = l_guid ). stylemapping = excel->get_style_to_guid( l_guid ). CATCH zcx_excel. * Error --> use submitted style ENDTRY. IF multiple_change_requested-complete = abap_true. stylemapping-complete_style = complete_style. stylemapping-complete_stylex = complete_stylex. ENDIF. IF multiple_change_requested-font = abap_true. stylemapping-complete_style-font = complete_style-font. stylemapping-complete_stylex-font = complete_stylex-font. ENDIF. IF multiple_change_requested-fill = abap_true. stylemapping-complete_style-fill = complete_style-fill. stylemapping-complete_stylex-fill = complete_stylex-fill. ENDIF. IF multiple_change_requested-borders-complete = abap_true. stylemapping-complete_style-borders = complete_style-borders. stylemapping-complete_stylex-borders = complete_stylex-borders. ENDIF. IF multiple_change_requested-borders-allborders = abap_true. stylemapping-complete_style-borders-allborders = complete_style-borders-allborders. stylemapping-complete_stylex-borders-allborders = complete_stylex-borders-allborders. ENDIF. IF multiple_change_requested-borders-diagonal = abap_true. stylemapping-complete_style-borders-diagonal = complete_style-borders-diagonal. stylemapping-complete_stylex-borders-diagonal = complete_stylex-borders-diagonal. ENDIF. IF multiple_change_requested-borders-down = abap_true. stylemapping-complete_style-borders-down = complete_style-borders-down. stylemapping-complete_stylex-borders-down = complete_stylex-borders-down. ENDIF. IF multiple_change_requested-borders-left = abap_true. stylemapping-complete_style-borders-left = complete_style-borders-left. stylemapping-complete_stylex-borders-left = complete_stylex-borders-left. ENDIF. IF multiple_change_requested-borders-right = abap_true. stylemapping-complete_style-borders-right = complete_style-borders-right. stylemapping-complete_stylex-borders-right = complete_stylex-borders-right. ENDIF. IF multiple_change_requested-borders-top = abap_true. stylemapping-complete_style-borders-top = complete_style-borders-top. stylemapping-complete_stylex-borders-top = complete_stylex-borders-top. ENDIF. IF multiple_change_requested-alignment = abap_true. stylemapping-complete_style-alignment = complete_style-alignment. stylemapping-complete_stylex-alignment = complete_stylex-alignment. ENDIF. IF multiple_change_requested-protection = abap_true. stylemapping-complete_style-protection = complete_style-protection. stylemapping-complete_stylex-protection = complete_stylex-protection. ENDIF. IF complete_stylex-number_format = abap_true. stylemapping-complete_style-number_format-format_code = complete_style-number_format-format_code. stylemapping-complete_stylex-number_format-format_code = abap_true. ENDIF. IF complete_stylex-font-bold = abap_true. stylemapping-complete_style-font-bold = complete_style-font-bold. stylemapping-complete_stylex-font-bold = complete_stylex-font-bold. ENDIF. IF complete_stylex-font-color = abap_true. stylemapping-complete_style-font-color = complete_style-font-color. stylemapping-complete_stylex-font-color = complete_stylex-font-color. ENDIF. IF complete_stylex-font-color-rgb = abap_true. stylemapping-complete_style-font-color-rgb = complete_style-font-color-rgb. stylemapping-complete_stylex-font-color-rgb = complete_stylex-font-color-rgb. ENDIF. IF complete_stylex-font-color-indexed = abap_true. stylemapping-complete_style-font-color-indexed = complete_style-font-color-indexed. stylemapping-complete_stylex-font-color-indexed = complete_stylex-font-color-indexed. ENDIF. IF complete_stylex-font-color-theme = abap_true. stylemapping-complete_style-font-color-theme = complete_style-font-color-theme. stylemapping-complete_stylex-font-color-theme = complete_stylex-font-color-theme. ENDIF. IF complete_stylex-font-color-tint = abap_true. stylemapping-complete_style-font-color-tint = complete_style-font-color-tint. stylemapping-complete_stylex-font-color-tint = complete_stylex-font-color-tint. ENDIF. IF complete_stylex-font-family = abap_true. stylemapping-complete_style-font-family = complete_style-font-family. stylemapping-complete_stylex-font-family = complete_stylex-font-family. ENDIF. IF complete_stylex-font-italic = abap_true. stylemapping-complete_style-font-italic = complete_style-font-italic. stylemapping-complete_stylex-font-italic = complete_stylex-font-italic. ENDIF. IF complete_stylex-font-name = abap_true. stylemapping-complete_style-font-name = complete_style-font-name. stylemapping-complete_stylex-font-name = complete_stylex-font-name. ENDIF. IF complete_stylex-font-scheme = abap_true. stylemapping-complete_style-font-scheme = complete_style-font-scheme. stylemapping-complete_stylex-font-scheme = complete_stylex-font-scheme. ENDIF. IF complete_stylex-font-size = abap_true. stylemapping-complete_style-font-size = complete_style-font-size. stylemapping-complete_stylex-font-size = complete_stylex-font-size. ENDIF. IF complete_stylex-font-strikethrough = abap_true. stylemapping-complete_style-font-strikethrough = complete_style-font-strikethrough. stylemapping-complete_stylex-font-strikethrough = complete_stylex-font-strikethrough. ENDIF. IF complete_stylex-font-underline = abap_true. stylemapping-complete_style-font-underline = complete_style-font-underline. stylemapping-complete_stylex-font-underline = complete_stylex-font-underline. ENDIF. IF complete_stylex-font-underline_mode = abap_true. stylemapping-complete_style-font-underline_mode = complete_style-font-underline_mode. stylemapping-complete_stylex-font-underline_mode = complete_stylex-font-underline_mode. ENDIF. IF complete_stylex-fill-filltype = abap_true. stylemapping-complete_style-fill-filltype = complete_style-fill-filltype. stylemapping-complete_stylex-fill-filltype = complete_stylex-fill-filltype. ENDIF. IF complete_stylex-fill-rotation = abap_true. stylemapping-complete_style-fill-rotation = complete_style-fill-rotation. stylemapping-complete_stylex-fill-rotation = complete_stylex-fill-rotation. ENDIF. IF complete_stylex-fill-fgcolor = abap_true. stylemapping-complete_style-fill-fgcolor = complete_style-fill-fgcolor. stylemapping-complete_stylex-fill-fgcolor = complete_stylex-fill-fgcolor. ENDIF. IF complete_stylex-fill-fgcolor-rgb = abap_true. stylemapping-complete_style-fill-fgcolor-rgb = complete_style-fill-fgcolor-rgb. stylemapping-complete_stylex-fill-fgcolor-rgb = complete_stylex-fill-fgcolor-rgb. ENDIF. IF complete_stylex-fill-fgcolor-indexed = abap_true. stylemapping-complete_style-fill-fgcolor-indexed = complete_style-fill-fgcolor-indexed. stylemapping-complete_stylex-fill-fgcolor-indexed = complete_stylex-fill-fgcolor-indexed. ENDIF. IF complete_stylex-fill-fgcolor-theme = abap_true. stylemapping-complete_style-fill-fgcolor-theme = complete_style-fill-fgcolor-theme. stylemapping-complete_stylex-fill-fgcolor-theme = complete_stylex-fill-fgcolor-theme. ENDIF. IF complete_stylex-fill-fgcolor-tint = abap_true. stylemapping-complete_style-fill-fgcolor-tint = complete_style-fill-fgcolor-tint. stylemapping-complete_stylex-fill-fgcolor-tint = complete_stylex-fill-fgcolor-tint. ENDIF. IF complete_stylex-fill-bgcolor = abap_true. stylemapping-complete_style-fill-bgcolor = complete_style-fill-bgcolor. stylemapping-complete_stylex-fill-bgcolor = complete_stylex-fill-bgcolor. ENDIF. IF complete_stylex-fill-bgcolor-rgb = abap_true. stylemapping-complete_style-fill-bgcolor-rgb = complete_style-fill-bgcolor-rgb. stylemapping-complete_stylex-fill-bgcolor-rgb = complete_stylex-fill-bgcolor-rgb. ENDIF. IF complete_stylex-fill-bgcolor-indexed = abap_true. stylemapping-complete_style-fill-bgcolor-indexed = complete_style-fill-bgcolor-indexed. stylemapping-complete_stylex-fill-bgcolor-indexed = complete_stylex-fill-bgcolor-indexed. ENDIF. IF complete_stylex-fill-bgcolor-theme = abap_true. stylemapping-complete_style-fill-bgcolor-theme = complete_style-fill-bgcolor-theme. stylemapping-complete_stylex-fill-bgcolor-theme = complete_stylex-fill-bgcolor-theme. ENDIF. IF complete_stylex-fill-bgcolor-tint = abap_true. stylemapping-complete_style-fill-bgcolor-tint = complete_style-fill-bgcolor-tint. stylemapping-complete_stylex-fill-bgcolor-tint = complete_stylex-fill-bgcolor-tint. ENDIF. IF complete_stylex-fill-gradtype-type = abap_true. stylemapping-complete_style-fill-gradtype-type = complete_style-fill-gradtype-type. stylemapping-complete_stylex-fill-gradtype-type = complete_stylex-fill-gradtype-type. ENDIF. IF complete_stylex-fill-gradtype-degree = abap_true. stylemapping-complete_style-fill-gradtype-degree = complete_style-fill-gradtype-degree. stylemapping-complete_stylex-fill-gradtype-degree = complete_stylex-fill-gradtype-degree. ENDIF. IF complete_stylex-fill-gradtype-bottom = abap_true. stylemapping-complete_style-fill-gradtype-bottom = complete_style-fill-gradtype-bottom. stylemapping-complete_stylex-fill-gradtype-bottom = complete_stylex-fill-gradtype-bottom. ENDIF. IF complete_stylex-fill-gradtype-left = abap_true. stylemapping-complete_style-fill-gradtype-left = complete_style-fill-gradtype-left. stylemapping-complete_stylex-fill-gradtype-left = complete_stylex-fill-gradtype-left. ENDIF. IF complete_stylex-fill-gradtype-top = abap_true. stylemapping-complete_style-fill-gradtype-top = complete_style-fill-gradtype-top. stylemapping-complete_stylex-fill-gradtype-top = complete_stylex-fill-gradtype-top. ENDIF. IF complete_stylex-fill-gradtype-right = abap_true. stylemapping-complete_style-fill-gradtype-right = complete_style-fill-gradtype-right. stylemapping-complete_stylex-fill-gradtype-right = complete_stylex-fill-gradtype-right. ENDIF. IF complete_stylex-fill-gradtype-position1 = abap_true. stylemapping-complete_style-fill-gradtype-position1 = complete_style-fill-gradtype-position1. stylemapping-complete_stylex-fill-gradtype-position1 = complete_stylex-fill-gradtype-position1. ENDIF. IF complete_stylex-fill-gradtype-position2 = abap_true. stylemapping-complete_style-fill-gradtype-position2 = complete_style-fill-gradtype-position2. stylemapping-complete_stylex-fill-gradtype-position2 = complete_stylex-fill-gradtype-position2. ENDIF. IF complete_stylex-fill-gradtype-position3 = abap_true. stylemapping-complete_style-fill-gradtype-position3 = complete_style-fill-gradtype-position3. stylemapping-complete_stylex-fill-gradtype-position3 = complete_stylex-fill-gradtype-position3. ENDIF. IF complete_stylex-borders-diagonal_mode = abap_true. stylemapping-complete_style-borders-diagonal_mode = complete_style-borders-diagonal_mode. stylemapping-complete_stylex-borders-diagonal_mode = complete_stylex-borders-diagonal_mode. ENDIF. IF complete_stylex-alignment-horizontal = abap_true. stylemapping-complete_style-alignment-horizontal = complete_style-alignment-horizontal. stylemapping-complete_stylex-alignment-horizontal = complete_stylex-alignment-horizontal. ENDIF. IF complete_stylex-alignment-vertical = abap_true. stylemapping-complete_style-alignment-vertical = complete_style-alignment-vertical. stylemapping-complete_stylex-alignment-vertical = complete_stylex-alignment-vertical. ENDIF. IF complete_stylex-alignment-textrotation = abap_true. stylemapping-complete_style-alignment-textrotation = complete_style-alignment-textrotation. stylemapping-complete_stylex-alignment-textrotation = complete_stylex-alignment-textrotation. ENDIF. IF complete_stylex-alignment-wraptext = abap_true. stylemapping-complete_style-alignment-wraptext = complete_style-alignment-wraptext. stylemapping-complete_stylex-alignment-wraptext = complete_stylex-alignment-wraptext. ENDIF. IF complete_stylex-alignment-shrinktofit = abap_true. stylemapping-complete_style-alignment-shrinktofit = complete_style-alignment-shrinktofit. stylemapping-complete_stylex-alignment-shrinktofit = complete_stylex-alignment-shrinktofit. ENDIF. IF complete_stylex-alignment-indent = abap_true. stylemapping-complete_style-alignment-indent = complete_style-alignment-indent. stylemapping-complete_stylex-alignment-indent = complete_stylex-alignment-indent. ENDIF. IF complete_stylex-protection-hidden = abap_true. stylemapping-complete_style-protection-hidden = complete_style-protection-hidden. stylemapping-complete_stylex-protection-hidden = complete_stylex-protection-hidden. ENDIF. IF complete_stylex-protection-locked = abap_true. stylemapping-complete_style-protection-locked = complete_style-protection-locked. stylemapping-complete_stylex-protection-locked = complete_stylex-protection-locked. ENDIF. IF complete_stylex-borders-allborders-border_style = abap_true. stylemapping-complete_style-borders-allborders-border_style = complete_style-borders-allborders-border_style. stylemapping-complete_stylex-borders-allborders-border_style = complete_stylex-borders-allborders-border_style. ENDIF. IF complete_stylex-borders-allborders-border_color-rgb = abap_true. stylemapping-complete_style-borders-allborders-border_color-rgb = complete_style-borders-allborders-border_color-rgb. stylemapping-complete_stylex-borders-allborders-border_color-rgb = complete_stylex-borders-allborders-border_color-rgb. ENDIF. IF complete_stylex-borders-allborders-border_color-indexed = abap_true. stylemapping-complete_style-borders-allborders-border_color-indexed = complete_style-borders-allborders-border_color-indexed. stylemapping-complete_stylex-borders-allborders-border_color-indexed = complete_stylex-borders-allborders-border_color-indexed. ENDIF. IF complete_stylex-borders-allborders-border_color-theme = abap_true. stylemapping-complete_style-borders-allborders-border_color-theme = complete_style-borders-allborders-border_color-theme. stylemapping-complete_stylex-borders-allborders-border_color-theme = complete_stylex-borders-allborders-border_color-theme. ENDIF. IF complete_stylex-borders-allborders-border_color-tint = abap_true. stylemapping-complete_style-borders-allborders-border_color-tint = complete_style-borders-allborders-border_color-tint. stylemapping-complete_stylex-borders-allborders-border_color-tint = complete_stylex-borders-allborders-border_color-tint. ENDIF. IF complete_stylex-borders-diagonal-border_style = abap_true. stylemapping-complete_style-borders-diagonal-border_style = complete_style-borders-diagonal-border_style. stylemapping-complete_stylex-borders-diagonal-border_style = complete_stylex-borders-diagonal-border_style. ENDIF. IF complete_stylex-borders-diagonal-border_color-rgb = abap_true. stylemapping-complete_style-borders-diagonal-border_color-rgb = complete_style-borders-diagonal-border_color-rgb. stylemapping-complete_stylex-borders-diagonal-border_color-rgb = complete_stylex-borders-diagonal-border_color-rgb. ENDIF. IF complete_stylex-borders-diagonal-border_color-indexed = abap_true. stylemapping-complete_style-borders-diagonal-border_color-indexed = complete_style-borders-diagonal-border_color-indexed. stylemapping-complete_stylex-borders-diagonal-border_color-indexed = complete_stylex-borders-diagonal-border_color-indexed. ENDIF. IF complete_stylex-borders-diagonal-border_color-theme = abap_true. stylemapping-complete_style-borders-diagonal-border_color-theme = complete_style-borders-diagonal-border_color-theme. stylemapping-complete_stylex-borders-diagonal-border_color-theme = complete_stylex-borders-diagonal-border_color-theme. ENDIF. IF complete_stylex-borders-diagonal-border_color-tint = abap_true. stylemapping-complete_style-borders-diagonal-border_color-tint = complete_style-borders-diagonal-border_color-tint. stylemapping-complete_stylex-borders-diagonal-border_color-tint = complete_stylex-borders-diagonal-border_color-tint. ENDIF. IF complete_stylex-borders-down-border_style = abap_true. stylemapping-complete_style-borders-down-border_style = complete_style-borders-down-border_style. stylemapping-complete_stylex-borders-down-border_style = complete_stylex-borders-down-border_style. ENDIF. IF complete_stylex-borders-down-border_color-rgb = abap_true. stylemapping-complete_style-borders-down-border_color-rgb = complete_style-borders-down-border_color-rgb. stylemapping-complete_stylex-borders-down-border_color-rgb = complete_stylex-borders-down-border_color-rgb. ENDIF. IF complete_stylex-borders-down-border_color-indexed = abap_true. stylemapping-complete_style-borders-down-border_color-indexed = complete_style-borders-down-border_color-indexed. stylemapping-complete_stylex-borders-down-border_color-indexed = complete_stylex-borders-down-border_color-indexed. ENDIF. IF complete_stylex-borders-down-border_color-theme = abap_true. stylemapping-complete_style-borders-down-border_color-theme = complete_style-borders-down-border_color-theme. stylemapping-complete_stylex-borders-down-border_color-theme = complete_stylex-borders-down-border_color-theme. ENDIF. IF complete_stylex-borders-down-border_color-tint = abap_true. stylemapping-complete_style-borders-down-border_color-tint = complete_style-borders-down-border_color-tint. stylemapping-complete_stylex-borders-down-border_color-tint = complete_stylex-borders-down-border_color-tint. ENDIF. IF complete_stylex-borders-left-border_style = abap_true. stylemapping-complete_style-borders-left-border_style = complete_style-borders-left-border_style. stylemapping-complete_stylex-borders-left-border_style = complete_stylex-borders-left-border_style. ENDIF. IF complete_stylex-borders-left-border_color-rgb = abap_true. stylemapping-complete_style-borders-left-border_color-rgb = complete_style-borders-left-border_color-rgb. stylemapping-complete_stylex-borders-left-border_color-rgb = complete_stylex-borders-left-border_color-rgb. ENDIF. IF complete_stylex-borders-left-border_color-indexed = abap_true. stylemapping-complete_style-borders-left-border_color-indexed = complete_style-borders-left-border_color-indexed. stylemapping-complete_stylex-borders-left-border_color-indexed = complete_stylex-borders-left-border_color-indexed. ENDIF. IF complete_stylex-borders-left-border_color-theme = abap_true. stylemapping-complete_style-borders-left-border_color-theme = complete_style-borders-left-border_color-theme. stylemapping-complete_stylex-borders-left-border_color-theme = complete_stylex-borders-left-border_color-theme. ENDIF. IF complete_stylex-borders-left-border_color-tint = abap_true. stylemapping-complete_style-borders-left-border_color-tint = complete_style-borders-left-border_color-tint. stylemapping-complete_stylex-borders-left-border_color-tint = complete_stylex-borders-left-border_color-tint. ENDIF. IF complete_stylex-borders-right-border_style = abap_true. stylemapping-complete_style-borders-right-border_style = complete_style-borders-right-border_style. stylemapping-complete_stylex-borders-right-border_style = complete_stylex-borders-right-border_style. ENDIF. IF complete_stylex-borders-right-border_color-rgb = abap_true. stylemapping-complete_style-borders-right-border_color-rgb = complete_style-borders-right-border_color-rgb. stylemapping-complete_stylex-borders-right-border_color-rgb = complete_stylex-borders-right-border_color-rgb. ENDIF. IF complete_stylex-borders-right-border_color-indexed = abap_true. stylemapping-complete_style-borders-right-border_color-indexed = complete_style-borders-right-border_color-indexed. stylemapping-complete_stylex-borders-right-border_color-indexed = complete_stylex-borders-right-border_color-indexed. ENDIF. IF complete_stylex-borders-right-border_color-theme = abap_true. stylemapping-complete_style-borders-right-border_color-theme = complete_style-borders-right-border_color-theme. stylemapping-complete_stylex-borders-right-border_color-theme = complete_stylex-borders-right-border_color-theme. ENDIF. IF complete_stylex-borders-right-border_color-tint = abap_true. stylemapping-complete_style-borders-right-border_color-tint = complete_style-borders-right-border_color-tint. stylemapping-complete_stylex-borders-right-border_color-tint = complete_stylex-borders-right-border_color-tint. ENDIF. IF complete_stylex-borders-top-border_style = abap_true. stylemapping-complete_style-borders-top-border_style = complete_style-borders-top-border_style. stylemapping-complete_stylex-borders-top-border_style = complete_stylex-borders-top-border_style. ENDIF. IF complete_stylex-borders-top-border_color-rgb = abap_true. stylemapping-complete_style-borders-top-border_color-rgb = complete_style-borders-top-border_color-rgb. stylemapping-complete_stylex-borders-top-border_color-rgb = complete_stylex-borders-top-border_color-rgb. ENDIF. IF complete_stylex-borders-top-border_color-indexed = abap_true. stylemapping-complete_style-borders-top-border_color-indexed = complete_style-borders-top-border_color-indexed. stylemapping-complete_stylex-borders-top-border_color-indexed = complete_stylex-borders-top-border_color-indexed. ENDIF. IF complete_stylex-borders-top-border_color-theme = abap_true. stylemapping-complete_style-borders-top-border_color-theme = complete_style-borders-top-border_color-theme. stylemapping-complete_stylex-borders-top-border_color-theme = complete_stylex-borders-top-border_color-theme. ENDIF. IF complete_stylex-borders-top-border_color-tint = abap_true. stylemapping-complete_style-borders-top-border_color-tint = complete_style-borders-top-border_color-tint. stylemapping-complete_stylex-borders-top-border_color-tint = complete_stylex-borders-top-border_color-tint. ENDIF. * Now we have a completly filled styles. * This can be used to get the guid * Return guid if requested. Might be used if copy&paste of styles is requested ep_guid = me->excel->get_static_cellstyle_guid( ip_cstyle_complete = stylemapping-complete_style ip_cstylex_complete = stylemapping-complete_stylex ). lo_worksheet->set_cell_style( ip_column = ip_column ip_row = ip_row ip_style = ep_guid ). ENDMETHOD. METHOD zif_excel_style_changer~get_guid. result = excel->get_static_cellstyle_guid( ip_cstyle_complete = complete_style ip_cstylex_complete = complete_stylex ). ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_horizontal. complete_style-alignment-horizontal = value. complete_stylex-alignment-horizontal = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_indent. complete_style-alignment-indent = value. complete_stylex-alignment-indent = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_shrinktofit. complete_style-alignment-shrinktofit = value. complete_stylex-alignment-shrinktofit = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_textrotation. complete_style-alignment-textrotation = value. complete_stylex-alignment-textrotation = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_vertical. complete_style-alignment-vertical = value. complete_stylex-alignment-vertical = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_wraptext. complete_style-alignment-wraptext = value. complete_stylex-alignment-wraptext = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allborders_color. complete_style-borders-allborders-border_color = value. complete_stylex-borders-allborders-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allborders_style. complete_style-borders-allborders-border_style = value. complete_stylex-borders-allborders-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_indexe. complete_style-borders-allborders-border_color-indexed = value. complete_stylex-borders-allborders-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_rgb. complete_style-borders-allborders-border_color-rgb = value. complete_stylex-borders-allborders-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_theme. complete_style-borders-allborders-border_color-theme = value. complete_stylex-borders-allborders-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_tint. complete_style-borders-allborders-border_color-tint = value. complete_stylex-borders-allborders-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color. complete_style-borders-diagonal-border_color = value. complete_stylex-borders-diagonal-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_ind. complete_style-borders-diagonal-border_color-indexed = value. complete_stylex-borders-diagonal-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_rgb. complete_style-borders-diagonal-border_color-rgb = value. complete_stylex-borders-diagonal-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_the. complete_style-borders-diagonal-border_color-theme = value. complete_stylex-borders-diagonal-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_tin. complete_style-borders-diagonal-border_color-tint = value. complete_stylex-borders-diagonal-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_mode. complete_style-borders-diagonal_mode = value. complete_stylex-borders-diagonal_mode = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_style. complete_style-borders-diagonal-border_style = value. complete_stylex-borders-diagonal-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color. complete_style-borders-down-border_color = value. complete_stylex-borders-down-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_indexed. complete_style-borders-down-border_color-indexed = value. complete_stylex-borders-down-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_rgb. complete_style-borders-down-border_color-rgb = value. complete_stylex-borders-down-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_theme. complete_style-borders-down-border_color-theme = value. complete_stylex-borders-down-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_tint. complete_style-borders-down-border_color-tint = value. complete_stylex-borders-down-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_style. complete_style-borders-down-border_style = value. complete_stylex-borders-down-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color. complete_style-borders-left-border_color = value. complete_stylex-borders-left-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_indexed. complete_style-borders-left-border_color-indexed = value. complete_stylex-borders-left-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_rgb. complete_style-borders-left-border_color-rgb = value. complete_stylex-borders-left-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_theme. complete_style-borders-left-border_color-theme = value. complete_stylex-borders-left-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_tint. complete_style-borders-left-border_color-tint = value. complete_stylex-borders-left-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_style. complete_style-borders-left-border_style = value. complete_stylex-borders-left-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color. complete_style-borders-right-border_color = value. complete_stylex-borders-right-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_indexe. complete_style-borders-right-border_color-indexed = value. complete_stylex-borders-right-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_rgb. complete_style-borders-right-border_color-rgb = value. complete_stylex-borders-right-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_theme. complete_style-borders-right-border_color-theme = value. complete_stylex-borders-right-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_tint. complete_style-borders-right-border_color-tint = value. complete_stylex-borders-right-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_style. complete_style-borders-right-border_style = value. complete_stylex-borders-right-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color. complete_style-borders-top-border_color = value. complete_stylex-borders-top-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_indexed. complete_style-borders-top-border_color-indexed = value. complete_stylex-borders-top-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_rgb. complete_style-borders-top-border_color-rgb = value. complete_stylex-borders-top-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_theme. complete_style-borders-top-border_color-theme = value. complete_stylex-borders-top-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_tint. complete_style-borders-top-border_color-tint = value. complete_stylex-borders-top-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_style. complete_style-borders-top-border_style = value. complete_stylex-borders-top-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete. complete_style = ip_complete. complete_stylex = ip_xcomplete. multiple_change_requested-complete = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_alignment. DATA: alignmentx LIKE ip_xalignment. IF ip_xalignment IS SUPPLIED. alignmentx = ip_xalignment. ELSE. CLEAR alignmentx WITH 'X'. IF ip_alignment-horizontal IS INITIAL. CLEAR alignmentx-horizontal. ENDIF. IF ip_alignment-vertical IS INITIAL. CLEAR alignmentx-vertical. ENDIF. ENDIF. complete_style-alignment = ip_alignment . complete_stylex-alignment = alignmentx . multiple_change_requested-alignment = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders. DATA: bordersx LIKE ip_xborders. IF ip_xborders IS SUPPLIED. bordersx = ip_xborders. ELSE. CLEAR bordersx WITH 'X'. IF ip_borders-allborders-border_style IS INITIAL. CLEAR bordersx-allborders-border_style. ENDIF. IF ip_borders-diagonal-border_style IS INITIAL. CLEAR bordersx-diagonal-border_style. ENDIF. IF ip_borders-down-border_style IS INITIAL. CLEAR bordersx-down-border_style. ENDIF. IF ip_borders-left-border_style IS INITIAL. CLEAR bordersx-left-border_style. ENDIF. IF ip_borders-right-border_style IS INITIAL. CLEAR bordersx-right-border_style. ENDIF. IF ip_borders-top-border_style IS INITIAL. CLEAR bordersx-top-border_style. ENDIF. clear_initial_colorxfields( EXPORTING is_color = ip_borders-allborders-border_color CHANGING cs_xcolor = bordersx-allborders-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-diagonal-border_color CHANGING cs_xcolor = bordersx-diagonal-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-down-border_color CHANGING cs_xcolor = bordersx-down-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-left-border_color CHANGING cs_xcolor = bordersx-left-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-right-border_color CHANGING cs_xcolor = bordersx-right-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-top-border_color CHANGING cs_xcolor = bordersx-top-border_color ). ENDIF. complete_style-borders = ip_borders. complete_stylex-borders = bordersx. multiple_change_requested-borders-complete = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_all. lv_xborder_supplied = boolc( ip_xborders_allborders IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_allborders iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_allborders CHANGING cs_complete_style_border = complete_style-borders-allborders cs_complete_stylex_border = complete_stylex-borders-allborders ). multiple_change_requested-borders-allborders = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_diagonal. lv_xborder_supplied = boolc( ip_xborders_diagonal IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_diagonal iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_diagonal CHANGING cs_complete_style_border = complete_style-borders-diagonal cs_complete_stylex_border = complete_stylex-borders-diagonal ). multiple_change_requested-borders-diagonal = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_down. lv_xborder_supplied = boolc( ip_xborders_down IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_down iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_down CHANGING cs_complete_style_border = complete_style-borders-down cs_complete_stylex_border = complete_stylex-borders-down ). multiple_change_requested-borders-down = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_left. lv_xborder_supplied = boolc( ip_xborders_left IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_left iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_left CHANGING cs_complete_style_border = complete_style-borders-left cs_complete_stylex_border = complete_stylex-borders-left ). multiple_change_requested-borders-left = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_right. lv_xborder_supplied = boolc( ip_xborders_right IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_right iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_right CHANGING cs_complete_style_border = complete_style-borders-right cs_complete_stylex_border = complete_stylex-borders-right ). multiple_change_requested-borders-right = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_top. lv_xborder_supplied = boolc( ip_xborders_top IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_top iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_top CHANGING cs_complete_style_border = complete_style-borders-top cs_complete_stylex_border = complete_stylex-borders-top ). multiple_change_requested-borders-top = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_fill. DATA: fillx LIKE ip_xfill. IF ip_xfill IS SUPPLIED. fillx = ip_xfill. ELSE. CLEAR fillx WITH 'X'. IF ip_fill-filltype IS INITIAL. CLEAR fillx-filltype. ENDIF. clear_initial_colorxfields( EXPORTING is_color = ip_fill-fgcolor CHANGING cs_xcolor = fillx-fgcolor ). clear_initial_colorxfields( EXPORTING is_color = ip_fill-bgcolor CHANGING cs_xcolor = fillx-bgcolor ). ENDIF. complete_style-fill = ip_fill. complete_stylex-fill = fillx. multiple_change_requested-fill = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_font. DATA: fontx TYPE zexcel_s_cstylex_font. IF ip_xfont IS SUPPLIED. fontx = ip_xfont. ELSE. * Only supplied values should be used - exception: Flags bold and italic strikethrough underline fontx-bold = 'X'. fontx-italic = 'X'. fontx-strikethrough = 'X'. fontx-underline_mode = 'X'. CLEAR fontx-color WITH 'X'. clear_initial_colorxfields( EXPORTING is_color = ip_font-color CHANGING cs_xcolor = fontx-color ). IF ip_font-family IS NOT INITIAL. fontx-family = 'X'. ENDIF. IF ip_font-name IS NOT INITIAL. fontx-name = 'X'. ENDIF. IF ip_font-scheme IS NOT INITIAL. fontx-scheme = 'X'. ENDIF. IF ip_font-size IS NOT INITIAL. fontx-size = 'X'. ENDIF. IF ip_font-underline_mode IS NOT INITIAL. fontx-underline_mode = 'X'. ENDIF. ENDIF. complete_style-font = ip_font. complete_stylex-font = fontx. multiple_change_requested-font = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_protection. MOVE-CORRESPONDING ip_protection TO complete_style-protection. IF ip_xprotection IS SUPPLIED. MOVE-CORRESPONDING ip_xprotection TO complete_stylex-protection. ELSE. IF ip_protection-hidden IS NOT INITIAL. complete_stylex-protection-hidden = 'X'. ENDIF. IF ip_protection-locked IS NOT INITIAL. complete_stylex-protection-locked = 'X'. ENDIF. ENDIF. multiple_change_requested-protection = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor. complete_style-fill-bgcolor = value. complete_stylex-fill-bgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_indexed. complete_style-fill-bgcolor-indexed = value. complete_stylex-fill-bgcolor-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_rgb. complete_style-fill-bgcolor-rgb = value. complete_stylex-fill-bgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_theme. complete_style-fill-bgcolor-theme = value. complete_stylex-fill-bgcolor-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_tint. complete_style-fill-bgcolor-tint = value. complete_stylex-fill-bgcolor-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor. complete_style-fill-fgcolor = value. complete_stylex-fill-fgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_indexed. complete_style-fill-fgcolor-indexed = value. complete_stylex-fill-fgcolor-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_rgb. complete_style-fill-fgcolor-rgb = value. complete_stylex-fill-fgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_theme. complete_style-fill-fgcolor-theme = value. complete_stylex-fill-fgcolor-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_tint. complete_style-fill-fgcolor-tint = value. complete_stylex-fill-fgcolor-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_filltype. complete_style-fill-filltype = value. complete_stylex-fill-filltype = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_bottom. complete_style-fill-gradtype-bottom = value. complete_stylex-fill-gradtype-bottom = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_degree. complete_style-fill-gradtype-degree = value. complete_stylex-fill-gradtype-degree = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_left. complete_style-fill-gradtype-left = value. complete_stylex-fill-gradtype-left = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_position1. complete_style-fill-gradtype-position1 = value. complete_stylex-fill-gradtype-position1 = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_position2. complete_style-fill-gradtype-position2 = value. complete_stylex-fill-gradtype-position2 = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_position3. complete_style-fill-gradtype-position3 = value. complete_stylex-fill-gradtype-position3 = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_right. complete_style-fill-gradtype-right = value. complete_stylex-fill-gradtype-right = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_top. complete_style-fill-gradtype-top = value. complete_stylex-fill-gradtype-top = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_type. complete_style-fill-gradtype-type = value. complete_stylex-fill-gradtype-type = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_rotation. complete_style-fill-rotation = value. complete_stylex-fill-rotation = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_bold. complete_style-font-bold = value. complete_stylex-font-bold = 'X'. single_change_requested-font-bold = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color. complete_style-font-color = value. complete_stylex-font-color-rgb = 'X'. single_change_requested-font-color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_indexed. complete_style-font-color-indexed = value. complete_stylex-font-color-indexed = 'X'. single_change_requested-font-color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_rgb. complete_style-font-color-rgb = value. complete_stylex-font-color-rgb = 'X'. single_change_requested-font-color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_theme. complete_style-font-color-theme = value. complete_stylex-font-color-theme = 'X'. single_change_requested-font-color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_tint. complete_style-font-color-tint = value. complete_stylex-font-color-tint = 'X'. single_change_requested-font-color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_family. complete_style-font-family = value. complete_stylex-font-family = 'X'. single_change_requested-font-family = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_italic. complete_style-font-italic = value. complete_stylex-font-italic = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_name. complete_style-font-name = value. complete_stylex-font-name = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_scheme. complete_style-font-scheme = value. complete_stylex-font-scheme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_size. complete_style-font-size = value. complete_stylex-font-size = abap_true. single_change_requested-font-size = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_strikethrough. complete_style-font-strikethrough = value. complete_stylex-font-strikethrough = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_underline. complete_style-font-underline = value. complete_stylex-font-underline = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_underline_mode. complete_style-font-underline_mode = value. complete_stylex-font-underline_mode = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_number_format. complete_style-number_format-format_code = value. complete_stylex-number_format-format_code = abap_true. single_change_requested-number_format-format_code = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_protection_hidden. complete_style-protection-hidden = value. complete_stylex-protection-hidden = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_protection_locked. complete_style-protection-locked = value. complete_stylex-protection-locked = 'X'. result = me. ENDMETHOD. ENDCLASS. ",12450,True,3444.9333485066472,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_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. ",8131,False,1650.9310386909356,median "CLASS ycl_abapgit_object_tran DEFINITION PUBLIC INHERITING FROM ycl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES yif_abapgit_object. ALIASES mo_files FOR yif_abapgit_object~mo_files. PRIVATE SECTION. CONSTANTS: c_oo_program(9) VALUE '\\PROGRAM=', c_oo_class(7) VALUE '\\CLASS=', c_oo_method(8) VALUE '\\METHOD=', c_oo_tcode TYPE tcode VALUE 'OS_APPLICATION', c_oo_frclass(30) VALUE 'CLASS', c_oo_frmethod(30) VALUE 'METHOD', c_oo_frupdtask(30) VALUE 'UPDATE_MODE', c_oo_synchron VALUE 'S', c_oo_asynchron VALUE 'U', c_true TYPE c VALUE 'X', c_false TYPE c VALUE space. METHODS: split_parameters CHANGING ct_rsparam TYPE s_param cs_rsstcd TYPE rsstcd cs_tstcp TYPE tstcp cs_tstc TYPE tstc, split_parameters_comp IMPORTING ig_type TYPE any ig_param TYPE any CHANGING cg_value TYPE any, serialize_texts IMPORTING io_xml TYPE REF TO ycl_abapgit_xml_output RAISING ycx_abapgit_exception, deserialize_texts IMPORTING io_xml TYPE REF TO ycl_abapgit_xml_input RAISING ycx_abapgit_exception. ENDCLASS. CLASS YCL_ABAPGIT_OBJECT_TRAN IMPLEMENTATION. METHOD deserialize_texts. DATA lt_tpool_i18n TYPE TABLE OF tstct. FIELD-SYMBOLS LIKE LINE OF lt_tpool_i18n. "" Read XML-files data io_xml->read( EXPORTING iv_name = 'I18N_TPOOL' CHANGING cg_data = lt_tpool_i18n ). "" Force t-code name (security reasons) LOOP AT lt_tpool_i18n ASSIGNING . -tcode = ms_item-obj_name. ENDLOOP. IF lines( lt_tpool_i18n ) > 0. MODIFY tstct FROM TABLE lt_tpool_i18n. IF sy-subrc <> 0. ycx_abapgit_exception=>raise( 'Update of t-code translations failed' ). ENDIF. ENDIF. ENDMETHOD. METHOD serialize_texts. DATA lt_tpool_i18n TYPE TABLE OF tstct. "" Skip master language - it was already serialized "" Don't serialize t-code itself SELECT sprsl ttext INTO CORRESPONDING FIELDS OF TABLE lt_tpool_i18n FROM tstct WHERE sprsl <> mv_language AND tcode = ms_item-obj_name. ""#EC CI_GENBUFF IF lines( lt_tpool_i18n ) > 0. SORT lt_tpool_i18n BY sprsl ASCENDING. io_xml->add( iv_name = 'I18N_TPOOL' ig_data = lt_tpool_i18n ). ENDIF. ENDMETHOD. METHOD split_parameters. * see subroutine split_parameters in include LSEUKF01 DATA: lv_off TYPE i, lv_param_beg TYPE i, lv_length TYPE i, ls_param LIKE LINE OF ct_rsparam. FIELD-SYMBOLS TYPE any. CLEAR cs_rsstcd-s_vari. IF cs_tstcp-param(1) = '\\'. "" OO-Transaktion ohne FR split_parameters_comp( EXPORTING ig_type = c_oo_program ig_param = cs_tstcp-param CHANGING cg_value = cs_tstc-pgmna ). split_parameters_comp( EXPORTING ig_type = c_oo_class ig_param = cs_tstcp-param CHANGING cg_value = cs_rsstcd-classname ). split_parameters_comp( EXPORTING ig_type = c_oo_method ig_param = cs_tstcp-param CHANGING cg_value = cs_rsstcd-method ). IF NOT cs_tstc-pgmna IS INITIAL. cs_rsstcd-s_local = c_true. ENDIF. RETURN. ELSEIF cs_tstcp-param(1) = '@'. "" Transaktionsvariante cs_rsstcd-s_vari = c_true. IF cs_tstcp-param(2) = '@@'. cs_rsstcd-s_ind_vari = c_true. lv_off = 2. ELSE. CLEAR cs_rsstcd-s_ind_vari. lv_off = 1. ENDIF. IF cs_tstcp-param CA ' '. ENDIF. sy-fdpos = sy-fdpos - lv_off. IF sy-fdpos > 0. cs_rsstcd-call_tcode = cs_tstcp-param+lv_off(sy-fdpos). sy-fdpos = sy-fdpos + 1 + lv_off. cs_rsstcd-variant = cs_tstcp-param+sy-fdpos. ENDIF. ELSEIF cs_tstcp-param(1) = '/'. cs_rsstcd-st_tcode = c_true. cs_rsstcd-st_prog = space. IF cs_tstcp-param+1(1) = '*'. cs_rsstcd-st_skip_1 = c_true. ELSE. CLEAR cs_rsstcd-st_skip_1. ENDIF. IF cs_tstcp-param CA ' '. ENDIF. lv_param_beg = sy-fdpos + 1. sy-fdpos = sy-fdpos - 2. IF sy-fdpos > 0. cs_rsstcd-call_tcode = cs_tstcp-param+2(sy-fdpos). ENDIF. SHIFT cs_tstcp-param BY lv_param_beg PLACES. ELSE. cs_rsstcd-st_tcode = space. cs_rsstcd-st_prog = c_true. ENDIF. DO 254 TIMES. IF cs_tstcp-param = space. EXIT. ENDIF. CLEAR ls_param. IF cs_tstcp-param CA '='. CHECK sy-fdpos <> 0. ASSIGN cs_tstcp-param(sy-fdpos) TO . ls_param-field = . IF ls_param-field(1) = space. SHIFT ls_param-field. ENDIF. sy-fdpos = sy-fdpos + 1. SHIFT cs_tstcp-param BY sy-fdpos PLACES. IF cs_tstcp-param CA ';'. IF sy-fdpos <> 0. ASSIGN cs_tstcp-param(sy-fdpos) TO . ls_param-value = . IF ls_param-value(1) = space. SHIFT ls_param-value. ENDIF. ENDIF. sy-fdpos = sy-fdpos + 1. SHIFT cs_tstcp-param BY sy-fdpos PLACES. APPEND ls_param TO ct_rsparam. ELSE. lv_length = strlen( cs_tstcp-param ). CHECK lv_length > 0. ASSIGN cs_tstcp-param(lv_length) TO . ls_param-value = . IF ls_param-value(1) = space. SHIFT ls_param-value. ENDIF. lv_length = lv_length + 1. SHIFT cs_tstcp-param BY lv_length PLACES. APPEND ls_param TO ct_rsparam. ENDIF. ENDIF. ENDDO. * oo-Transaktion mit Framework IF cs_rsstcd-call_tcode = c_oo_tcode. cs_rsstcd-s_trframe = c_true. LOOP AT ct_rsparam INTO ls_param. CASE ls_param-field. WHEN c_oo_frclass. cs_rsstcd-classname = ls_param-value. WHEN c_oo_frmethod. cs_rsstcd-method = ls_param-value. WHEN c_oo_frupdtask. IF ls_param-value = c_oo_synchron. cs_rsstcd-s_upddir = c_true. cs_rsstcd-s_updtask = c_false. cs_rsstcd-s_updlok = c_false. ELSEIF ls_param-value = c_oo_asynchron. cs_rsstcd-s_upddir = c_false. cs_rsstcd-s_updtask = c_true. cs_rsstcd-s_updlok = c_false. ELSE. cs_rsstcd-s_upddir = c_false. cs_rsstcd-s_updtask = c_false. cs_rsstcd-s_updlok = c_true. ENDIF. ENDCASE. ENDLOOP. ENDIF. ENDMETHOD. METHOD split_parameters_comp. DATA: lv_off TYPE i. IF ig_param CS ig_type. lv_off = sy-fdpos + strlen( ig_type ). cg_value = ig_param+lv_off. IF cg_value CA '\\'. CLEAR cg_value+sy-fdpos. ENDIF. ENDIF. ENDMETHOD. METHOD yif_abapgit_object~changed_by. rv_user = c_user_unknown. "" todo ENDMETHOD. METHOD yif_abapgit_object~compare_to_remote_version. CREATE OBJECT ro_comparison_result TYPE ycl_abapgit_comparison_null. ENDMETHOD. METHOD yif_abapgit_object~delete. DATA: lv_transaction TYPE tstc-tcode. lv_transaction = ms_item-obj_name. CALL FUNCTION 'RPY_TRANSACTION_DELETE' EXPORTING transaction = lv_transaction EXCEPTIONS not_excecuted = 1 object_not_found = 2 OTHERS = 3. IF sy-subrc <> 0. ycx_abapgit_exception=>raise( 'Error from RPY_TRANSACTION_DELETE' ). ENDIF. ENDMETHOD. METHOD yif_abapgit_object~deserialize. CONSTANTS: lc_hex_tra TYPE x VALUE '00', * c_hex_men TYPE x VALUE '01', lc_hex_par TYPE x VALUE '02', lc_hex_rep TYPE x VALUE '80'. * c_hex_rpv TYPE x VALUE '10', * c_hex_obj TYPE x VALUE '08', * c_hex_chk TYPE x VALUE '04', * c_hex_enq TYPE x VALUE '20'. DATA: lv_dynpro TYPE d020s-dnum, ls_tstc TYPE tstc, lv_type TYPE rglif-docutype, ls_tstct TYPE tstct, ls_tstcc TYPE tstcc, ls_tstcp TYPE tstcp, lt_param_values TYPE TABLE OF rsparam, ls_rsstcd TYPE rsstcd. IF yif_abapgit_object~exists( ) = abap_true. yif_abapgit_object~delete( ). ENDIF. io_xml->read( EXPORTING iv_name = 'TSTC' CHANGING cg_data = ls_tstc ). io_xml->read( EXPORTING iv_name = 'TSTCC' CHANGING cg_data = ls_tstcc ). io_xml->read( EXPORTING iv_name = 'TSTCT' CHANGING cg_data = ls_tstct ). io_xml->read( EXPORTING iv_name = 'TSTCP' CHANGING cg_data = ls_tstcp ). lv_dynpro = ls_tstc-dypno. CASE ls_tstc-cinfo. WHEN lc_hex_tra. lv_type = ststc_c_type_dialog. WHEN lc_hex_rep. lv_type = ststc_c_type_report. WHEN lc_hex_par. lv_type = ststc_c_type_parameters. * todo, or ststc_c_type_variant? WHEN OTHERS. ycx_abapgit_exception=>raise( 'Transaction, unknown CINFO' ). ENDCASE. IF ls_tstcp IS NOT INITIAL. split_parameters( CHANGING ct_rsparam = lt_param_values cs_rsstcd = ls_rsstcd cs_tstcp = ls_tstcp cs_tstc = ls_tstc ). ENDIF. CALL FUNCTION 'RPY_TRANSACTION_INSERT' EXPORTING transaction = ls_tstc-tcode program = ls_tstc-pgmna dynpro = lv_dynpro language = mv_language development_class = iv_package transaction_type = lv_type shorttext = ls_tstct-ttext called_transaction = ls_rsstcd-call_tcode called_transaction_skip = ls_rsstcd-st_skip_1 variant = ls_rsstcd-variant cl_independend = ls_rsstcd-s_ind_vari html_enabled = ls_tstcc-s_webgui java_enabled = ls_tstcc-s_platin wingui_enabled = ls_tstcc-s_win32 TABLES param_values = lt_param_values EXCEPTIONS cancelled = 1 already_exist = 2 permission_error = 3 name_not_allowed = 4 name_conflict = 5 illegal_type = 6 object_inconsistent = 7 db_access_error = 8 OTHERS = 9. IF sy-subrc <> 0. ycx_abapgit_exception=>raise( 'Error from RPY_TRANSACTION_INSERT' ). ENDIF. "" Texts deserializing (translations) deserialize_texts( io_xml ). ENDMETHOD. METHOD yif_abapgit_object~exists. DATA: lv_tcode TYPE tstc-tcode. SELECT SINGLE tcode FROM tstc INTO lv_tcode WHERE tcode = ms_item-obj_name. ""#EC CI_GENBUFF rv_bool = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD yif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). ENDMETHOD. METHOD yif_abapgit_object~has_changed_since. rv_changed = abap_true. ENDMETHOD. METHOD yif_abapgit_object~jump. DATA: lt_bdcdata TYPE TABLE OF bdcdata. FIELD-SYMBOLS: LIKE LINE OF lt_bdcdata. APPEND INITIAL LINE TO lt_bdcdata ASSIGNING . -program = 'SAPLSEUK'. -dynpro = '0390'. -dynbegin = abap_true. APPEND INITIAL LINE TO lt_bdcdata ASSIGNING . -fnam = 'BDC_OKCODE'. -fval = '=SHOW'. APPEND INITIAL LINE TO lt_bdcdata ASSIGNING . -fnam = 'TSTC-TCODE'. -fval = ms_item-obj_name. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'GIT' EXPORTING tcode = 'SE93' mode_val = 'E' TABLES using_tab = lt_bdcdata EXCEPTIONS system_failure = 1 communication_failure = 2 resource_failure = 3 OTHERS = 4 ##fm_subrc_ok. ""#EC CI_SUBRC ENDMETHOD. METHOD yif_abapgit_object~serialize. DATA: lv_transaction TYPE tstc-tcode, lt_tcodes TYPE TABLE OF tstc, ls_tcode LIKE LINE OF lt_tcodes, ls_tstct TYPE tstct, ls_tstcp TYPE tstcp, lt_gui_attr TYPE TABLE OF tstcc, ls_gui_attr LIKE LINE OF lt_gui_attr. lv_transaction = ms_item-obj_name. CALL FUNCTION 'RPY_TRANSACTION_READ' EXPORTING transaction = lv_transaction TABLES tcodes = lt_tcodes gui_attributes = lt_gui_attr EXCEPTIONS permission_error = 1 cancelled = 2 not_found = 3 object_not_found = 4 OTHERS = 5. IF sy-subrc = 4 OR sy-subrc = 3. RETURN. ELSEIF sy-subrc <> 0. ycx_abapgit_exception=>raise( 'Error from RPY_TRANSACTION_READ' ). ENDIF. SELECT SINGLE * FROM tstct INTO ls_tstct WHERE sprsl = mv_language AND tcode = lv_transaction. ""#EC CI_SUBRC ""#EC CI_GENBUFF SELECT SINGLE * FROM tstcp INTO ls_tstcp WHERE tcode = lv_transaction. ""#EC CI_SUBRC ""#EC CI_GENBUFF READ TABLE lt_tcodes INDEX 1 INTO ls_tcode. ASSERT sy-subrc = 0. READ TABLE lt_gui_attr INDEX 1 INTO ls_gui_attr. ASSERT sy-subrc = 0. io_xml->add( iv_name = 'TSTC' ig_data = ls_tcode ). io_xml->add( iv_name = 'TSTCC' ig_data = ls_gui_attr ). io_xml->add( iv_name = 'TSTCT' ig_data = ls_tstct ). IF ls_tstcp IS NOT INITIAL. io_xml->add( iv_name = 'TSTCP' ig_data = ls_tstcp ). ENDIF. "" Texts serializing (translations) serialize_texts( io_xml ). ENDMETHOD. METHOD yif_abapgit_object~is_locked. DATA: lv_object TYPE eqegraarg. lv_object = |TN{ ms_item-obj_name }|. OVERLAY lv_object WITH ' '. lv_object = lv_object && '*'. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'EEUDB' iv_argument = lv_object ). ENDMETHOD. ENDCLASS. ",4105,False,830.3949507293223,median "/* Copyright (c) 2014 Josh Tynjala 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. */ package feathers.themes { import feathers.controls.Alert; import feathers.controls.Button; import feathers.controls.ButtonGroup; import feathers.controls.Callout; import feathers.controls.Check; import feathers.controls.Drawers; import feathers.controls.GroupedList; import feathers.controls.Header; import feathers.controls.IScrollBar; import feathers.controls.ImageLoader; import feathers.controls.Label; import feathers.controls.List; import feathers.controls.NumericStepper; import feathers.controls.PageIndicator; import feathers.controls.Panel; import feathers.controls.PanelScreen; import feathers.controls.PickerList; import feathers.controls.ProgressBar; import feathers.controls.Radio; import feathers.controls.Screen; import feathers.controls.ScrollBar; import feathers.controls.ScrollContainer; import feathers.controls.ScrollScreen; import feathers.controls.ScrollText; import feathers.controls.Scroller; import feathers.controls.SimpleScrollBar; import feathers.controls.Slider; import feathers.controls.TabBar; import feathers.controls.TextArea; import feathers.controls.TextInput; import feathers.controls.ToggleSwitch; import feathers.controls.popups.DropDownPopUpContentManager; import feathers.controls.renderers.BaseDefaultItemRenderer; import feathers.controls.renderers.DefaultGroupedListHeaderOrFooterRenderer; import feathers.controls.renderers.DefaultGroupedListItemRenderer; import feathers.controls.renderers.DefaultListItemRenderer; import feathers.controls.text.TextFieldTextEditor; import feathers.controls.text.TextFieldTextRenderer; import feathers.core.FeathersControl; import feathers.core.FocusManager; import feathers.core.ITextEditor; import feathers.core.ITextRenderer; import feathers.core.PopUpManager; import feathers.display.Scale3Image; import feathers.display.Scale9Image; import feathers.layout.HorizontalLayout; import feathers.layout.VerticalLayout; import feathers.skins.SmartDisplayObjectStateValueSelector; import feathers.skins.StandardIcons; import feathers.system.DeviceCapabilities; import feathers.textures.Scale3Textures; import feathers.textures.Scale9Textures; import flash.geom.Rectangle; import flash.text.TextFormat; import flash.text.TextFormatAlign; import starling.core.Starling; import starling.display.DisplayObject; import starling.display.Image; import starling.display.Quad; import starling.textures.SubTexture; import starling.textures.Texture; import starling.textures.TextureAtlas; /** * The base class for the ""Aeon"" theme for desktop Feathers apps. Handles * everything except asset loading, which is left to subclasses. * * @see AeonDesktopTheme * @see AeonDesktopThemeWithAssetManager */ public class BaseAeonDesktopTheme extends StyleNameFunctionTheme { protected static const THEME_NAME_HORIZONTAL_SCROLL_BAR_INCREMENT_BUTTON:String = ""aeon-horizontal-scroll-bar-increment-button""; protected static const THEME_NAME_HORIZONTAL_SCROLL_BAR_DECREMENT_BUTTON:String = ""aeon-horizontal-scroll-bar-decrement-button""; protected static const THEME_NAME_HORIZONTAL_SCROLL_BAR_THUMB:String = ""aeon-horizontal-scroll-bar-thumb""; protected static const THEME_NAME_HORIZONTAL_SCROLL_BAR_MINIMUM_TRACK:String = ""aeon-horizontal-scroll-bar-minimum-track""; protected static const THEME_NAME_VERTICAL_SCROLL_BAR_INCREMENT_BUTTON:String = ""aeon-vertical-scroll-bar-increment-button""; protected static const THEME_NAME_VERTICAL_SCROLL_BAR_DECREMENT_BUTTON:String = ""aeon-vertical-scroll-bar-decrement-button""; protected static const THEME_NAME_VERTICAL_SCROLL_BAR_THUMB:String = ""aeon-vertical-scroll-bar-thumb""; protected static const THEME_NAME_VERTICAL_SCROLL_BAR_MINIMUM_TRACK:String = ""aeon-vertical-scroll-bar-minimum-track""; protected static const THEME_NAME_HORIZONTAL_SIMPLE_SCROLL_BAR_THUMB:String = ""aeon-horizontal-simple-scroll-bar-thumb""; protected static const THEME_NAME_VERTICAL_SIMPLE_SCROLL_BAR_THUMB:String = ""aeon-vertical-simple-scroll-bar-thumb""; protected static const THEME_NAME_HORIZONTAL_SLIDER_THUMB:String = ""aeon-horizontal-slider-thumb""; protected static const THEME_NAME_HORIZONTAL_SLIDER_MINIMUM_TRACK:String = ""aeon-horizontal-slider-minimum-track""; protected static const THEME_NAME_VERTICAL_SLIDER_THUMB:String = ""aeon-vertical-slider-thumb""; protected static const THEME_NAME_VERTICAL_SLIDER_MINIMUM_TRACK:String = ""aeon-vertical-slider-minimum-track""; protected static const ATLAS_NAME:String = ""aeon""; protected static const FONT_NAME:String = ""_sans""; protected static const FOCUS_INDICATOR_SCALE_9_GRID:Rectangle = new Rectangle(5, 4, 1, 14); protected static const BUTTON_SCALE_9_GRID:Rectangle = new Rectangle(6, 6, 70, 10); protected static const SELECTED_BUTTON_SCALE_9_GRID:Rectangle = new Rectangle(6, 6, 52, 10); protected static const TAB_SCALE_9_GRID:Rectangle = new Rectangle(4, 4, 55, 16); protected static const STEPPER_INCREMENT_BUTTON_SCALE_9_GRID:Rectangle = new Rectangle(1, 9, 15, 1); protected static const STEPPER_DECREMENT_BUTTON_SCALE_9_GRID:Rectangle = new Rectangle(1, 1, 15, 1); protected static const HSLIDER_FIRST_REGION:Number = 2; protected static const HSLIDER_SECOND_REGION:Number = 75; protected static const TEXT_INPUT_SCALE_9_GRID:Rectangle = new Rectangle(2, 2, 148, 18); protected static const VERTICAL_SCROLL_BAR_THUMB_SCALE_9_GRID:Rectangle = new Rectangle(2, 5, 6, 42); protected static const VERTICAL_SCROLL_BAR_TRACK_SCALE_9_GRID:Rectangle = new Rectangle(2, 1, 11, 2); protected static const VERTICAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID:Rectangle = new Rectangle(2, 2, 11, 10); protected static const HORIZONTAL_SCROLL_BAR_THUMB_SCALE_9_GRID:Rectangle = new Rectangle(5, 2, 42, 6); protected static const HORIZONTAL_SCROLL_BAR_TRACK_SCALE_9_GRID:Rectangle = new Rectangle(1, 2, 2, 11); protected static const HORIZONTAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID:Rectangle = new Rectangle(2, 2, 10, 11); protected static const SIMPLE_BORDER_SCALE_9_GRID:Rectangle = new Rectangle(2, 2, 2, 2); protected static const PANEL_BORDER_SCALE_9_GRID:Rectangle = new Rectangle(6, 6, 2, 2); protected static const HEADER_SCALE_9_GRID:Rectangle = new Rectangle(0, 0, 4, 28); protected static const BACKGROUND_COLOR:uint = 0x869CA7; protected static const MODAL_OVERLAY_COLOR:uint = 0xDDDDDD; protected static const PRIMARY_TEXT_COLOR:uint = 0x0B333C; protected static const DISABLED_TEXT_COLOR:uint = 0x5B6770; protected static const MODAL_OVERLAY_ALPHA:Number = 0.5; protected static function textRendererFactory():ITextRenderer { return new TextFieldTextRenderer(); } protected static function textEditorFactory():ITextEditor { return new TextFieldTextEditor(); } protected static function scrollBarFactory():IScrollBar { return new ScrollBar(); } protected static function popUpOverlayFactory():DisplayObject { var quad:Quad = new Quad(100, 100, MODAL_OVERLAY_COLOR); quad.alpha = MODAL_OVERLAY_ALPHA; return quad; } protected static function textureValueTypeHandler(value:Texture, oldDisplayObject:DisplayObject = null):DisplayObject { var displayObject:ImageLoader = oldDisplayObject as ImageLoader; if(!displayObject) { displayObject = new ImageLoader(); } displayObject.source = value; return displayObject; } public function BaseAeonDesktopTheme() { super(); } public function get originalDPI():int { return DeviceCapabilities.dpi; } public function get scaleToDPI():Boolean { return false; } protected var atlas:TextureAtlas; protected var atlasTexture:Texture; protected var defaultTextFormat:TextFormat; protected var disabledTextFormat:TextFormat; protected var headingTextFormat:TextFormat; protected var headingDisabledTextFormat:TextFormat; protected var detailTextFormat:TextFormat; protected var detailDisabledTextFormat:TextFormat; protected var headerTitleTextFormat:TextFormat; protected var focusIndicatorSkinTextures:Scale9Textures; protected var buttonUpSkinTextures:Scale9Textures; protected var buttonHoverSkinTextures:Scale9Textures; protected var buttonDownSkinTextures:Scale9Textures; protected var buttonDisabledSkinTextures:Scale9Textures; protected var buttonSelectedUpSkinTextures:Scale9Textures; protected var buttonSelectedHoverSkinTextures:Scale9Textures; protected var buttonSelectedDownSkinTextures:Scale9Textures; protected var buttonSelectedDisabledSkinTextures:Scale9Textures; protected var tabUpSkinTextures:Scale9Textures; protected var tabHoverSkinTextures:Scale9Textures; protected var tabDownSkinTextures:Scale9Textures; protected var tabDisabledSkinTextures:Scale9Textures; protected var tabSelectedUpSkinTextures:Scale9Textures; protected var tabSelectedDisabledSkinTextures:Scale9Textures; protected var stepperIncrementButtonUpSkinTextures:Scale9Textures; protected var stepperIncrementButtonHoverSkinTextures:Scale9Textures; protected var stepperIncrementButtonDownSkinTextures:Scale9Textures; protected var stepperIncrementButtonDisabledSkinTextures:Scale9Textures; protected var stepperDecrementButtonUpSkinTextures:Scale9Textures; protected var stepperDecrementButtonHoverSkinTextures:Scale9Textures; protected var stepperDecrementButtonDownSkinTextures:Scale9Textures; protected var stepperDecrementButtonDisabledSkinTextures:Scale9Textures; protected var hSliderThumbUpSkinTexture:Texture; protected var hSliderThumbHoverSkinTexture:Texture; protected var hSliderThumbDownSkinTexture:Texture; protected var hSliderThumbDisabledSkinTexture:Texture; protected var hSliderTrackSkinTextures:Scale3Textures; protected var vSliderThumbUpSkinTexture:Texture; protected var vSliderThumbHoverSkinTexture:Texture; protected var vSliderThumbDownSkinTexture:Texture; protected var vSliderThumbDisabledSkinTexture:Texture; protected var vSliderTrackSkinTextures:Scale3Textures; protected var itemRendererUpSkinTexture:Texture; protected var itemRendererHoverSkinTexture:Texture; protected var itemRendererSelectedUpSkinTexture:Texture; protected var headerBackgroundSkinTextures:Scale9Textures; protected var groupedListHeaderBackgroundSkinTextures:Scale9Textures; protected var checkUpIconTexture:Texture; protected var checkHoverIconTexture:Texture; protected var checkDownIconTexture:Texture; protected var checkDisabledIconTexture:Texture; protected var checkSelectedUpIconTexture:Texture; protected var checkSelectedHoverIconTexture:Texture; protected var checkSelectedDownIconTexture:Texture; protected var checkSelectedDisabledIconTexture:Texture; protected var radioUpIconTexture:Texture; protected var radioHoverIconTexture:Texture; protected var radioDownIconTexture:Texture; protected var radioDisabledIconTexture:Texture; protected var radioSelectedUpIconTexture:Texture; protected var radioSelectedHoverIconTexture:Texture; protected var radioSelectedDownIconTexture:Texture; protected var radioSelectedDisabledIconTexture:Texture; protected var pageIndicatorNormalSkinTexture:Texture; protected var pageIndicatorSelectedSkinTexture:Texture; protected var pickerListUpIconTexture:Texture; protected var pickerListHoverIconTexture:Texture; protected var pickerListDownIconTexture:Texture; protected var pickerListDisabledIconTexture:Texture; protected var textInputBackgroundSkinTextures:Scale9Textures; protected var textInputBackgroundDisabledSkinTextures:Scale9Textures; protected var textInputSearchIconTexture:Texture; protected var vScrollBarThumbUpSkinTextures:Scale9Textures; protected var vScrollBarThumbHoverSkinTextures:Scale9Textures; protected var vScrollBarThumbDownSkinTextures:Scale9Textures; protected var vScrollBarTrackSkinTextures:Scale9Textures; protected var vScrollBarThumbIconTexture:Texture; protected var vScrollBarStepButtonUpSkinTextures:Scale9Textures; protected var vScrollBarStepButtonHoverSkinTextures:Scale9Textures; protected var vScrollBarStepButtonDownSkinTextures:Scale9Textures; protected var vScrollBarStepButtonDisabledSkinTextures:Scale9Textures; protected var vScrollBarDecrementButtonIconTexture:Texture; protected var vScrollBarIncrementButtonIconTexture:Texture; protected var hScrollBarThumbUpSkinTextures:Scale9Textures; protected var hScrollBarThumbHoverSkinTextures:Scale9Textures; protected var hScrollBarThumbDownSkinTextures:Scale9Textures; protected var hScrollBarTrackSkinTextures:Scale9Textures; protected var hScrollBarThumbIconTexture:Texture; protected var hScrollBarStepButtonUpSkinTextures:Scale9Textures; protected var hScrollBarStepButtonHoverSkinTextures:Scale9Textures; protected var hScrollBarStepButtonDownSkinTextures:Scale9Textures; protected var hScrollBarStepButtonDisabledSkinTextures:Scale9Textures; protected var hScrollBarDecrementButtonIconTexture:Texture; protected var hScrollBarIncrementButtonIconTexture:Texture; protected var simpleBorderBackgroundSkinTextures:Scale9Textures; protected var panelBorderBackgroundSkinTextures:Scale9Textures; protected var progressBarFillSkinTexture:Texture; public function dispose():void { if(this.atlas) { this.atlas.dispose(); this.atlas = null; //no need to dispose the atlas texture because the atlas will do that this.atlasTexture = null; } } protected function initializeStage():void { Starling.current.stage.color = BACKGROUND_COLOR; Starling.current.nativeStage.color = BACKGROUND_COLOR; } protected function initialize():void { this.initializeFonts(); this.initializeTextures(); this.initializeGlobals() this.initializeStage(); this.initializeStyleProviders(); } protected function initializeGlobals():void { FocusManager.isEnabled = true; FeathersControl.defaultTextRendererFactory = textRendererFactory; FeathersControl.defaultTextEditorFactory = textEditorFactory; PopUpManager.overlayFactory = popUpOverlayFactory; Callout.stagePaddingTop = Callout.stagePaddingRight = Callout.stagePaddingBottom = Callout.stagePaddingLeft = 16; } protected function initializeFonts():void { this.defaultTextFormat = new TextFormat(FONT_NAME, 11, PRIMARY_TEXT_COLOR, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0); this.disabledTextFormat = new TextFormat(FONT_NAME, 11, DISABLED_TEXT_COLOR, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0); this.headerTitleTextFormat = new TextFormat(FONT_NAME, 12, PRIMARY_TEXT_COLOR, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0); this.headingTextFormat = new TextFormat(FONT_NAME, 14, PRIMARY_TEXT_COLOR, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0); this.headingDisabledTextFormat = new TextFormat(FONT_NAME, 14, DISABLED_TEXT_COLOR, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0); this.detailTextFormat = new TextFormat(FONT_NAME, 10, PRIMARY_TEXT_COLOR, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0); this.detailDisabledTextFormat = new TextFormat(FONT_NAME, 10, DISABLED_TEXT_COLOR, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0); } protected function initializeTextures():void { this.focusIndicatorSkinTextures = new Scale9Textures(this.atlas.getTexture(""focus-indicator-skin""), FOCUS_INDICATOR_SCALE_9_GRID); this.buttonUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-up-skin""), BUTTON_SCALE_9_GRID); this.buttonHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-hover-skin""), BUTTON_SCALE_9_GRID); this.buttonDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-down-skin""), BUTTON_SCALE_9_GRID); this.buttonDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-disabled-skin""), BUTTON_SCALE_9_GRID); this.buttonSelectedUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-selected-up-skin""), SELECTED_BUTTON_SCALE_9_GRID); this.buttonSelectedHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-selected-hover-skin""), SELECTED_BUTTON_SCALE_9_GRID); this.buttonSelectedDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-selected-down-skin""), SELECTED_BUTTON_SCALE_9_GRID); this.buttonSelectedDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""button-selected-disabled-skin""), SELECTED_BUTTON_SCALE_9_GRID); this.tabUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""tab-up-skin""), TAB_SCALE_9_GRID); this.tabHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""tab-hover-skin""), TAB_SCALE_9_GRID); this.tabDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""tab-down-skin""), TAB_SCALE_9_GRID); this.tabDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""tab-disabled-skin""), TAB_SCALE_9_GRID); this.tabSelectedUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""tab-selected-up-skin""), TAB_SCALE_9_GRID); this.tabSelectedDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""tab-selected-disabled-skin""), TAB_SCALE_9_GRID); this.stepperIncrementButtonUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-increment-button-up-skin""), STEPPER_INCREMENT_BUTTON_SCALE_9_GRID); this.stepperIncrementButtonHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-increment-button-hover-skin""), STEPPER_INCREMENT_BUTTON_SCALE_9_GRID); this.stepperIncrementButtonDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-increment-button-down-skin""), STEPPER_INCREMENT_BUTTON_SCALE_9_GRID); this.stepperIncrementButtonDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-increment-button-disabled-skin""), STEPPER_INCREMENT_BUTTON_SCALE_9_GRID); this.stepperDecrementButtonUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-decrement-button-up-skin""), STEPPER_DECREMENT_BUTTON_SCALE_9_GRID); this.stepperDecrementButtonHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-decrement-button-hover-skin""), STEPPER_DECREMENT_BUTTON_SCALE_9_GRID); this.stepperDecrementButtonDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-decrement-button-down-skin""), STEPPER_DECREMENT_BUTTON_SCALE_9_GRID); this.stepperDecrementButtonDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""numeric-stepper-decrement-button-disabled-skin""), STEPPER_DECREMENT_BUTTON_SCALE_9_GRID); this.hSliderThumbUpSkinTexture = this.atlas.getTexture(""hslider-thumb-up-skin""); this.hSliderThumbHoverSkinTexture = this.atlas.getTexture(""hslider-thumb-hover-skin""); this.hSliderThumbDownSkinTexture = this.atlas.getTexture(""hslider-thumb-down-skin""); this.hSliderThumbDisabledSkinTexture = this.atlas.getTexture(""hslider-thumb-disabled-skin""); this.hSliderTrackSkinTextures = new Scale3Textures(this.atlas.getTexture(""hslider-track-skin""), HSLIDER_FIRST_REGION, HSLIDER_SECOND_REGION, Scale3Textures.DIRECTION_HORIZONTAL); this.vSliderThumbUpSkinTexture = this.atlas.getTexture(""vslider-thumb-up-skin""); this.vSliderThumbHoverSkinTexture = this.atlas.getTexture(""vslider-thumb-hover-skin""); this.vSliderThumbDownSkinTexture = this.atlas.getTexture(""vslider-thumb-down-skin""); this.vSliderThumbDisabledSkinTexture = this.atlas.getTexture(""vslider-thumb-disabled-skin""); this.vSliderTrackSkinTextures = new Scale3Textures(this.atlas.getTexture(""vslider-track-skin""), HSLIDER_FIRST_REGION, HSLIDER_SECOND_REGION, Scale3Textures.DIRECTION_VERTICAL); this.itemRendererUpSkinTexture = this.atlas.getTexture(""item-renderer-up-skin""); this.itemRendererHoverSkinTexture = this.atlas.getTexture(""item-renderer-hover-skin""); this.itemRendererSelectedUpSkinTexture = this.atlas.getTexture(""item-renderer-selected-up-skin""); this.headerBackgroundSkinTextures = new Scale9Textures(this.atlas.getTexture(""header-background-skin""), HEADER_SCALE_9_GRID); this.groupedListHeaderBackgroundSkinTextures = new Scale9Textures(this.atlas.getTexture(""grouped-list-header-background-skin""), HEADER_SCALE_9_GRID); this.checkUpIconTexture = this.atlas.getTexture(""check-up-icon""); this.checkHoverIconTexture = this.atlas.getTexture(""check-hover-icon""); this.checkDownIconTexture = this.atlas.getTexture(""check-down-icon""); this.checkDisabledIconTexture = this.atlas.getTexture(""check-disabled-icon""); this.checkSelectedUpIconTexture = this.atlas.getTexture(""check-selected-up-icon""); this.checkSelectedHoverIconTexture = this.atlas.getTexture(""check-selected-hover-icon""); this.checkSelectedDownIconTexture = this.atlas.getTexture(""check-selected-down-icon""); this.checkSelectedDisabledIconTexture = this.atlas.getTexture(""check-selected-disabled-icon""); this.radioUpIconTexture = this.atlas.getTexture(""radio-up-icon""); this.radioHoverIconTexture = this.atlas.getTexture(""radio-hover-icon""); this.radioDownIconTexture = this.atlas.getTexture(""radio-down-icon""); this.radioDisabledIconTexture = this.atlas.getTexture(""radio-disabled-icon""); this.radioSelectedUpIconTexture = this.atlas.getTexture(""radio-selected-up-icon""); this.radioSelectedHoverIconTexture = this.atlas.getTexture(""radio-selected-hover-icon""); this.radioSelectedDownIconTexture = this.atlas.getTexture(""radio-selected-down-icon""); this.radioSelectedDisabledIconTexture = this.atlas.getTexture(""radio-selected-disabled-icon""); this.pageIndicatorNormalSkinTexture = this.atlas.getTexture(""page-indicator-normal-skin""); this.pageIndicatorSelectedSkinTexture = this.atlas.getTexture(""page-indicator-selected-skin""); this.pickerListUpIconTexture = this.atlas.getTexture(""picker-list-up-icon""); this.pickerListHoverIconTexture = this.atlas.getTexture(""picker-list-hover-icon""); this.pickerListDownIconTexture = this.atlas.getTexture(""picker-list-down-icon""); this.pickerListDisabledIconTexture = this.atlas.getTexture(""picker-list-disabled-icon""); this.textInputBackgroundSkinTextures = new Scale9Textures(this.atlas.getTexture(""text-input-background-skin""), TEXT_INPUT_SCALE_9_GRID); this.textInputBackgroundDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""text-input-background-disabled-skin""), TEXT_INPUT_SCALE_9_GRID); this.textInputSearchIconTexture = this.atlas.getTexture(""search-icon""); this.vScrollBarThumbUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-thumb-up-skin""), VERTICAL_SCROLL_BAR_THUMB_SCALE_9_GRID); this.vScrollBarThumbHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-thumb-hover-skin""), VERTICAL_SCROLL_BAR_THUMB_SCALE_9_GRID); this.vScrollBarThumbDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-thumb-down-skin""), VERTICAL_SCROLL_BAR_THUMB_SCALE_9_GRID); this.vScrollBarTrackSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-track-skin""), VERTICAL_SCROLL_BAR_TRACK_SCALE_9_GRID); this.vScrollBarThumbIconTexture = this.atlas.getTexture(""vertical-scroll-bar-thumb-icon""); this.vScrollBarStepButtonUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-step-button-up-skin""), VERTICAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.vScrollBarStepButtonHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-step-button-hover-skin""), VERTICAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.vScrollBarStepButtonDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-step-button-down-skin""), VERTICAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.vScrollBarStepButtonDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""vertical-scroll-bar-step-button-disabled-skin""), VERTICAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.vScrollBarDecrementButtonIconTexture = this.atlas.getTexture(""vertical-scroll-bar-decrement-button-icon""); this.vScrollBarIncrementButtonIconTexture = this.atlas.getTexture(""vertical-scroll-bar-increment-button-icon""); this.hScrollBarThumbUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-thumb-up-skin""), HORIZONTAL_SCROLL_BAR_THUMB_SCALE_9_GRID); this.hScrollBarThumbHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-thumb-hover-skin""), HORIZONTAL_SCROLL_BAR_THUMB_SCALE_9_GRID); this.hScrollBarThumbDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-thumb-down-skin""), HORIZONTAL_SCROLL_BAR_THUMB_SCALE_9_GRID); this.hScrollBarTrackSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-track-skin""), HORIZONTAL_SCROLL_BAR_TRACK_SCALE_9_GRID); this.hScrollBarThumbIconTexture = this.atlas.getTexture(""horizontal-scroll-bar-thumb-icon""); this.hScrollBarStepButtonUpSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-step-button-up-skin""), HORIZONTAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.hScrollBarStepButtonHoverSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-step-button-hover-skin""), HORIZONTAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.hScrollBarStepButtonDownSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-step-button-down-skin""), HORIZONTAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.hScrollBarStepButtonDisabledSkinTextures = new Scale9Textures(this.atlas.getTexture(""horizontal-scroll-bar-step-button-disabled-skin""), HORIZONTAL_SCROLL_BAR_STEP_BUTTON_SCALE_9_GRID); this.hScrollBarDecrementButtonIconTexture = this.atlas.getTexture(""horizontal-scroll-bar-decrement-button-icon""); this.hScrollBarIncrementButtonIconTexture = this.atlas.getTexture(""horizontal-scroll-bar-increment-button-icon""); this.simpleBorderBackgroundSkinTextures = new Scale9Textures(this.atlas.getTexture(""simple-border-background-skin""), SIMPLE_BORDER_SCALE_9_GRID); this.panelBorderBackgroundSkinTextures = new Scale9Textures(this.atlas.getTexture(""panel-background-skin""), PANEL_BORDER_SCALE_9_GRID); this.progressBarFillSkinTexture = this.atlas.getTexture(""progress-bar-fill-skin""); StandardIcons.listDrillDownAccessoryTexture = this.atlas.getTexture(""list-accessory-drill-down-icon""); } protected function initializeStyleProviders():void { //alert this.getStyleProviderForClass(Alert).defaultStyleFunction = this.setAlertStyles; this.getStyleProviderForClass(Header).setFunctionForStyleName(Alert.DEFAULT_CHILD_NAME_HEADER, this.setPanelHeaderStyles); this.getStyleProviderForClass(ButtonGroup).setFunctionForStyleName(Alert.DEFAULT_CHILD_NAME_BUTTON_GROUP, this.setAlertButtonGroupStyles); this.getStyleProviderForClass(TextFieldTextRenderer).setFunctionForStyleName(Alert.DEFAULT_CHILD_NAME_MESSAGE, this.setAlertMessageTextRendererStyles); //button this.getStyleProviderForClass(Button).defaultStyleFunction = this.setButtonStyles; this.getStyleProviderForClass(Button).setFunctionForStyleName(Button.ALTERNATE_NAME_QUIET_BUTTON, this.setQuietButtonStyles); //button group this.getStyleProviderForClass(ButtonGroup).defaultStyleFunction = this.setButtonGroupStyles; //callout this.getStyleProviderForClass(Callout).defaultStyleFunction = this.setCalloutStyles; //check this.getStyleProviderForClass(Check).defaultStyleFunction = this.setCheckStyles; //drawers this.getStyleProviderForClass(Drawers).defaultStyleFunction = this.setDrawersStyles; //grouped list (see also: item renderers) this.getStyleProviderForClass(GroupedList).defaultStyleFunction = this.setGroupedListStyles; this.getStyleProviderForClass(GroupedList).setFunctionForStyleName(GroupedList.ALTERNATE_NAME_INSET_GROUPED_LIST, this.setInsetGroupedListStyles); //header this.getStyleProviderForClass(Header).defaultStyleFunction = this.setHeaderStyles; //item renderers for lists this.getStyleProviderForClass(DefaultListItemRenderer).defaultStyleFunction = this.setItemRendererStyles; this.getStyleProviderForClass(DefaultGroupedListItemRenderer).defaultStyleFunction = this.setItemRendererStyles; this.getStyleProviderForClass(TextFieldTextRenderer).setFunctionForStyleName(BaseDefaultItemRenderer.DEFAULT_CHILD_NAME_ACCESSORY_LABEL, this.setItemRendererAccessoryLabelStyles); this.getStyleProviderForClass(TextFieldTextRenderer).setFunctionForStyleName(BaseDefaultItemRenderer.DEFAULT_CHILD_NAME_ICON_LABEL, this.setItemRendererIconLabelStyles); //header and footer renderers for grouped list this.getStyleProviderForClass(DefaultGroupedListHeaderOrFooterRenderer).defaultStyleFunction = this.setGroupedListHeaderOrFooterRendererStyles; this.getStyleProviderForClass(DefaultGroupedListHeaderOrFooterRenderer).setFunctionForStyleName(GroupedList.ALTERNATE_CHILD_NAME_INSET_HEADER_RENDERER, this.setInsetGroupedListHeaderOrFooterRendererStyles); //label this.getStyleProviderForClass(Label).defaultStyleFunction = this.setLabelStyles; this.getStyleProviderForClass(Label).setFunctionForStyleName(Label.ALTERNATE_NAME_HEADING, this.setHeadingLabelStyles); this.getStyleProviderForClass(Label).setFunctionForStyleName(Label.ALTERNATE_NAME_DETAIL, this.setDetailLabelStyles); //list (see also: item renderers) this.getStyleProviderForClass(List).defaultStyleFunction = this.setListStyles; //numeric stepper this.getStyleProviderForClass(NumericStepper).defaultStyleFunction = this.setNumericStepperStyles; this.getStyleProviderForClass(TextInput).setFunctionForStyleName(NumericStepper.DEFAULT_CHILD_NAME_TEXT_INPUT, this.setNumericStepperTextInputStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(NumericStepper.DEFAULT_CHILD_NAME_INCREMENT_BUTTON, this.setNumericStepperIncrementButtonStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(NumericStepper.DEFAULT_CHILD_NAME_DECREMENT_BUTTON, this.setNumericStepperDecrementButtonStyles); //panel this.getStyleProviderForClass(Panel).defaultStyleFunction = this.setPanelStyles; this.getStyleProviderForClass(Header).setFunctionForStyleName(Panel.DEFAULT_CHILD_NAME_HEADER, this.setPanelHeaderStyles); //panel screen this.getStyleProviderForClass(PanelScreen).defaultStyleFunction = this.setPanelScreenStyles; //page indicator this.getStyleProviderForClass(PageIndicator).defaultStyleFunction = this.setPageIndicatorStyles; //picker list (see also: item renderers) this.getStyleProviderForClass(PickerList).defaultStyleFunction = this.setPickerListStyles; this.getStyleProviderForClass(List).setFunctionForStyleName(PickerList.DEFAULT_CHILD_NAME_LIST, this.setPickerListListStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(PickerList.DEFAULT_CHILD_NAME_BUTTON, this.setPickerListButtonStyles); //progress bar this.getStyleProviderForClass(ProgressBar).defaultStyleFunction = this.setProgressBarStyles; //radio this.getStyleProviderForClass(Radio).defaultStyleFunction = this.setRadioStyles; //screen this.getStyleProviderForClass(Screen).defaultStyleFunction = this.setScreenStyles; //scroll bar this.getStyleProviderForClass(ScrollBar).setFunctionForStyleName(Scroller.DEFAULT_CHILD_NAME_HORIZONTAL_SCROLL_BAR, this.setHorizontalScrollBarStyles); this.getStyleProviderForClass(ScrollBar).setFunctionForStyleName(Scroller.DEFAULT_CHILD_NAME_VERTICAL_SCROLL_BAR, this.setVerticalScrollBarStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_HORIZONTAL_SCROLL_BAR_INCREMENT_BUTTON, this.setHorizontalScrollBarIncrementButtonStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_HORIZONTAL_SCROLL_BAR_DECREMENT_BUTTON, this.setHorizontalScrollBarDecrementButtonStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_HORIZONTAL_SCROLL_BAR_THUMB, this.setHorizontalScrollBarThumbStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_HORIZONTAL_SCROLL_BAR_MINIMUM_TRACK, this.setHorizontalScrollBarMinimumTrackStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_VERTICAL_SCROLL_BAR_INCREMENT_BUTTON, this.setVerticalScrollBarIncrementButtonStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_VERTICAL_SCROLL_BAR_DECREMENT_BUTTON, this.setVerticalScrollBarDecrementButtonStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_VERTICAL_SCROLL_BAR_THUMB, this.setVerticalScrollBarThumbStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_VERTICAL_SCROLL_BAR_MINIMUM_TRACK, this.setVerticalScrollBarMinimumTrackStyles); //scroll container this.getStyleProviderForClass(ScrollContainer).defaultStyleFunction = this.setScrollContainerStyles; this.getStyleProviderForClass(ScrollContainer).setFunctionForStyleName(ScrollContainer.ALTERNATE_NAME_TOOLBAR, this.setToolbarScrollContainerStyles); //scroll screen this.getStyleProviderForClass(ScrollScreen).defaultStyleFunction = this.setScrollScreenStyles; //scroll text this.getStyleProviderForClass(ScrollText).defaultStyleFunction = this.setScrollTextStyles; //simple scroll bar this.getStyleProviderForClass(SimpleScrollBar).setFunctionForStyleName(Scroller.DEFAULT_CHILD_NAME_HORIZONTAL_SCROLL_BAR, this.setHorizontalSimpleScrollBarStyles); this.getStyleProviderForClass(SimpleScrollBar).setFunctionForStyleName(Scroller.DEFAULT_CHILD_NAME_VERTICAL_SCROLL_BAR, this.setVerticalSimpleScrollBarStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_HORIZONTAL_SIMPLE_SCROLL_BAR_THUMB, this.setHorizontalSimpleScrollBarThumbStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_VERTICAL_SIMPLE_SCROLL_BAR_THUMB, this.setVerticalSimpleScrollBarThumbStyles); //slider this.getStyleProviderForClass(Slider).defaultStyleFunction = this.setSliderStyles; this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_HORIZONTAL_SLIDER_THUMB, this.setHorizontalSliderThumbStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_HORIZONTAL_SLIDER_MINIMUM_TRACK, this.setHorizontalSliderMinimumTrackStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_VERTICAL_SLIDER_THUMB, this.setVerticalSliderThumbStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(THEME_NAME_VERTICAL_SLIDER_MINIMUM_TRACK, this.setVerticalSliderMinimumTrackStyles); //tab bar this.getStyleProviderForClass(TabBar).defaultStyleFunction = this.setTabBarStyles; this.getStyleProviderForClass(Button).setFunctionForStyleName(TabBar.DEFAULT_CHILD_NAME_TAB, this.setTabStyles); //text area this.getStyleProviderForClass(TextArea).defaultStyleFunction = this.setTextAreaStyles; //text input this.getStyleProviderForClass(TextInput).defaultStyleFunction = this.setTextInputStyles; this.getStyleProviderForClass(TextInput).setFunctionForStyleName(TextInput.ALTERNATE_NAME_SEARCH_TEXT_INPUT, this.setSearchTextInputStyles); //toggle switch this.getStyleProviderForClass(ToggleSwitch).defaultStyleFunction = this.setToggleSwitchStyles; this.getStyleProviderForClass(Button).setFunctionForStyleName(ToggleSwitch.DEFAULT_CHILD_NAME_ON_TRACK, this.setToggleSwitchOnTrackStyles); this.getStyleProviderForClass(Button).setFunctionForStyleName(ToggleSwitch.DEFAULT_CHILD_NAME_THUMB, this.setToggleSwitchThumbStyles); } protected function pageIndicatorNormalSymbolFactory():Image { return new Image(this.pageIndicatorNormalSkinTexture); } protected function pageIndicatorSelectedSymbolFactory():Image { return new Image(this.pageIndicatorSelectedSkinTexture); } //------------------------- // Shared //------------------------- protected function setScrollerStyles(scroller:Scroller):void { scroller.clipContent = true; scroller.horizontalScrollBarFactory = scrollBarFactory; scroller.verticalScrollBarFactory = scrollBarFactory; scroller.interactionMode = ScrollContainer.INTERACTION_MODE_MOUSE; scroller.scrollBarDisplayMode = ScrollContainer.SCROLL_BAR_DISPLAY_MODE_FIXED; } //------------------------- // Alert //------------------------- protected function setAlertStyles(alert:Alert):void { this.setScrollerStyles(alert); alert.backgroundSkin = new Scale9Image(panelBorderBackgroundSkinTextures); alert.paddingTop = 0; alert.paddingRight = 14; alert.paddingBottom = 0; alert.paddingLeft = 14; alert.gap = 12; alert.maxWidth = alert.maxHeight = 300; } protected function setAlertButtonGroupStyles(group:ButtonGroup):void { group.direction = ButtonGroup.DIRECTION_HORIZONTAL; group.horizontalAlign = ButtonGroup.HORIZONTAL_ALIGN_CENTER; group.verticalAlign = ButtonGroup.VERTICAL_ALIGN_JUSTIFY; group.gap = 4; group.paddingTop = 12; group.paddingRight = 12; group.paddingBottom = 12; group.paddingLeft = 12; } protected function setAlertMessageTextRendererStyles(renderer:TextFieldTextRenderer):void { renderer.textFormat = this.defaultTextFormat; renderer.wordWrap = true; } //------------------------- // Button //------------------------- protected function setBaseButtonStyles(button:Button):void { button.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); button.focusPadding = -1; button.defaultLabelProperties.textFormat = this.defaultTextFormat; button.disabledLabelProperties.textFormat = this.disabledTextFormat; button.paddingTop = button.paddingBottom = 2; button.paddingLeft = button.paddingRight = 10; button.gap = 2; button.minGap = 2; button.minWidth = button.minHeight = 12; } protected function setButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.buttonUpSkinTextures; skinSelector.defaultSelectedValue = this.buttonSelectedUpSkinTextures; skinSelector.setValueForState(this.buttonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.buttonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.buttonDisabledSkinTextures, Button.STATE_DISABLED, false); skinSelector.setValueForState(this.buttonSelectedHoverSkinTextures, Button.STATE_HOVER, true); skinSelector.setValueForState(this.buttonSelectedDownSkinTextures, Button.STATE_DOWN, true); skinSelector.setValueForState(this.buttonSelectedDisabledSkinTextures, Button.STATE_DISABLED, true); button.stateToSkinFunction = skinSelector.updateValue; this.setBaseButtonStyles(button); } protected function setQuietButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = null; skinSelector.defaultSelectedValue = this.buttonSelectedUpSkinTextures; skinSelector.setValueForState(this.buttonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.buttonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.buttonDisabledSkinTextures, Button.STATE_DISABLED, false); skinSelector.setValueForState(this.buttonSelectedHoverSkinTextures, Button.STATE_HOVER, true); skinSelector.setValueForState(this.buttonSelectedDownSkinTextures, Button.STATE_DOWN, true); skinSelector.setValueForState(this.buttonSelectedDisabledSkinTextures, Button.STATE_DISABLED, true); button.stateToSkinFunction = skinSelector.updateValue; this.setBaseButtonStyles(button); } //------------------------- // ButtonGroup //------------------------- protected function setButtonGroupStyles(group:ButtonGroup):void { group.gap = 4; } //------------------------- // Callout //------------------------- protected function setCalloutStyles(callout:Callout):void { callout.backgroundSkin = new Scale9Image(panelBorderBackgroundSkinTextures); var arrowSkin:Quad = new Quad(8, 8, 0xff00ff); arrowSkin.alpha = 0; callout.topArrowSkin = callout.rightArrowSkin = callout.bottomArrowSkin = callout.leftArrowSkin = arrowSkin; callout.paddingTop = callout.paddingBottom = 6; callout.paddingRight = callout.paddingLeft = 10; } //------------------------- // Check //------------------------- protected function setCheckStyles(check:Check):void { var iconSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); iconSelector.setValueTypeHandler(SubTexture, textureValueTypeHandler); iconSelector.defaultValue = this.checkUpIconTexture; iconSelector.defaultSelectedValue = this.checkSelectedUpIconTexture; iconSelector.setValueForState(this.checkHoverIconTexture, Button.STATE_HOVER, false); iconSelector.setValueForState(this.checkDownIconTexture, Button.STATE_DOWN, false); iconSelector.setValueForState(this.checkDisabledIconTexture, Button.STATE_DISABLED, false); iconSelector.setValueForState(this.checkSelectedHoverIconTexture, Button.STATE_HOVER, true); iconSelector.setValueForState(this.checkSelectedDownIconTexture, Button.STATE_DOWN, true); iconSelector.setValueForState(this.checkSelectedDisabledIconTexture, Button.STATE_DISABLED, true); iconSelector.displayObjectProperties = { snapToPixels: true }; check.stateToIconFunction = iconSelector.updateValue; check.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); check.focusPadding = -2; check.defaultLabelProperties.textFormat = this.defaultTextFormat; check.disabledLabelProperties.textFormat = this.disabledTextFormat; check.horizontalAlign = Button.HORIZONTAL_ALIGN_LEFT; check.verticalAlign = Button.VERTICAL_ALIGN_MIDDLE; check.gap = 4; } //------------------------- // Drawers //------------------------- protected function setDrawersStyles(drawers:Drawers):void { var overlaySkin:Quad = new Quad(10, 10, MODAL_OVERLAY_COLOR); overlaySkin.alpha = MODAL_OVERLAY_ALPHA; drawers.overlaySkin = overlaySkin; } //------------------------- // GroupedList //------------------------- protected function setGroupedListStyles(list:GroupedList):void { this.setScrollerStyles(list); list.verticalScrollPolicy = GroupedList.SCROLL_POLICY_AUTO; list.backgroundSkin = new Scale9Image(simpleBorderBackgroundSkinTextures); list.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); list.focusPadding = -1; list.paddingTop = list.paddingRight = list.paddingBottom = list.paddingLeft = 1; } //see List section for item renderer styles protected function setGroupedListHeaderOrFooterRendererStyles(renderer:DefaultGroupedListHeaderOrFooterRenderer):void { renderer.backgroundSkin = new Scale9Image(groupedListHeaderBackgroundSkinTextures); renderer.backgroundSkin.height = 18; renderer.contentLabelProperties.textFormat = this.defaultTextFormat; renderer.paddingTop = renderer.paddingBottom = 2; renderer.paddingRight = renderer.paddingLeft = 6; renderer.minWidth = renderer.minHeight = 18; } protected function setInsetGroupedListStyles(list:GroupedList):void { this.setScrollerStyles(list); list.verticalScrollPolicy = GroupedList.SCROLL_POLICY_AUTO; list.headerRendererName = GroupedList.ALTERNATE_CHILD_NAME_INSET_HEADER_RENDERER; list.footerRendererName = GroupedList.ALTERNATE_CHILD_NAME_INSET_FOOTER_RENDERER; var layout:VerticalLayout = new VerticalLayout(); layout.useVirtualLayout = true; layout.padding = 10; layout.paddingTop = 0; layout.gap = 0; layout.horizontalAlign = VerticalLayout.HORIZONTAL_ALIGN_JUSTIFY; layout.verticalAlign = VerticalLayout.VERTICAL_ALIGN_TOP; list.layout = layout; } protected function setInsetGroupedListHeaderOrFooterRendererStyles(renderer:DefaultGroupedListHeaderOrFooterRenderer):void { renderer.contentLabelProperties.textFormat = this.defaultTextFormat; renderer.paddingTop = 8; renderer.paddingBottom = 2; renderer.paddingRight = renderer.paddingLeft = 6; renderer.minWidth = renderer.minHeight = 18; } //------------------------- // Header //------------------------- protected function setHeaderStyles(header:Header):void { header.backgroundSkin = new Scale9Image(headerBackgroundSkinTextures); header.minHeight = 22; header.titleProperties.textFormat = this.headerTitleTextFormat; header.paddingTop = header.paddingBottom = 4; header.paddingRight = header.paddingLeft = 6; header.gap = 2; header.titleGap = 4; } //------------------------- // Label //------------------------- protected function setLabelStyles(label:Label):void { label.textRendererProperties.textFormat = this.defaultTextFormat; label.textRendererProperties.disabledTextFormat = this.disabledTextFormat; } protected function setHeadingLabelStyles(label:Label):void { label.textRendererProperties.textFormat = this.headingTextFormat; label.textRendererProperties.disabledTextFormat = this.headingDisabledTextFormat; } protected function setDetailLabelStyles(label:Label):void { label.textRendererProperties.textFormat = this.detailTextFormat; label.textRendererProperties.disabledTextFormat = this.detailDisabledTextFormat; } //------------------------- // List //------------------------- protected function setListStyles(list:List):void { this.setScrollerStyles(list); list.verticalScrollPolicy = List.SCROLL_POLICY_AUTO; list.backgroundSkin = new Scale9Image(simpleBorderBackgroundSkinTextures); list.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); list.focusPadding = -1; list.paddingTop = list.paddingRight = list.paddingBottom = list.paddingLeft = 1; } protected function setItemRendererStyles(renderer:BaseDefaultItemRenderer):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.itemRendererUpSkinTexture; skinSelector.defaultSelectedValue = this.itemRendererSelectedUpSkinTexture; skinSelector.setValueForState(this.itemRendererHoverSkinTexture, Button.STATE_HOVER, false); skinSelector.setValueForState(this.itemRendererSelectedUpSkinTexture, Button.STATE_DOWN, false); renderer.stateToSkinFunction = skinSelector.updateValue; renderer.defaultLabelProperties.textFormat = this.defaultTextFormat; renderer.disabledLabelProperties.textFormat = this.disabledTextFormat; renderer.horizontalAlign = Button.HORIZONTAL_ALIGN_LEFT; renderer.iconPosition = Button.ICON_POSITION_LEFT; renderer.accessoryPosition = BaseDefaultItemRenderer.ACCESSORY_POSITION_RIGHT; renderer.paddingTop = renderer.paddingBottom = 2; renderer.paddingRight = renderer.paddingLeft = 6; renderer.gap = 2; renderer.minGap = 2; renderer.accessoryGap = Number.POSITIVE_INFINITY; renderer.minAccessoryGap = 2; renderer.minWidth = renderer.minHeight = 22; } protected function setItemRendererAccessoryLabelStyles(renderer:TextFieldTextRenderer):void { renderer.textFormat = this.defaultTextFormat; } protected function setItemRendererIconLabelStyles(renderer:TextFieldTextRenderer):void { renderer.textFormat = this.defaultTextFormat; } //------------------------- // NumericStepper //------------------------- protected function setNumericStepperStyles(stepper:NumericStepper):void { stepper.buttonLayoutMode = NumericStepper.BUTTON_LAYOUT_MODE_RIGHT_SIDE_VERTICAL; stepper.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); stepper.focusPadding = -1; } protected function setNumericStepperIncrementButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.stepperIncrementButtonUpSkinTextures; skinSelector.setValueForState(this.stepperIncrementButtonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.stepperIncrementButtonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.stepperIncrementButtonDisabledSkinTextures, Button.STATE_DISABLED, false); button.stateToSkinFunction = skinSelector.updateValue; } protected function setNumericStepperDecrementButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.stepperDecrementButtonUpSkinTextures; skinSelector.setValueForState(this.stepperDecrementButtonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.stepperDecrementButtonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.stepperDecrementButtonDisabledSkinTextures, Button.STATE_DISABLED, false); button.stateToSkinFunction = skinSelector.updateValue; } protected function setNumericStepperTextInputStyles(input:TextInput):void { input.minWidth = input.minHeight = 22; input.gap = 2; input.paddingTop = input.paddingBottom = 2; input.paddingRight = input.paddingLeft = 4; input.textEditorProperties.textFormat = this.defaultTextFormat; var backgroundSkin:Scale9Image = new Scale9Image(textInputBackgroundSkinTextures); backgroundSkin.width = backgroundSkin.height; input.backgroundSkin = backgroundSkin; var backgroundDisabledSkin:Scale9Image = new Scale9Image(textInputBackgroundDisabledSkinTextures); backgroundDisabledSkin.width = backgroundDisabledSkin.height; input.backgroundDisabledSkin = backgroundDisabledSkin; } //------------------------- // PageIndicator //------------------------- protected function setPageIndicatorStyles(pageIndicator:PageIndicator):void { pageIndicator.interactionMode = PageIndicator.INTERACTION_MODE_PRECISE; pageIndicator.normalSymbolFactory = this.pageIndicatorNormalSymbolFactory; pageIndicator.selectedSymbolFactory = this.pageIndicatorSelectedSymbolFactory; pageIndicator.gap = 12; pageIndicator.paddingTop = pageIndicator.paddingRight = pageIndicator.paddingBottom = pageIndicator.paddingLeft = 12; pageIndicator.minTouchWidth = pageIndicator.minTouchHeight = 12; } //------------------------- // Panel //------------------------- protected function setPanelStyles(panel:Panel):void { this.setScrollerStyles(panel); panel.backgroundSkin = new Scale9Image(panelBorderBackgroundSkinTextures); panel.paddingTop = 0; panel.paddingRight = 10; panel.paddingBottom = 10; panel.paddingLeft = 10; } protected function setPanelHeaderStyles(header:Header):void { header.titleProperties.textFormat = this.headerTitleTextFormat; header.minHeight = 22; header.paddingTop = header.paddingBottom = 6; header.paddingRight = header.paddingLeft = 6; header.gap = 2; header.titleGap = 4; } //------------------------- // PanelScreen //------------------------- protected function setPanelScreenStyles(screen:PanelScreen):void { this.setScrollerStyles(screen); screen.originalDPI = this.originalDPI; } //------------------------- // PickerList //------------------------- protected function setPickerListStyles(list:PickerList):void { list.popUpContentManager = new DropDownPopUpContentManager(); } protected function setPickerListListStyles(list:List):void { this.setListStyles(list); list.maxHeight = 110; } protected function setPickerListButtonStyles(button:Button):void { this.setButtonStyles(button); var iconSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); iconSelector.defaultValue = this.pickerListUpIconTexture; iconSelector.setValueForState(this.pickerListHoverIconTexture, Button.STATE_HOVER, false); iconSelector.setValueForState(this.pickerListDownIconTexture, Button.STATE_DOWN, false); iconSelector.setValueForState(this.pickerListDisabledIconTexture, Button.STATE_DISABLED, false); button.stateToIconFunction = iconSelector.updateValue; button.gap = Number.POSITIVE_INFINITY; //fill as completely as possible button.minGap = 10; button.horizontalAlign = Button.HORIZONTAL_ALIGN_LEFT; button.iconPosition = Button.ICON_POSITION_RIGHT; button.paddingRight = 6; } //------------------------- // ProgressBar //------------------------- protected function setProgressBarStyles(progress:ProgressBar):void { var backgroundSkin:Scale9Image = new Scale9Image(simpleBorderBackgroundSkinTextures); if(progress.direction == ProgressBar.DIRECTION_VERTICAL) { backgroundSkin.height = backgroundSkin.width * 30; } else { backgroundSkin.width = backgroundSkin.height * 30; } progress.backgroundSkin = backgroundSkin; var fillSkin:Image = new Image(progressBarFillSkinTexture); if(progress.direction == ProgressBar.DIRECTION_VERTICAL) { fillSkin.height = 0; } else { fillSkin.width = 0; } progress.fillSkin = fillSkin; progress.paddingTop = progress.paddingRight = progress.paddingBottom = progress.paddingLeft = 1; } //------------------------- // Radio //------------------------- protected function setRadioStyles(radio:Radio):void { var iconSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); iconSelector.defaultValue = this.radioUpIconTexture; iconSelector.defaultSelectedValue = this.radioSelectedUpIconTexture; iconSelector.setValueForState(this.radioHoverIconTexture, Button.STATE_HOVER, false); iconSelector.setValueForState(this.radioDownIconTexture, Button.STATE_DOWN, false); iconSelector.setValueForState(this.radioDisabledIconTexture, Button.STATE_DISABLED, false); iconSelector.setValueForState(this.radioSelectedHoverIconTexture, Button.STATE_HOVER, true); iconSelector.setValueForState(this.radioSelectedDownIconTexture, Button.STATE_DOWN, true); iconSelector.setValueForState(this.radioSelectedDisabledIconTexture, Button.STATE_DISABLED, true); radio.stateToIconFunction = iconSelector.updateValue; radio.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); radio.focusPadding = -2; radio.defaultLabelProperties.textFormat = this.defaultTextFormat; radio.disabledLabelProperties.textFormat = this.disabledTextFormat; radio.horizontalAlign = Button.HORIZONTAL_ALIGN_LEFT; radio.verticalAlign = Button.VERTICAL_ALIGN_MIDDLE; radio.gap = 4; } //------------------------- // Screen //------------------------- protected function setScreenStyles(screen:Screen):void { screen.originalDPI = this.originalDPI; } //------------------------- // ScrollBar //------------------------- protected function setHorizontalScrollBarStyles(scrollBar:ScrollBar):void { scrollBar.direction = ScrollBar.DIRECTION_HORIZONTAL; scrollBar.trackLayoutMode = ScrollBar.TRACK_LAYOUT_MODE_SINGLE; scrollBar.customIncrementButtonName = THEME_NAME_HORIZONTAL_SCROLL_BAR_INCREMENT_BUTTON; scrollBar.customDecrementButtonName = THEME_NAME_HORIZONTAL_SCROLL_BAR_DECREMENT_BUTTON; scrollBar.customThumbName = THEME_NAME_HORIZONTAL_SCROLL_BAR_THUMB; scrollBar.customMinimumTrackName = THEME_NAME_HORIZONTAL_SCROLL_BAR_MINIMUM_TRACK; } protected function setVerticalScrollBarStyles(scrollBar:ScrollBar):void { scrollBar.direction = ScrollBar.DIRECTION_VERTICAL; scrollBar.trackLayoutMode = ScrollBar.TRACK_LAYOUT_MODE_SINGLE; scrollBar.customIncrementButtonName = THEME_NAME_VERTICAL_SCROLL_BAR_INCREMENT_BUTTON; scrollBar.customDecrementButtonName = THEME_NAME_VERTICAL_SCROLL_BAR_DECREMENT_BUTTON; scrollBar.customThumbName = THEME_NAME_VERTICAL_SCROLL_BAR_THUMB; scrollBar.customMinimumTrackName = THEME_NAME_VERTICAL_SCROLL_BAR_MINIMUM_TRACK; } protected function setHorizontalScrollBarIncrementButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.hScrollBarStepButtonUpSkinTextures; skinSelector.setValueForState(this.hScrollBarStepButtonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.hScrollBarStepButtonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.hScrollBarStepButtonDisabledSkinTextures, Button.STATE_DISABLED, false); button.stateToSkinFunction = skinSelector.updateValue; button.defaultIcon = new Image(this.hScrollBarIncrementButtonIconTexture); var incrementButtonDisabledIcon:Quad = new Quad(1, 1, 0xff00ff); incrementButtonDisabledIcon.alpha = 0; button.disabledIcon = incrementButtonDisabledIcon; } protected function setHorizontalScrollBarDecrementButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = hScrollBarStepButtonUpSkinTextures; skinSelector.setValueForState(this.hScrollBarStepButtonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.hScrollBarStepButtonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.hScrollBarStepButtonDisabledSkinTextures, Button.STATE_DISABLED, false); button.stateToSkinFunction = skinSelector.updateValue; button.defaultIcon = new Image(this.hScrollBarDecrementButtonIconTexture); var decrementButtonDisabledIcon:Quad = new Quad(1, 1, 0xff00ff); decrementButtonDisabledIcon.alpha = 0; button.disabledIcon = decrementButtonDisabledIcon; } protected function setHorizontalScrollBarThumbStyles(thumb:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.hScrollBarThumbUpSkinTextures; skinSelector.setValueForState(this.hScrollBarThumbHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.hScrollBarThumbDownSkinTextures, Button.STATE_DOWN, false); thumb.stateToSkinFunction = skinSelector.updateValue; thumb.defaultIcon = new Image(this.hScrollBarThumbIconTexture); thumb.verticalAlign = Button.VERTICAL_ALIGN_TOP; thumb.paddingTop = 4; } protected function setHorizontalScrollBarMinimumTrackStyles(track:Button):void { track.defaultSkin = new Scale9Image(this.hScrollBarTrackSkinTextures); } protected function setVerticalScrollBarIncrementButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.vScrollBarStepButtonUpSkinTextures; skinSelector.setValueForState(this.vScrollBarStepButtonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.vScrollBarStepButtonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.vScrollBarStepButtonDisabledSkinTextures, Button.STATE_DISABLED, false); button.stateToSkinFunction = skinSelector.updateValue; button.defaultIcon = new Image(this.vScrollBarIncrementButtonIconTexture); var incrementButtonDisabledIcon:Quad = new Quad(1, 1, 0xff00ff); incrementButtonDisabledIcon.alpha = 0; button.disabledIcon = incrementButtonDisabledIcon; } protected function setVerticalScrollBarDecrementButtonStyles(button:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.vScrollBarStepButtonUpSkinTextures; skinSelector.setValueForState(this.vScrollBarStepButtonHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.vScrollBarStepButtonDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.vScrollBarStepButtonDisabledSkinTextures, Button.STATE_DISABLED, false); button.stateToSkinFunction = skinSelector.updateValue; button.defaultIcon = new Image(this.vScrollBarDecrementButtonIconTexture); var decrementButtonDisabledIcon:Quad = new Quad(1, 1, 0xff00ff); decrementButtonDisabledIcon.alpha = 0; button.disabledIcon = decrementButtonDisabledIcon; } protected function setVerticalScrollBarThumbStyles(thumb:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.vScrollBarThumbUpSkinTextures; skinSelector.setValueForState(this.vScrollBarThumbHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.vScrollBarThumbDownSkinTextures, Button.STATE_DOWN, false); thumb.stateToSkinFunction = skinSelector.updateValue; thumb.defaultIcon = new Image(this.vScrollBarThumbIconTexture); thumb.horizontalAlign = Button.HORIZONTAL_ALIGN_LEFT; thumb.paddingLeft = 4; } protected function setVerticalScrollBarMinimumTrackStyles(track:Button):void { track.defaultSkin = new Scale9Image(this.vScrollBarTrackSkinTextures); } //------------------------- // ScrollContainer //------------------------- protected function setScrollContainerStyles(container:ScrollContainer):void { this.setScrollerStyles(container); } protected function setToolbarScrollContainerStyles(container:ScrollContainer):void { this.setScrollerStyles(container); if(!container.layout) { var layout:HorizontalLayout = new HorizontalLayout(); layout.paddingTop = layout.paddingBottom = 2; layout.paddingRight = layout.paddingLeft = 6; layout.gap = 2; container.layout = layout; } container.minHeight = 22; container.backgroundSkin = new Scale9Image(headerBackgroundSkinTextures); } //------------------------- // ScrollScreen //------------------------- protected function setScrollScreenStyles(screen:ScrollScreen):void { this.setScrollerStyles(screen); screen.originalDPI = this.originalDPI; } //------------------------- // ScrollText //------------------------- protected function setScrollTextStyles(text:ScrollText):void { this.setScrollerStyles(text); text.textFormat = this.defaultTextFormat; text.disabledTextFormat = this.disabledTextFormat; text.paddingTop = text.paddingRight = text.paddingBottom = text.paddingLeft = 8; } //------------------------- // SimpleScrollBar //------------------------- protected function setHorizontalSimpleScrollBarStyles(scrollBar:SimpleScrollBar):void { scrollBar.customThumbName = THEME_NAME_HORIZONTAL_SIMPLE_SCROLL_BAR_THUMB; } protected function setVerticalSimpleScrollBarStyles(scrollBar:SimpleScrollBar):void { scrollBar.customThumbName = THEME_NAME_VERTICAL_SIMPLE_SCROLL_BAR_THUMB; } protected function setHorizontalSimpleScrollBarThumbStyles(thumb:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.hScrollBarThumbUpSkinTextures; skinSelector.setValueForState(this.hScrollBarThumbHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.hScrollBarThumbDownSkinTextures, Button.STATE_DOWN, false); thumb.stateToSkinFunction = skinSelector.updateValue; thumb.defaultIcon = new Image(this.hScrollBarThumbIconTexture); thumb.verticalAlign = Button.VERTICAL_ALIGN_TOP; thumb.paddingTop = 4; } protected function setVerticalSimpleScrollBarThumbStyles(thumb:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.vScrollBarThumbUpSkinTextures; skinSelector.setValueForState(this.vScrollBarThumbHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.vScrollBarThumbDownSkinTextures, Button.STATE_DOWN, false); thumb.stateToSkinFunction = skinSelector.updateValue; thumb.defaultIcon = new Image(this.vScrollBarThumbIconTexture); thumb.horizontalAlign = Button.HORIZONTAL_ALIGN_LEFT; thumb.paddingLeft = 4; } //------------------------- // Slider //------------------------- protected function setSliderStyles(slider:Slider):void { slider.trackLayoutMode = Slider.TRACK_LAYOUT_MODE_SINGLE; slider.minimumPadding = slider.maximumPadding = -vSliderThumbUpSkinTexture.height / 2; if(slider.direction == Slider.DIRECTION_VERTICAL) { slider.customThumbName = THEME_NAME_VERTICAL_SLIDER_THUMB; slider.customMinimumTrackName = THEME_NAME_VERTICAL_SLIDER_MINIMUM_TRACK; slider.focusPaddingLeft = slider.focusPaddingRight = -2; slider.focusPaddingTop = slider.focusPaddingBottom = -2 + slider.minimumPadding; } else //horizontal { slider.customThumbName = THEME_NAME_HORIZONTAL_SLIDER_THUMB; slider.customMinimumTrackName = THEME_NAME_HORIZONTAL_SLIDER_MINIMUM_TRACK; slider.focusPaddingTop = slider.focusPaddingBottom = -2; slider.focusPaddingLeft = slider.focusPaddingRight = -2 + slider.minimumPadding; } slider.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); } protected function setHorizontalSliderThumbStyles(thumb:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.hSliderThumbUpSkinTexture; skinSelector.setValueForState(this.hSliderThumbHoverSkinTexture, Button.STATE_HOVER, false); skinSelector.setValueForState(this.hSliderThumbDownSkinTexture, Button.STATE_DOWN, false); skinSelector.setValueForState(this.hSliderThumbDisabledSkinTexture, Button.STATE_DISABLED, false); thumb.stateToSkinFunction = skinSelector.updateValue; } protected function setHorizontalSliderMinimumTrackStyles(track:Button):void { track.defaultSkin = new Scale3Image(this.hSliderTrackSkinTextures); } protected function setVerticalSliderThumbStyles(thumb:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.vSliderThumbUpSkinTexture; skinSelector.setValueForState(this.vSliderThumbHoverSkinTexture, Button.STATE_HOVER, false); skinSelector.setValueForState(this.vSliderThumbDownSkinTexture, Button.STATE_DOWN, false); skinSelector.setValueForState(this.vSliderThumbDisabledSkinTexture, Button.STATE_DISABLED, false); thumb.stateToSkinFunction = skinSelector.updateValue; } protected function setVerticalSliderMinimumTrackStyles(track:Button):void { track.defaultSkin = new Scale3Image(this.vSliderTrackSkinTextures); } //------------------------- // TabBar //------------------------- protected function setTabBarStyles(tabBar:TabBar):void { tabBar.distributeTabSizes = false; tabBar.horizontalAlign = TabBar.HORIZONTAL_ALIGN_LEFT; tabBar.verticalAlign = TabBar.VERTICAL_ALIGN_JUSTIFY; } protected function setTabStyles(tab:Button):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.tabUpSkinTextures; skinSelector.defaultSelectedValue = this.tabSelectedUpSkinTextures; skinSelector.setValueForState(this.tabHoverSkinTextures, Button.STATE_HOVER, false); skinSelector.setValueForState(this.tabDownSkinTextures, Button.STATE_DOWN, false); skinSelector.setValueForState(this.tabDisabledSkinTextures, Button.STATE_DISABLED, false); skinSelector.setValueForState(this.tabSelectedDisabledSkinTextures, Button.STATE_DISABLED, true); tab.stateToSkinFunction = skinSelector.updateValue; tab.defaultLabelProperties.textFormat = this.defaultTextFormat; tab.disabledLabelProperties.textFormat = this.disabledTextFormat; tab.paddingTop = tab.paddingBottom = 2; tab.paddingLeft = tab.paddingRight = 10; tab.gap = 2; tab.minWidth = tab.minHeight = 12; } //------------------------- // TextArea //------------------------- protected function setTextAreaStyles(textArea:TextArea):void { this.setScrollerStyles(textArea); textArea.textEditorProperties.textFormat = this.defaultTextFormat; textArea.paddingTop = 2; textArea.paddingBottom = 2; textArea.paddingRight = 2; textArea.paddingLeft = 4; textArea.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); textArea.focusPadding = -1; var backgroundSkin:Scale9Image = new Scale9Image(textInputBackgroundSkinTextures); backgroundSkin.width = 264; backgroundSkin.height = 88; textArea.backgroundSkin = backgroundSkin; var backgroundDisabledSkin:Scale9Image = new Scale9Image(textInputBackgroundDisabledSkinTextures); backgroundDisabledSkin.width = 264; backgroundDisabledSkin.height = 88; textArea.backgroundDisabledSkin = backgroundDisabledSkin; } //------------------------- // TextInput //------------------------- protected function setBaseTextInputStyles(input:TextInput):void { var skinSelector:SmartDisplayObjectStateValueSelector = new SmartDisplayObjectStateValueSelector(); skinSelector.defaultValue = this.textInputBackgroundSkinTextures; skinSelector.setValueForState(this.textInputBackgroundDisabledSkinTextures, TextInput.STATE_DISABLED); input.stateToSkinFunction = skinSelector.updateValue; input.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); input.focusPadding = -1; input.minWidth = input.minHeight = 22; input.gap = 2; input.paddingTop = input.paddingBottom = 2; input.paddingRight = input.paddingLeft = 4; input.textEditorProperties.textFormat = this.defaultTextFormat; input.promptProperties.textFormat = this.defaultTextFormat; } protected function setTextInputStyles(input:TextInput):void { this.setBaseTextInputStyles(input); } protected function setSearchTextInputStyles(input:TextInput):void { this.setBaseTextInputStyles(input); var searchIcon:ImageLoader = new ImageLoader(); searchIcon.source = this.textInputSearchIconTexture; searchIcon.snapToPixels = true; input.defaultIcon = searchIcon; } //------------------------- // ToggleSwitch //------------------------- protected function setToggleSwitchStyles(toggle:ToggleSwitch):void { toggle.trackLayoutMode = ToggleSwitch.TRACK_LAYOUT_MODE_SINGLE; toggle.labelAlign = ToggleSwitch.LABEL_ALIGN_MIDDLE; toggle.defaultLabelProperties.textFormat = this.defaultTextFormat; toggle.disabledLabelProperties.textFormat = this.disabledTextFormat; toggle.focusIndicatorSkin = new Scale9Image(this.focusIndicatorSkinTextures); toggle.focusPadding = -1; } protected function setToggleSwitchOnTrackStyles(track:Button):void { track.defaultSkin = new Scale9Image(buttonSelectedUpSkinTextures); } protected function setToggleSwitchThumbStyles(thumb:Button):void { this.setButtonStyles(thumb); var frame:Rectangle = this.buttonUpSkinTextures.texture.frame; if(frame) { thumb.width = thumb.height = buttonUpSkinTextures.texture.frame.height; } else { thumb.width = thumb.height = buttonUpSkinTextures.texture.height; } } } } ",16129,True,3230.4746491786946,median "class ZCL_BUG_CONTROLLER definition public create public global friends ZCL_PRODUCTO_CONTROLLER . public section. *""* public components of class ZCL_BUG_CONTROLLER *""* do not include other source files here!!! class-methods CREATE importing !BUG type ref to ZCL_BUG raising ZCX_CREATE_EXCEPTION ZCX_VALIDATE_EXCEPTION . class-methods DELETE importing !BUG type ref to ZCL_BUG raising ZCX_DELETE_EXCEPTION . class-methods ENTITY_TO_STRUCTURE importing !ENTITY type ref to ZCL_BUG returning value(STRUCTURE) type ZBT_BUG . class-methods EXIST importing !BUG type ref to ZCL_BUG returning value(RETURN) type FLAG . class-methods FIND_BY_KEY importing !ID type ZBT_ID_BUG !PRODUCTO type ref to ZCL_PRODUCTO returning value(BUG) type ref to ZCL_BUG raising ZCX_NOT_FOUND_EXCEPTION . class-methods NEXT_ID importing !PRODUCTO type ref to ZCL_PRODUCTO !BUGTYPE type ref to ZCL_BUGTYPE optional returning value(RETURN) type ZBT_BUG-BUG . class-methods UPDATE importing !BUG type ref to ZCL_BUG raising ZCX_UPDATE_EXCEPTION ZCX_VALIDATE_EXCEPTION . class-methods VALIDATE_ON_CREATE importing !BUG type ref to ZCL_BUG raising ZCX_VALIDATE_EXCEPTION . class-methods VALIDATE_ON_DELETE importing !BUG type ref to ZCL_BUG raising ZCX_VALIDATE_EXCEPTION . class-methods VALIDATE_ON_UPDATE importing !BUG type ref to ZCL_BUG raising ZCX_VALIDATE_EXCEPTION . class-methods STRUCTURE_TO_ENTITY importing !STRUCTURE type ZBT_BUG changing value(ENTITY) type ref to ZCL_BUG . class-methods LOCK importing !BUG type ref to ZCL_BUG . class-methods UNLOCK importing !BUG type ref to ZCL_BUG . class-methods EQUAL importing !BUG1 type ref to ZCL_BUG !BUG2 type ref to ZCL_BUG returning value(EQUAL) type FLAG . class-methods SEARCH importing !BUG type ZBT_BUG_RANGE optional !BUG_I type ZBT_BUG_I_RANGE optional !BUGSTYPE type ZBT_BUGSTYPE_RANGE optional !BUGTYPE type ZBT_BUGTYPE_RANGE optional !COMPONENTE type ZBT_COMPONENTE_RANGE optional !DEADLINE type ZBT_DATS_RANGE optional !ESTADO type ZBT_ESTADO_RANGE optional !HORAS_ESTIMADAS type ZBT_HORAS_RANGE optional !HORAS_REALES type ZBT_HORAS_RANGE optional !PRODUCTO type ZBT_PRODUCTO_RANGE optional !RESUMEN type ZBT_TEXT_RANGE optional !CREADO type ZBT_TIMESTAMP_RANGE optional !REPORTER type ZBT_USER_RANGE optional !DEVELOPER type ZBT_USER_RANGE optional !ASSIGNED type ZBT_USER_RANGE optional !TESTER type ZBT_USER_RANGE optional !FINALIZADO type ZBT_TIMESTAMP_RANGE optional !AEDAT type ZBT_TIMESTAMP_RANGE optional !AENAM type ZBT_USER_RANGE optional value(MAX_ROWS) type I optional returning value(RETURN) type ZBT_BUGS . protected section. *""* protected components of class ZCL_BUG_CONTROLLER *""* do not include other source files here!!! class-methods ENTITY_TO_PERSIST importing !ENTITY type ref to ZCL_BUG changing value(PERSIST) type ref to ZCL_BUG_PERSIST . class-methods FIND_NEXT_BUGS importing !BUG type ref to ZCL_BUG returning value(RESULT) type ZBT_BUGS . class-methods FIND_PREV_BUGS importing !BUG type ref to ZCL_BUG returning value(RESULT) type ZBT_BUGS . class-methods PERSIST_TO_ENTITY importing !PERSIST type ref to ZCL_BUG_PERSIST returning value(ENTITY) type ref to ZCL_BUG . private section. *""* private components of class ZCL_BUG_CONTROLLER *""* do not include other source files here!!! class-data BUGS_BUFFER type ZBT_BUGS . class-methods EQUAL_TAGS importing !BUG1 type ref to ZCL_BUG !BUG2 type ref to ZCL_BUG returning value(EQUAL) type FLAG . ENDCLASS. CLASS ZCL_BUG_CONTROLLER IMPLEMENTATION. METHOD create. DATA: lo_bug_persist TYPE REF TO zcl_bug_persist, l_timestamp TYPE timestamp, l_creado TYPE zbt_bug-creado, l_aedat TYPE zbt_bug-aedat, lo_producto TYPE REF TO zcl_producto, lo_bugtype TYPE REF TO zcl_bugtype, l_str_bug TYPE zbt_bug, lt_attachements TYPE zbt_attachements, lt_comentarios TYPE zbt_comentarios, lt_sections TYPE zbt_bugsections, lo_usuario TYPE REF TO zcl_usuario, lt_transportes TYPE zbt_transport_tbl, lo_transaccion TYPE REF TO zcl_transaction_service, lo_validate_exception TYPE REF TO zcx_validate_exception, lt_tags TYPE zbt_bug_tag_tbl, lt_wrklogs TYPE zbt_bugwrklogs, lo_exception TYPE REF TO cx_root. FIELD-SYMBOLS: TYPE LINE OF zbt_attachements, TYPE LINE OF zbt_comentarios,
TYPE LINE OF zbt_bugsections, TYPE LINE OF zbt_transport_tbl, TYPE LINE OF zbt_bug_tag_tbl, LIKE LINE OF lt_wrklogs. * On create, get next Id l_str_bug-bug = bug->get_id( ). l_str_bug-bug_i = bug->get_id_i( ). IF l_str_bug-bug IS INITIAL. lo_producto = bug->get_producto( ). lo_bugtype = bug->get_bug_type( ). l_str_bug-bug = zcl_bug_controller=>next_id( producto = lo_producto bugtype = lo_bugtype ). bug->set_id( l_str_bug-bug ). bug->set_id_i( l_str_bug-bug_i ). ENDIF. * Set CreateTime IF l_str_bug-creado IS INITIAL. GET TIME STAMP FIELD l_timestamp. l_creado = l_timestamp. bug->set_creado( l_creado ). ENDIF. * Antes de crear procedemos a validar validate_on_create( bug ). l_str_bug = entity_to_structure( bug ). TRY. CREATE OBJECT lo_transaccion. lo_transaccion->start( ). CALL METHOD zca_bug_persist=>agent->create_persistent EXPORTING i_bug = l_str_bug-bug i_bug_i = l_str_bug-bug_i i_bugstype = l_str_bug-bugstype i_bugtype = l_str_bug-bugtype i_componente = l_str_bug-componente i_creado = l_str_bug-creado i_deadline = l_str_bug-deadline i_developer = l_str_bug-developer i_estado = l_str_bug-estado i_finalizado = l_str_bug-finalizado i_horas_est = l_str_bug-horas_est i_horas_rea = l_str_bug-horas_rea i_producto = l_str_bug-producto i_reporter = l_str_bug-reporter i_resumen = l_str_bug-resumen i_tester = l_str_bug-tester i_assigned = l_str_bug-assigned RECEIVING result = lo_bug_persist. * Creamos los attachements lt_attachements[] = bug->get_attachements( ). LOOP AT lt_attachements ASSIGNING . zcl_attachement_controller=>create( ). ENDLOOP. * Creamos los comentarios lt_comentarios[] = bug->get_comentarios( no_section_comments = 'X' ). LOOP AT lt_comentarios ASSIGNING . zcl_comment_controller=>create( -oref ). ENDLOOP. * Creamos las secciones lt_sections[] = bug->get_sections( ) . LOOP AT lt_sections ASSIGNING
. zcl_bugsection_controller=>create(
-oref ). ENDLOOP. * Creamos los transportes lt_transportes[] = bug->get_transports( ). LOOP AT lt_transportes ASSIGNING . zcl_transport_controller=>create( -oref ). ENDLOOP. * Creamos los Tags lt_tags[] = bug->get_tags( ). LOOP AT lt_tags ASSIGNING . zcl_bug_tag_controller=>create( -oref ). ENDLOOP. * Creates WorkLog lt_wrklogs = bug->get_wrklogs( ). LOOP AT lt_wrklogs ASSIGNING . zcl_bug_wrklog_controller=>create( -oref ). ENDLOOP. * Set ModifyDate GET TIME STAMP FIELD l_timestamp. l_aedat = l_aedat. bug->set_aedat( l_aedat ). * Set ModifyUser lo_usuario = zcl_usuario_controller=>find_by_key( ). bug->set_aenam( lo_usuario ). lo_transaccion->end( ). CATCH cx_os_object_existing INTO lo_exception. RAISE EXCEPTION TYPE zcx_create_exception EXPORTING textid = zcx_create_exception=>zcx_create_exception previous = lo_exception. ENDTRY. ENDMETHOD. METHOD delete. DATA: lo_bug_persist TYPE REF TO zcl_bug_persist, lo_producto TYPE REF TO zcl_producto, l_id_bug TYPE zbt_bug-bug, l_id_bug_i TYPE zbt_bug-bug_i, l_id_producto TYPE zbt_producto-producto, lt_attachements TYPE zbt_attachements, lt_comentarios TYPE zbt_comentarios, lt_sections TYPE zbt_bugsections, lt_transportes TYPE ZBT_TRANSPORT_TBL, lo_transaccion TYPE REF TO zcl_transaction_service, lt_tags TYPE zbt_bug_tag_tbl, lo_exception TYPE REF TO cx_root. FIELD-SYMBOLS: TYPE LINE OF zbt_attachements, TYPE LINE OF zbt_comentarios,
TYPE LINE OF zbt_bugsections, TYPE LINE OF zbt_bug_tag_tbl, TYPE LINE OF ZBT_TRANSPORT_TBL. validate_on_delete( bug ). l_id_bug = bug->get_id( ). l_id_bug_i = bug->get_id_i( ). lo_producto = bug->get_producto( ). l_id_producto = lo_producto->get_id( ). CREATE OBJECT lo_transaccion. lo_transaccion->start( ). *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Borramos el resto de objetos *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Borramos los attachements lt_attachements[] = bug->get_attachements( ). LOOP AT lt_attachements ASSIGNING . zcl_attachement_controller=>delete( ). ENDLOOP. * Borramos los comentarios lt_comentarios[] = bug->get_comentarios( NO_SECTION_COMMENTS = space ). LOOP AT lt_comentarios ASSIGNING . zcl_comment_controller=>delete( -oref ). ENDLOOP. * Borramos las secciones lt_sections[] = bug->get_sections( ) . LOOP AT lt_sections ASSIGNING
. zcl_bugsection_controller=>delete(
-oref ). ENDLOOP. * Borramos los transportes lt_transportes[] = bug->get_transports( ). LOOP AT lt_transportes ASSIGNING . zcl_transport_controller=>delete( -oref ). ENDLOOP. * Borramos los tags lt_tags[] = bug->get_tags( ). LOOP AT lt_tags ASSIGNING . zcl_bug_tag_controller=>delete( -oref ). ENDLOOP. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Borramos de la persistencia *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ zca_bug_persist=>agent->delete_persistent( i_bug = l_id_bug * i_bug_i = l_id_bug_i i_producto = l_id_producto ). lo_transaccion->end( ). ENDMETHOD. METHOD entity_to_persist. DATA: l_structure TYPE zbt_bug. l_structure = entity_to_structure( entity ). *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Las clave de un objeto de persistencia NO se pueden cambiar *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * persist->set_bug( l_structure-bug ). * persist->set_producto( l_structure-producto ). persist->set_bugstype( l_structure-bugstype ). persist->set_bugtype( l_structure-bugtype ). persist->set_componente( l_structure-componente ). persist->set_creado( l_structure-creado ). persist->set_deadline( l_structure-deadline ). persist->set_developer( l_structure-developer ). persist->set_assigned( l_structure-assigned ). persist->set_estado( l_structure-estado ). persist->set_finalizado( l_structure-finalizado ). persist->set_horas_est( l_structure-horas_est ). persist->set_horas_rea( l_structure-horas_rea ). persist->set_reporter( l_structure-reporter ). persist->set_resumen( l_structure-resumen ). persist->set_tester( l_structure-tester ). persist->set_aedat( l_structure-aedat ). persist->set_aenam( l_structure-aenam ). persist->set_bug_i( l_structure-bug_i ). ENDMETHOD. METHOD entity_to_structure. DATA: lo_producto TYPE REF TO zcl_producto, lo_usuario TYPE REF TO zcl_usuario, lo_componente TYPE REF TO zcl_componente, lo_bugtype TYPE REF TO zcl_bugtype, lo_bugstype TYPE REF TO zcl_bugstype, lo_estado TYPE REF TO zcl_estado. structure-bug = entity->get_id( ). structure-bug_i = entity->get_id_i( ). lo_producto = entity->get_producto( ). structure-producto = lo_producto->get_id( ). structure-creado = entity->get_creado( ). structure-finalizado = entity->get_finalizado( ). structure-deadline = entity->get_deadline( ). structure-aedat = entity->get_aedat( ). lo_usuario = entity->get_aenam( ). IF lo_usuario IS BOUND. structure-aenam = lo_usuario->get_id( ). ENDIF. CLEAR lo_usuario. lo_usuario = entity->get_reporter( ). IF lo_usuario IS BOUND. structure-reporter = lo_usuario->get_id( ). ENDIF. CLEAR lo_usuario. lo_usuario = entity->get_developer( ). IF lo_usuario IS BOUND. structure-developer = lo_usuario->get_id( ). ENDIF. CLEAR lo_usuario. lo_usuario = entity->get_assigned( ). IF lo_usuario IS BOUND. structure-assigned = lo_usuario->get_id( ). ENDIF. CLEAR lo_usuario. lo_usuario = entity->get_tester( ). IF lo_usuario IS BOUND. structure-tester = lo_usuario->get_id( ). ENDIF. CLEAR lo_usuario. structure-resumen = entity->get_resumen( ). lo_estado = entity->get_estado( ). IF lo_estado IS BOUND. structure-estado = lo_estado->get_id( ). ENDIF. structure-horas_est = entity->get_horas_estimadas( ). structure-horas_rea = entity->get_horas_reales( ). lo_componente = entity->get_componente( ). IF lo_componente IS BOUND. structure-componente = lo_componente->get_id( ). ENDIF. lo_bugtype = entity->get_bug_type( ). IF lo_bugtype IS BOUND. structure-bugtype = lo_bugtype->get_id( ). ENDIF. lo_bugstype = entity->get_bug_subtype( ). IF lo_bugstype IS BOUND. structure-bugstype = lo_bugstype->get_id( ). ENDIF. ENDMETHOD. METHOD equal. IF bug1->get_hash( ) = bug2->get_hash( ). equal = abap_true. ELSE. equal = abap_false. ENDIF. ENDMETHOD. METHOD equal_tags. DATA: l_counter1 TYPE i, l_counter2 TYPE i, lt_tags1 TYPE zbt_bug_tag_tbl, lt_tags2 TYPE zbt_bug_tag_tbl, l_tag1 TYPE LINE OF zbt_bug_tag_tbl, l_tag2 TYPE LINE OF zbt_bug_tag_tbl. lt_tags1 = bug1->get_tags( ). lt_tags2 = bug2->get_tags( ). SORT: lt_tags1, lt_tags2. DESCRIBE TABLE lt_tags1 LINES l_counter1. DESCRIBE TABLE lt_tags2 LINES l_counter2. IF l_counter1 <> l_counter2. equal = abap_false. ELSE. CLEAR l_counter2. DO l_counter1 TIMES. ADD 1 TO l_counter2. READ TABLE lt_tags1 INDEX l_counter2 INTO l_tag1. READ TABLE lt_tags2 INDEX l_counter2 INTO l_tag2. IF zcl_bug_tag_controller=>equal( tag1 = l_tag1-oref tag2 = l_tag2-oref ) = abap_false. equal = abap_false. EXIT. ENDIF. ENDDO. ENDIF. ENDMETHOD. method EXIST. DATA: l_id TYPE zbt_bug-bug, l_id_i TYPE zbt_bug-bug_i, lo_producto TYPE REF TO zcl_producto. TRY . l_id = bug->get_id( ). l_id_i = bug->get_id_i( ). lo_producto = bug->get_producto( ). zcl_bug_controller=>find_by_key( id = l_id * id_i = l_id_i producto = lo_producto ). return = 'X'. CATCH cx_root. return = space. ENDTRY. endmethod. method FIND_BY_KEY. DATA: lo_bug_agent TYPE REF TO zca_bug_persist, lo_bug_persist TYPE REF TO zcl_bug_persist, lo_exception TYPE REF TO cx_root, l_id_producto TYPE zbt_producto-producto. l_id_producto = producto->get_id( ). TRY. * Buscamos el objeto en la capa de persistencia lo_bug_agent = zca_bug_persist=>agent. CALL METHOD lo_bug_agent->get_persistent EXPORTING i_bug = id i_producto = l_id_producto RECEIVING result = lo_bug_persist. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Mapeamos contra un Entity *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bug = persist_to_entity( lo_bug_persist ). CATCH cx_root INTO lo_exception. RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING textid = zcx_not_found_exception=>zcx_not_found_exception previous = lo_exception. ENDTRY. endmethod. METHOD find_next_bugs. DATA: lo_qm TYPE REF TO if_os_query_manager, lo_q TYPE REF TO if_os_query, lo_producto TYPE REF TO zcl_producto, lo_bug TYPE REF TO zcl_bug, l_id_producto TYPE zbt_producto-producto, l_id_bug TYPE zbt_id_bug, l_id_bug_i TYPE zbt_id_bug_i, l_result TYPE LINE OF zbt_bugs, lt_bughier_persist TYPE osreftab, l_bug_buffer TYPE LINE OF zbt_bugs, lo_bughier_persist TYPE REF TO zcl_bughier_persist. FIELD-SYMBOLS: TYPE osref. l_id_bug = bug->get_id( ). l_id_bug_i = bug->get_id_i( ). lo_producto = bug->get_producto( ). l_id_producto = lo_producto->get_id( ). READ TABLE bugs_buffer WITH TABLE KEY producto_id = l_id_producto bug_id = l_id_bug INTO l_bug_buffer. IF NOT sy-subrc IS INITIAL. l_bug_buffer-oref = bug. l_bug_buffer-producto_id = l_id_producto. l_bug_buffer-bug_id = l_id_bug. INSERT l_bug_buffer INTO TABLE bugs_buffer. ENDIF. * Montamos una query para obtener los siguientes bugs al indicado lo_qm = cl_os_system=>get_query_manager( ). lo_q = lo_qm->create_query( i_filter = 'PRODUCTO = PAR1 AND BUG = PAR2 ' ). lt_bughier_persist[] = zca_bughier_persist=>agent->if_os_ca_persistency~get_persistent_by_query( i_query = lo_q i_par1 = l_id_producto i_par2 = l_id_bug ). LOOP AT lt_bughier_persist ASSIGNING . lo_bughier_persist ?= . l_bug_buffer-bug_id = l_result-bug_id = lo_bughier_persist->get_next_bug( ). l_bug_buffer-producto_id = l_result-producto_id = l_id_producto. READ TABLE bugs_buffer WITH TABLE KEY producto_id = l_result-producto_id bug_id = l_result-bug_id INTO l_bug_buffer. IF sy-subrc IS INITIAL. l_result-oref = l_bug_buffer-oref. ELSE. l_bug_buffer-oref = l_result-oref = zcl_bug_controller=>find_by_key( id = l_result-bug_id producto = lo_producto ). INSERT l_bug_buffer INTO TABLE bugs_buffer[]. ENDIF. INSERT l_result INTO TABLE result[]. ENDLOOP. ENDMETHOD. METHOD find_prev_bugs. DATA: lo_qm TYPE REF TO if_os_query_manager, lo_q TYPE REF TO if_os_query, lo_producto TYPE REF TO zcl_producto, lo_bug TYPE REF TO zcl_bug, l_id_producto TYPE zbt_producto-producto, l_id_bug TYPE zbt_id_bug, l_id_bug_i TYPE zbt_id_bug_i, l_result TYPE LINE OF zbt_bugs, lt_bughier_persist TYPE osreftab, l_bug_buffer TYPE LINE OF zbt_bugs, lo_bughier_persist TYPE REF TO zcl_bughier_persist. FIELD-SYMBOLS: TYPE osref. l_id_bug = bug->get_id( ). lo_producto = bug->get_producto( ). l_id_producto = lo_producto->get_id( ). READ TABLE bugs_buffer WITH TABLE KEY producto_id = l_id_producto bug_id = l_id_bug INTO l_bug_buffer. IF NOT sy-subrc IS INITIAL. l_bug_buffer-oref = bug. l_bug_buffer-producto_id = l_id_producto. l_bug_buffer-bug_id = l_id_bug. INSERT l_bug_buffer INTO TABLE bugs_buffer. ENDIF. * Montamos una query para obtener los bugs anteriores al indicado lo_qm = cl_os_system=>get_query_manager( ). lo_q = lo_qm->create_query( i_filter = 'PRODUCTO = PAR1 AND NEXT_BUG = PAR2 ' ). lt_bughier_persist[] = zca_bughier_persist=>agent->if_os_ca_persistency~get_persistent_by_query( i_query = lo_q i_par1 = l_id_producto i_par2 = l_id_bug ). LOOP AT lt_bughier_persist ASSIGNING . lo_bughier_persist ?= . l_bug_buffer-bug_id = l_result-bug_id = lo_bughier_persist->get_bug( ). l_bug_buffer-producto_id = l_result-producto_id = l_id_producto. READ TABLE bugs_buffer WITH TABLE KEY producto_id = l_result-producto_id bug_id = l_result-bug_id INTO l_bug_buffer. IF sy-subrc IS INITIAL. l_result-oref = l_bug_buffer-oref. ELSE. l_bug_buffer-oref = l_result-oref = zcl_bug_controller=>find_by_key( id = l_result-bug_id producto = lo_producto ). INSERT l_bug_buffer INTO TABLE bugs_buffer[]. ENDIF. INSERT l_result INTO TABLE result[]. ENDLOOP. ENDMETHOD. method LOCK. endmethod. method NEXT_ID. DATA: l_number_range TYPE tnro-object. l_number_range = producto->get_bug_number_range( ). IF l_number_range IS INITIAL. l_number_range = 'ZBT_BUGID'. ""Default Number Range ENDIF. IF bugtype IS SUPPLIED AND bugtype->get_nrobj( ) IS NOT INITIAL. l_number_range = bugtype->get_nrobj( ). ENDIF. CALL FUNCTION 'NUMBER_GET_NEXT' EXPORTING nr_range_nr = '1' object = l_number_range quantity = '1' * TOYEAR = '0000' IMPORTING number = return * QUANTITY = * RETURNCODE = * EXCEPTIONS * INTERVAL_NOT_FOUND = 1 * NUMBER_RANGE_NOT_INTERN = 2 * OBJECT_NOT_FOUND = 3 * QUANTITY_IS_0 = 4 * QUANTITY_IS_NOT_1 = 5 * INTERVAL_OVERFLOW = 6 * BUFFER_OVERFLOW = 7 * OTHERS = 8 . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. endmethod. METHOD persist_to_entity. DATA: l_usuario TYPE xubname, l_id_estado TYPE zbt_id_estado, l_id_bugtype TYPE zbt_id_bugtype, l_id_bugstype TYPE zbt_bugstype, l_id_bug TYPE zbt_bug-bug, l_id_bug_i TYPE zbt_bug-bug_i, l_id_producto TYPE zbt_producto-producto, l_id_componente TYPE zbt_id_componente, l_resumen TYPE zbt_resumen, lo_bugstype TYPE REF TO zcl_bugstype, lo_bugtype TYPE REF TO zcl_bugtype, lo_producto TYPE REF TO zcl_producto, lo_usuario TYPE REF TO zcl_usuario, lo_componente TYPE REF TO zcl_componente, lo_estado TYPE REF TO zcl_estado, l_timestamp TYPE zbt_erdat, l_dats TYPE sy-datum, l_horas TYPE zbt_horas_reales, lt_bugs TYPE zbt_bugs, lt_sections TYPE zbt_bugsections, lt_transportes TYPE zbt_transport_tbl, lt_attachements TYPE zbt_attachements, lt_comments TYPE zbt_comentarios, lt_tags TYPE zbt_bug_tag_tbl. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Mapeamos contra un entity *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ l_id_bug = persist->get_bug( ). l_id_producto = persist->get_producto( ). l_id_componente = persist->get_componente( ). lo_producto = zcl_producto_controller=>find_by_key( l_id_producto ). lo_componente = zcl_componente_controller=>find_by_key( producto = lo_producto id = l_id_componente ). CREATE OBJECT entity EXPORTING id = l_id_bug producto = lo_producto componente = lo_componente. l_usuario = persist->get_developer( ). IF NOT l_usuario IS INITIAL. lo_usuario = zcl_usuario_controller=>find_by_key( l_usuario ). entity->set_developer( lo_usuario ). ENDIF. l_usuario = persist->get_assigned( ). IF NOT l_usuario IS INITIAL. lo_usuario = zcl_usuario_controller=>find_by_key( l_usuario ). entity->set_assigned( lo_usuario ). ENDIF. l_usuario = persist->get_tester( ). IF NOT l_usuario IS INITIAL. lo_usuario = zcl_usuario_controller=>find_by_key( l_usuario ). entity->set_tester( lo_usuario ). ENDIF. l_usuario = persist->get_reporter( ). IF NOT l_usuario IS INITIAL. lo_usuario = zcl_usuario_controller=>find_by_key( l_usuario ). entity->set_reporter( lo_usuario ). ENDIF. l_usuario = persist->get_aenam( ). IF NOT l_usuario IS INITIAL. lo_usuario = zcl_usuario_controller=>find_by_key( l_usuario ). entity->set_aenam( lo_usuario ). ENDIF. l_id_componente = persist->get_componente( ). IF NOT l_id_componente IS INITIAL. lo_componente = zcl_componente_controller=>find_by_key( id = l_id_componente producto = lo_producto ). entity->set_componente( lo_componente ). ENDIF. l_id_estado = persist->get_estado( ). IF NOT l_id_estado IS INITIAL. lo_estado = zcl_estado_controller=>find_by_key( l_id_estado ). entity->set_estado( lo_estado ). ENDIF. l_id_bugtype = persist->get_bugtype( ). IF NOT l_id_bugtype IS INITIAL. lo_bugtype = zcl_bugtype_controller=>find_by_key( l_id_bugtype ). entity->set_bug_type( lo_bugtype ). ENDIF. l_id_bugstype = persist->get_bugstype( ). IF NOT l_id_bugstype IS INITIAL. lo_bugstype = zcl_bug_subtype_controller=>find_by_key( bugtype = lo_bugtype id = l_id_bugstype ). entity->set_bug_subtype( lo_bugstype ). ENDIF. l_resumen = persist->get_resumen( ). entity->set_resumen( l_resumen ). l_timestamp = persist->get_creado( ). entity->set_creado( l_timestamp ). l_id_bug_i = persist->get_bug_i( ). entity->SET_ID_I( l_id_bug_i ). l_timestamp = persist->get_aedat( ). entity->set_aedat( l_timestamp ). l_dats = persist->get_deadline( ). entity->set_deadline( l_dats ). l_timestamp = persist->get_finalizado( ). entity->set_finalizado( l_timestamp ). l_horas = persist->get_horas_est( ). entity->set_horas_estimadas( l_horas ). l_horas = persist->get_horas_rea( ). entity->set_horas_reales( l_horas ). lt_bugs[] = find_next_bugs( entity ). entity->set_next_bugs( lt_bugs ). lt_bugs[] = find_prev_bugs( entity ). entity->set_prev_bugs( lt_bugs ). lt_attachements[] = zcl_attachement_controller=>find_all_bug_attachements( entity ). entity->set_attachements( lt_attachements[] ). lt_comments[] = zcl_comment_controller=>find_all_bug_comments( bug = entity no_section_comments = 'X' ). entity->set_comentarios( lt_comments[] ). lt_sections[] = zcl_bugsection_controller=>find_all_bug_sections( entity ). entity->set_sections( lt_sections[] ). lt_transportes[] = zcl_transport_controller=>find_all_bug_transports( entity ). entity->set_transports( lt_transportes[] ). lt_tags[] = zcl_bug_tag_controller=>find_bug_tags( entity ). entity->set_tags( lt_tags[] ). ENDMETHOD. METHOD search. DATA: lt_bugs TYPE STANDARD TABLE OF zbt_bug, l_bug TYPE zbt_bug, lo_producto TYPE REF TO zcl_producto, l_return TYPE LINE OF zbt_bugs. SELECT * FROM zbt_bug INTO TABLE lt_bugs up to max_rows ROWS WHERE bug IN bug[] and bug_i IN bug_i[] AND producto IN producto[] AND componente IN componente[] AND developer IN developer[] AND assigned IN assigned[] AND tester IN tester[] AND reporter IN reporter[] AND creado IN creado[] AND estado IN estado[] AND bugtype IN bugtype[] AND bugstype IN bugstype[] AND finalizado IN finalizado[] AND deadline IN deadline[] and aedat in aedat[] and aenam in aenam[]. LOOP AT lt_bugs INTO l_bug. l_return-bug_id = l_bug-bug. l_return-producto_id = l_bug-producto. lo_producto = zcl_producto_controller=>find_by_key( l_return-producto_id ). l_return-oref = zcl_bug_controller=>find_by_key( id = l_return-bug_id producto = lo_producto ). INSERT l_return INTO TABLE return. ENDLOOP. ENDMETHOD. METHOD structure_to_entity. DATA: lo_producto TYPE REF TO zcl_producto, lo_usuario TYPE REF TO zcl_usuario, lo_componente TYPE REF TO zcl_componente, lo_bugtype TYPE REF TO zcl_bugtype, lo_bugstype TYPE REF TO zcl_bugstype, lo_estado TYPE REF TO zcl_estado. * entity->set_id( structure-bug ). lo_producto = zcl_producto_controller=>find_by_key( structure-producto ). lo_componente = zcl_componente_controller=>find_by_key( id = structure-componente producto = lo_producto ). entity->set_producto( lo_producto ). entity->set_componente( lo_componente ). entity->set_creado( structure-creado ). entity->set_finalizado( structure-finalizado ). entity->set_deadline( structure-deadline ). TRY. lo_usuario = zcl_usuario_controller=>find_by_key( structure-reporter ). entity->set_reporter( lo_usuario ). CATCH zcx_not_found_exception. ENDTRY. CLEAR lo_usuario. TRY . lo_usuario = zcl_usuario_controller=>find_by_key( structure-developer ). entity->set_developer( lo_usuario ). CATCH zcx_not_found_exception. ENDTRY. CLEAR lo_usuario. TRY . lo_usuario = zcl_usuario_controller=>find_by_key( structure-assigned ). entity->set_assigned( lo_usuario ). CATCH zcx_not_found_exception. ENDTRY. CLEAR lo_usuario. TRY. lo_usuario = zcl_usuario_controller=>find_by_key( structure-tester ). entity->set_tester( lo_usuario ). CATCH zcx_not_found_exception. ENDTRY. CLEAR lo_usuario. entity->set_resumen( structure-resumen ). lo_estado = zcl_estado_controller=>find_by_key( structure-estado ). IF lo_estado IS BOUND. entity->set_estado( lo_estado ). ENDIF. entity->set_horas_estimadas( structure-horas_est ). entity->set_horas_reales( structure-horas_rea ). entity->set_componente( lo_componente ). lo_bugtype = zcl_bugtype_controller=>find_by_key( structure-bugtype ). entity->set_bug_type( lo_bugtype ). lo_bugstype = zcl_bug_subtype_controller=>find_by_key( id = structure-bugstype bugtype = lo_bugtype ). IF NOT lo_bugstype IS BOUND. * If after having changed BugType we found that there's no subtype with same subtype id * for the newly selected bugType, we try to obtain default subtype value lo_bugstype = zcl_bug_subtype_controller=>find_by_key( id = 0 bugtype = lo_bugtype ). ENDIF. entity->set_bug_subtype( lo_bugstype ). ENDMETHOD. method UNLOCK. endmethod. METHOD update. DATA: lo_bug_persist TYPE REF TO zcl_bug_persist, lo_producto TYPE REF TO zcl_producto, l_timestamp TYPE timestamp, l_aedat TYPE zbt_bug-aedat, l_id_bug TYPE zbt_bug-bug, l_id_bug_i TYPE zbt_bug-bug_i, l_id_producto TYPE zbt_producto-producto, lt_attachements TYPE zbt_attachements, lt_comentarios TYPE zbt_comentarios, lt_sections TYPE zbt_bugsections, lt_transportes TYPE zbt_transport_tbl, lo_usuario TYPE REF TO zcl_usuario, lo_transaccion TYPE REF TO zcl_transaction_service, lt_tags TYPE zbt_bug_tag_tbl, lt_wrklogs TYPE ZBT_BUGWRKLOGS, lo_exception TYPE REF TO cx_root. FIELD-SYMBOLS: TYPE LINE OF zbt_attachements, TYPE LINE OF zbt_comentarios,
TYPE LINE OF zbt_bugsections, TYPE LINE OF zbt_bug_tag_tbl, TYPE LINE OF zbt_transport_tbl, like LINE OF lt_wrklogs. validate_on_update( bug ). l_id_bug = bug->get_id( ). * l_id_bug_i = bug->get_id_i( ). lo_producto = bug->get_producto( ). l_id_producto = lo_producto->get_id( ). TRY . * We look first at what is now the persistence layer lo_bug_persist = zca_bug_persist=>agent->get_persistent( i_bug = l_id_bug i_producto = l_id_producto ). CATCH cx_os_object_not_found INTO lo_exception. * In order to update it must exist RAISE EXCEPTION TYPE zcx_update_exception EXPORTING textid = zcx_update_exception=>zcx_update_exception previous = lo_exception. ENDTRY. CREATE OBJECT lo_transaccion. lo_transaccion->start( ). *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * We proceed to update the rest of the objects *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TRY . * Update Attachments lt_attachements[] = bug->get_attachements( ). LOOP AT lt_attachements ASSIGNING . * IF zcl_attachement_controller=>exist( -oref ) = abap_true. zcl_attachement_controller=>update( ). * ELSE. zcl_attachement_controller=>update( ). * ENDIF. ENDLOOP. * Update comments lt_comentarios[] = bug->get_comentarios( no_section_comments = space ). LOOP AT lt_comentarios ASSIGNING . IF zcl_comment_controller=>exist( -oref ) = abap_true. zcl_comment_controller=>update( -oref ). ELSE. zcl_comment_controller=>create( -oref ). ENDIF. ENDLOOP. * Update Sections lt_sections[] = bug->get_sections( ) . LOOP AT lt_sections ASSIGNING
. IF zcl_bugsection_controller=>exist(
-oref ) = abap_true. zcl_bugsection_controller=>update(
-oref ). ELSE. zcl_bugsection_controller=>create(
-oref ). ENDIF. ENDLOOP. * Update Transports lt_transportes[] = bug->get_transports( ). LOOP AT lt_transportes ASSIGNING . IF zcl_transport_controller=>exist( -oref ) = abap_true. zcl_transport_controller=>update( -oref ). ELSE. zcl_transport_controller=>create( -oref ). ENDIF. ENDLOOP. * Update Tags lt_tags[] = bug->get_tags( ). LOOP AT lt_tags ASSIGNING . IF zcl_bug_tag_controller=>exist( -oref ) = abap_true. zcl_bug_tag_controller=>update( -oref ). ELSE. zcl_bug_tag_controller=>create( -oref ). ENDIF. ENDLOOP. lt_tags[] = bug->get_deleted_tags( ). LOOP AT lt_tags ASSIGNING . zcl_bug_tag_controller=>delete( -oref ). ENDLOOP. * Update WorkLog lt_wrklogs = bug->get_wrklogs( ). LOOP AT lt_wrklogs ASSIGNING . IF zcl_bug_wrklog_controller=>exists( -oref ) = abap_true. zcl_bug_wrklog_controller=>update( -oref ). ELSE. zcl_bug_wrklog_controller=>create( -oref ). ENDIF. ENDLOOP. * Set ModifyDate GET TIME STAMP FIELD l_timestamp. l_aedat = l_timestamp. bug->set_aedat( l_aedat ). * Set ModifyUser lo_usuario = zcl_usuario_controller=>find_by_key( ). bug->set_aenam( lo_usuario ). *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Mapeamos contra el objeto de persistencia *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ entity_to_persist( EXPORTING entity = bug CHANGING persist = lo_bug_persist ). lo_transaccion->end( ). CATCH zcx_create_exception INTO lo_exception. RAISE EXCEPTION TYPE zcx_update_exception EXPORTING previous = lo_exception. ENDTRY. ENDMETHOD. METHOD validate_on_create. DATA: l_str_bug TYPE zbt_bug, lt_sections TYPE zbt_bugsections, l_section TYPE LINE OF zbt_bugsections, l_section_ok TYPE i, l_comment_id TYPE zbt_bugcomment-comentario, l_seccion_id TYPE zbt_bugseccion-seccion, lo_estado TYPE REF TO zcl_estado, lo_producto TYPE REF TO zcl_producto, lo_usuario TYPE REF TO zcl_usuario, lo_bugtype TYPE REF TO zcl_bugtype, lo_subtype TYPE REF TO zcl_bugstype, lo_componente TYPE REF TO zcl_componente, l_field TYPE string, lo_not_found TYPE REF TO zcx_not_found_exception. l_str_bug = entity_to_structure( bug ). TRY . * Campos clave obligatorios! IF l_str_bug-bug IS INITIAL. l_field = 'Bug Id'(001). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. IF l_str_bug-bug_i IS INITIAL. l_field = 'internal Bug Id'(018). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. IF l_str_bug-producto IS INITIAL. l_field = 'Product Id'(002). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. * Producto debe existir lo_producto = bug->get_producto( ). IF zcl_producto_controller=>exist( lo_producto ) IS INITIAL. l_field = 'Product'(003). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. * Si se indica un componente éste debe existir IF NOT l_str_bug-componente IS INITIAL. lo_componente = bug->get_componente( ). IF zcl_componente_controller=>exist( lo_componente ) IS INITIAL. l_field = 'Component'(004). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * Necesario la persona que da de alta el Bug! IF l_str_bug-reporter IS INITIAL. l_field = 'Reporter'(005). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ELSE. * Reporter debe existir lo_usuario = bug->get_reporter( ). IF zcl_usuario_controller=>exist( lo_usuario ) IS INITIAL. l_field = 'Reporter'(005). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * Si se indica un desarrollador éste debe existir IF NOT l_str_bug-developer IS INITIAL. * Developer debe existir lo_usuario = bug->get_developer( ). IF zcl_usuario_controller=>exist( lo_usuario ) IS INITIAL. l_field = 'Developer'(006). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * does the assigned user exist? IF NOT l_str_bug-assigned IS INITIAL. * does the assigned user exist lo_usuario = bug->get_assigned( ). IF zcl_usuario_controller=>exist( lo_usuario ) IS INITIAL. l_field = 'Assigned'(017). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * Si se indica un tester éste debe existir IF NOT l_str_bug-tester IS INITIAL. * Tester debe existir lo_usuario = bug->get_tester( ). IF zcl_usuario_controller=>exist( lo_usuario ) IS INITIAL. l_field = 'Tester'(007). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * Necesario un estado IF l_str_bug-estado IS INITIAL. RAISE EXCEPTION TYPE zcx_validate_exception. ELSE. * Estado debe existir lo_estado = bug->get_estado( ). IF zcl_estado_controller=>exist( lo_estado ) IS INITIAL. l_field = 'Status'(008). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. ENDIF. * Necesario un resumen IF l_str_bug-resumen IS INITIAL. l_field = 'Short Text'(009). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. * Necesario un tipo IF l_str_bug-bugtype IS INITIAL. l_field = 'Bug Type'(010). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ELSE. * Tipo debe existir lo_bugtype = bug->get_bug_type( ). IF zcl_bugtype_controller=>exist( lo_bugtype ) IS INITIAL. l_field = 'Bug Type'(010). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * Necesaria una fecha de creación IF l_str_bug-creado IS INITIAL. l_field = 'Create Time'(011). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. lt_sections = bug->get_sections( ). CASE l_str_bug-bugtype. WHEN zcl_bugtype_controller=>bugtype_issue. * Si se trata de una incidencia, necesaria una estimación de la importancia IF l_str_bug-bugstype IS INITIAL. l_field = 'Bug SubType'(012). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ELSE. * Subtype Debe existir lo_subtype = bug->get_bug_subtype( ). IF zcl_bug_subtype_controller=>exist( lo_subtype ) IS INITIAL. l_field = 'Bug SubType'(012). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * Necesario haber rellenado las secciones de ""Problema detectado"" y ""Pasos para reproducirlo"" LOOP AT lt_sections INTO l_section. l_seccion_id = l_section-oref->get_id( ). IF l_seccion_id = zcl_bugsection_controller=>bugsection_problem OR l_seccion_id = zcl_bugsection_controller=>bugsection_steps_reproduce. ADD 1 TO l_section_ok. ENDIF. ENDLOOP. IF l_section_ok <> 2. l_field = 'Description and Steps to reproduce'(013). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. WHEN zcl_bugtype_controller=>bugtype_enhancement. * Wenn dies ein Verbesserung ist, eine Eingabe des Verbesserungtypes is nötig * Verhinderung des 0er Statuses IF l_str_bug-bugstype IS INITIAL. l_field = 'Bug SubType'(012). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ELSE. * Subtype Debe existir, existiert der Subtype? lo_subtype = bug->get_bug_subtype( ). IF zcl_bug_subtype_controller=>exist( lo_subtype ) IS INITIAL. l_field = 'Bug SubType'(012). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. * Si se trata de una mejora, necesaria una estimación inicial de horas * Wenn es eine Verbesserung ist, ist eine erste Einschätzung der erforderlichen Stunden IF l_str_bug-horas_est IS INITIAL. l_field = 'Estimated Time'(014). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. * Necesario la sección InfoAdicional * Erforderliche InfoAdicional Abschnitt LOOP AT lt_sections INTO l_section. l_seccion_id = l_section-oref->get_id( ). IF l_seccion_id = zcl_bugsection_controller=>bugsection_more_info. ADD 1 TO l_section_ok. ENDIF. ENDLOOP. IF l_section_ok <> 1. l_field = 'Additional Info'(015). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ENDIF. WHEN zcl_bugtype_controller=>bugtype_note. * Wenn dies ein Hinweis ist, eine Eingabe zur Schwere ist erforderlich * Verhinderung des 0er Statuses IF l_str_bug-bugstype IS INITIAL. l_field = 'Bug SubType'(012). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. ELSE. * Subtype Debe existir, existiert der Subtype? lo_subtype = bug->get_bug_subtype( ). IF zcl_bug_subtype_controller=>exist( lo_subtype ) IS INITIAL. l_field = 'Bug SubType'(012). RAISE EXCEPTION TYPE zcx_not_found_exception EXPORTING object = l_field. ENDIF. ENDIF. ENDCASE. CATCH zcx_not_found_exception INTO lo_not_found. RAISE EXCEPTION TYPE zcx_validate_exception EXPORTING textid = zcx_validate_exception=>zcx_validate_exception previous = lo_not_found. ENDTRY. ENDMETHOD. METHOD validate_on_delete. * Debe existir IF exist( bug ) = space. RAISE EXCEPTION TYPE zcx_validate_exception. ENDIF. ENDMETHOD. METHOD validate_on_update. DATA: l_str_bug TYPE zbt_bug, l_field TYPE string, lo_estado TYPE REF TO zcl_estado. validate_on_create( bug ). l_str_bug = entity_to_structure( bug ). lo_estado = bug->get_estado( ). * Si estado = cerrado -> tiene que tener fecha de cierre IF lo_estado->get_type( ) = zcl_estado_controller=>status_finished AND l_str_bug-finalizado IS INITIAL. l_field = 'End Date'(016). RAISE EXCEPTION TYPE zcx_mandatory_emptyfield EXPORTING field = l_field. * A la inversa también ELSEIF l_str_bug-finalizado IS NOT INITIAL AND lo_estado->get_type( ) <> zcl_estado_controller=>status_finished. RAISE EXCEPTION TYPE zcx_validate_exception. ENDIF. * Si estado = cerrado Y bug = mejora -> tiene que tener horas REALES IF lo_estado->get_type( ) = zcl_estado_controller=>status_finished AND l_str_bug-bugtype = zcl_bugtype_controller=>bugtype_enhancement AND l_str_bug-horas_rea IS INITIAL. RAISE EXCEPTION TYPE zcx_validate_exception. ENDIF. ENDMETHOD. ENDCLASS. ",12094,False,2459.5969629977963,median "//////////////////////////////////////////////////////////////////////////////// // // ADOBE SYSTEMS INCORPORATED // Copyright 2002-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 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: *
    *
  • selects an item in the drop-down list
  • *
  • clicks outside of the drop-down list
  • *
  • clicks the drop-down button while the drop-down list is * displayed
  • *
  • presses the ESC key while the drop-down list is displayed
  • *
* * @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 { var item:Object = selectedItem; return itemToLabel(item); } //-------------------------------------------------------------------------- // // 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.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.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; } } } ",16176,True,2877.320880978445,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.display.DisplayObjectContainer; 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 flash.utils.getTimer; import mx.automation.IAutomationObject; import flexlib.containers.accordionClasses.AccordionHeader; 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.managers.IFocusManagerComponent; import mx.managers.IHistoryManagerClient; import mx.core.IInvalidating; 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; FLEX_TARGET_VERSION::flex4 { import mx.geom.RoundedRectangle; } FLEX_TARGET_VERSION::flex3 { import mx.graphics.RoundedRectangle; } import mx.managers.HistoryManager; import mx.styles.StyleManager; import mx.styles.CSSStyleDeclaration; import mx.styles.StyleProxy; 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:Container = new Container(); 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():Container { if (selectedIndex == -1) return null; return Container(getChildAt(selectedIndex)); } /** * @private */ public function set selectedChild(value:Container):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++) { Container(getChildAt(i)).createComponentsFromDescriptors(); } } } /** * @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.numChildrenCreated == -1) // 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 Container) { var contentContainer:Container = Container(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 = Container(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. Container(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. Container(getChildAt(newIndex)).setVisible(false, true); if (oldIndex != -1) Container(getChildAt(oldIndex)).setVisible(false); instantiateChild(selectedChild); } else { if (tween) tween.endTween(); startTween(oldIndex, newIndex); } } /** * @private */ protected function instantiateChild(child:Container):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(); // 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) Container(getChildAt(oldSelectedIndex)).tweeningProperties = [""x"", ""y"", ""width"", ""height""]; Container(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:Container = Container(getChildAt(newSelectedIndex)); if (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:Container = Container(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:Container; 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 = Container(getChildAt(i)); content.cacheAsBitmap = false; content.scrollRect = null; content.visible = true; y += localContentHeight; } y += verticalGap; } if (oldSelectedIndex != -1) { content = Container(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(); Container(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(Container(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(Container(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 = Container(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"", Container(event.target).icon); //header.icon = Container(event.target).icon; } } } ",16197,True,2949.9705203585954,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 zcl_abapgit_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 zcx_abapgit_ajson_error. ENDCLASS. CLASS lcl_utils IMPLEMENTATION. METHOD validate_array_index. IF NOT iv_index CO '0123456789'. zcx_abapgit_ajson_error=>raise( |Cannot add non-numeric key [{ iv_index }] to array [{ iv_path }]| ). ENDIF. rv_index = iv_index. IF rv_index = 0. zcx_abapgit_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 zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. PRIVATE SECTION. TYPES: ty_stack_tt TYPE STANDARD TABLE OF REF TO zcl_abapgit_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 zcx_abapgit_ajson_error. METHODS _parse IMPORTING iv_json TYPE string RETURNING VALUE(rt_json_tree) TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error cx_sxml_error. ENDCLASS. CLASS lcl_json_parser IMPLEMENTATION. METHOD parse. DATA lx_sxml TYPE REF TO cx_sxml_error. TRY. rt_json_tree = _parse( iv_json ). CATCH cx_sxml_error INTO lx_sxml. zcx_abapgit_ajson_error=>raise( `SXML: ` && lx_sxml->get_text( ) ). ENDTRY. 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. zcx_abapgit_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 zcl_abapgit_ajson=>ty_nodes_ts iv_indent TYPE i DEFAULT 0 RETURNING VALUE(rv_json_string) TYPE string RAISING zcx_abapgit_ajson_error. CLASS-METHODS class_constructor. PRIVATE SECTION. CLASS-DATA gv_comma_with_lf TYPE string. DATA mt_json_tree TYPE zcl_abapgit_ajson=>ty_nodes_ts. 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 zcx_abapgit_ajson_error. METHODS stringify_node IMPORTING is_node TYPE zcl_abapgit_ajson=>ty_node RAISING zcx_abapgit_ajson_error. METHODS stringify_set IMPORTING iv_parent_path TYPE string iv_array TYPE abap_bool RAISING zcx_abapgit_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. 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 'array'. lv_item = lv_item && '['. WHEN 'object'. lv_item = lv_item && '{'. WHEN 'str'. lv_item = lv_item && |""{ escape( is_node-value ) }""|. WHEN 'bool' OR 'num'. lv_item = lv_item && is_node-value. WHEN 'null'. lv_item = lv_item && 'null'. WHEN OTHERS. zcx_abapgit_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 = 'array' OR is_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 = 'array' OR is_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 'array'. IF is_node-children > 0. stringify_set( iv_parent_path = lv_children_path iv_array = abap_true ). ENDIF. lv_tail = ']'. WHEN '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 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 find_loc IMPORTING iv_path TYPE string iv_name TYPE string OPTIONAL "" not mandatory iv_append_tables TYPE abap_bool DEFAULT abap_false RETURNING VALUE(r_ref) TYPE REF TO data RAISING zcx_abapgit_ajson_error. CLASS-METHODS bind CHANGING c_obj TYPE any co_instance TYPE REF TO lcl_json_to_abap. METHODS to_abap IMPORTING it_nodes TYPE zcl_abapgit_ajson=>ty_nodes_ts RAISING zcx_abapgit_ajson_error. PRIVATE SECTION. DATA mr_obj TYPE REF TO data. ENDCLASS. CLASS lcl_json_to_abap IMPLEMENTATION. METHOD bind. CREATE OBJECT co_instance. GET REFERENCE OF c_obj INTO co_instance->mr_obj. ENDMETHOD. METHOD to_abap. DATA lr_ref TYPE REF TO data. DATA lv_type TYPE c. DATA lx TYPE REF TO cx_root. FIELD-SYMBOLS LIKE LINE OF it_nodes. FIELD-SYMBOLS TYPE any. TRY. LOOP AT it_nodes ASSIGNING USING KEY array_index. lr_ref = find_loc( iv_append_tables = abap_true iv_path = -path iv_name = -name ). ASSIGN lr_ref->* TO . ASSERT sy-subrc = 0. DESCRIBE FIELD TYPE lv_type. CASE -type. WHEN 'null'. "" Do nothing WHEN 'bool'. = boolc( -value = 'true' ). WHEN 'num'. = -value. WHEN 'str'. IF lv_type = 'D' AND -value IS NOT INITIAL. 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|$)' IN -value SUBMATCHES lv_y lv_m lv_d. IF sy-subrc <> 0. zcx_abapgit_ajson_error=>raise( iv_msg = 'Unexpected date format' iv_location = -path && -name ). ENDIF. CONCATENATE lv_y lv_m lv_d INTO . ELSE. = -value. ENDIF. WHEN 'object'. IF NOT lv_type CO 'uv'. zcx_abapgit_ajson_error=>raise( iv_msg = 'Expected structure' iv_location = -path && -name ). ENDIF. WHEN 'array'. IF NOT lv_type CO 'h'. zcx_abapgit_ajson_error=>raise( iv_msg = 'Expected table' iv_location = -path && -name ). ENDIF. WHEN OTHERS. zcx_abapgit_ajson_error=>raise( iv_msg = |Unexpected JSON type [{ -type }]| iv_location = -path && -name ). ENDCASE. ENDLOOP. CATCH cx_sy_conversion_no_number INTO lx. zcx_abapgit_ajson_error=>raise( iv_msg = |Source is not a number| iv_location = -path && -name ). ENDTRY. ENDMETHOD. METHOD find_loc. DATA lt_path TYPE string_table. DATA lv_trace TYPE string. DATA lv_type TYPE c. DATA lv_size TYPE i. DATA lv_index TYPE i. FIELD-SYMBOLS TYPE any. FIELD-SYMBOLS TYPE STANDARD TABLE. FIELD-SYMBOLS TYPE any. FIELD-SYMBOLS LIKE LINE OF lt_path. SPLIT iv_path AT '/' INTO TABLE lt_path. DELETE lt_path WHERE table_line IS INITIAL. IF iv_name IS NOT INITIAL. APPEND iv_name TO lt_path. ENDIF. r_ref = mr_obj. LOOP AT lt_path ASSIGNING . lv_trace = lv_trace && '/' && . = to_upper( ). ASSIGN r_ref->* TO . ASSERT sy-subrc = 0. DESCRIBE FIELD TYPE lv_type. IF lv_type CA 'lr'. "" data/obj ref "" TODO maybe in future zcx_abapgit_ajson_error=>raise( iv_msg = 'Cannot assign to ref' iv_location = lv_trace ). ELSEIF lv_type = 'h'. "" table IF NOT CO '0123456789'. zcx_abapgit_ajson_error=>raise( iv_msg = 'Need index to access tables' iv_location = lv_trace ). ENDIF. lv_index = . ASSIGN r_ref->* TO
. ASSERT sy-subrc = 0. lv_size = lines(
). IF iv_append_tables = abap_true AND lv_index = lv_size + 1. APPEND INITIAL LINE TO
. ENDIF. READ TABLE
INDEX lv_index ASSIGNING . IF sy-subrc <> 0. zcx_abapgit_ajson_error=>raise( iv_msg = 'Index not found in table' iv_location = lv_trace ). ENDIF. ELSEIF lv_type CA 'uv'. "" structure ASSIGN COMPONENT OF STRUCTURE TO . IF sy-subrc <> 0. zcx_abapgit_ajson_error=>raise( iv_msg = 'Path not found' iv_location = lv_trace ). ENDIF. ELSE. zcx_abapgit_ajson_error=>raise( iv_msg = 'Target is not deep' iv_location = lv_trace ). ENDIF. GET REFERENCE OF INTO r_ref. ENDLOOP. 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 zcl_abapgit_ajson=>ty_path_name OPTIONAL iv_array_index TYPE i DEFAULT 0 RETURNING VALUE(rt_nodes) TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. CLASS-METHODS insert_with_type IMPORTING iv_data TYPE any iv_type TYPE string is_prefix TYPE zcl_abapgit_ajson=>ty_path_name OPTIONAL iv_array_index TYPE i DEFAULT 0 RETURNING VALUE(rt_nodes) TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. CLASS-METHODS class_constructor. PRIVATE SECTION. CLASS-DATA gv_ajson_absolute_type_name TYPE string. METHODS convert_any IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zcl_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. METHODS convert_ajson IMPORTING io_json TYPE REF TO zcl_abapgit_ajson is_prefix TYPE zcl_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zcl_abapgit_ajson=>ty_nodes_tt. METHODS convert_value IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zcl_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. METHODS convert_ref IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zcl_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. METHODS convert_struc IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zcl_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zcl_abapgit_ajson=>ty_nodes_tt cs_root TYPE zcl_abapgit_ajson=>ty_node OPTIONAL RAISING zcx_abapgit_ajson_error. METHODS convert_table IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zcl_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_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 zcl_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zcl_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. ENDCLASS. CLASS lcl_abap_to_json IMPLEMENTATION. METHOD class_constructor. DATA lo_dummy TYPE REF TO zcl_abapgit_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->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 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 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 CHANGING ct_nodes = ct_nodes ). WHEN OTHERS. IF io_type->type_kind = cl_abap_typedescr=>typekind_dref. convert_ref( EXPORTING iv_data = iv_data io_type = io_type is_prefix = is_prefix iv_index = iv_index 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. zcx_abapgit_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. ct_nodes = io_json->mt_json_tree. LOOP AT 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. FIELD-SYMBOLS LIKE LINE OF ct_nodes. APPEND INITIAL LINE TO ct_nodes ASSIGNING . -path = is_prefix-path. -name = is_prefix-name. -index = iv_index. IF io_type->absolute_name = '\\TYPE-POOL=ABAP\\TYPE=ABAP_BOOL' OR io_type->absolute_name = '\\TYPE=XFELD'. -type = 'bool'. IF iv_data IS NOT INITIAL. -value = 'true'. ELSE. -value = 'false'. ENDIF. ELSEIF io_type->type_kind CO 'CNgXyDT'. "" Char like, date/time, xstring -type = 'str'. -value = |{ iv_data }|. ELSEIF io_type->type_kind CO 'bsI8PaeF'. "" Numeric -type = 'num'. -value = |{ iv_data }|. ELSE. zcx_abapgit_ajson_error=>raise( |Unexpected elemetary type [{ io_type->type_kind }] @{ is_prefix-path && is_prefix-name }| ). ENDIF. ENDMETHOD. METHOD convert_ref. FIELD-SYMBOLS LIKE LINE OF ct_nodes. APPEND INITIAL LINE TO ct_nodes ASSIGNING . -path = is_prefix-path. -name = is_prefix-name. -index = iv_index. IF iv_data IS INITIAL. -type = 'null'. -value = 'null'. ELSE. "" TODO support data references zcx_abapgit_ajson_error=>raise( |Unexpected reference @{ is_prefix-path && is_prefix-name }| ). ENDIF. 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. FIELD-SYMBOLS LIKE LINE OF ct_nodes. FIELD-SYMBOLS LIKE LINE OF lt_comps. FIELD-SYMBOLS TYPE any. 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 IF cs_root IS SUPPLIED. "" call for include structure ASSIGN cs_root TO . ELSE. "" First call APPEND INITIAL LINE TO ct_nodes ASSIGNING . -path = is_prefix-path. -name = is_prefix-name. -type = 'object'. -index = iv_index. ENDIF. 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. convert_any( EXPORTING iv_data = io_type = -type is_prefix = ls_next_prefix 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. FIELD-SYMBOLS LIKE LINE OF ct_nodes. FIELD-SYMBOLS TYPE ANY TABLE. FIELD-SYMBOLS TYPE any. lo_table ?= io_type. lo_ltype = lo_table->get_table_line_type( ). APPEND INITIAL LINE TO ct_nodes ASSIGNING . -path = is_prefix-path. -name = is_prefix-name. -type = 'array'. -index = iv_index. ls_next_prefix-path = is_prefix-path && is_prefix-name && '/'. ASSIGN iv_data TO . LOOP AT ASSIGNING . ls_next_prefix-name = to_lower( |{ sy-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. 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->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. FIELD-SYMBOLS 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 = 'bool' AND iv_data <> 'true' AND iv_data <> 'false'. zcx_abapgit_ajson_error=>raise( |Unexpected boolean value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type = 'null' AND iv_data IS NOT INITIAL. zcx_abapgit_ajson_error=>raise( |Unexpected null value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type = 'num' AND iv_data CN '0123456789. E+-'. zcx_abapgit_ajson_error=>raise( |Unexpected numeric value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type <> 'str' AND iv_type <> 'bool' AND iv_type <> 'null' AND iv_type <> 'num'. zcx_abapgit_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 <> 'num'. zcx_abapgit_ajson_error=>raise( |Unexpected value for numeric [{ iv_data }] @{ lv_prefix }| ). ENDIF. ELSE. zcx_abapgit_ajson_error=>raise( |Unexpected type [{ io_type->type_kind }] @{ lv_prefix }| ). ENDIF. APPEND INITIAL LINE TO ct_nodes ASSIGNING . -path = is_prefix-path. -name = is_prefix-name. -index = iv_index. -value = iv_data. -type = iv_type. ENDMETHOD. ENDCLASS. ",7956,False,1700.5114598219957,median "/* Feathers Copyright 2012-2015 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 ../../../help/tiled-columns-layout.html How to use TiledColumnsLayout with Feathers containers */ 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,2942.724251919887,median "CLASS zcl_abapgit_object_tabl DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_object . ALIASES mo_files FOR zif_abapgit_object~mo_files . PROTECTED SECTION. TYPES: BEGIN OF ty_segment_definition, segmentheader TYPE edisegmhd, segmentdefinition TYPE edisegmdef, segmentstructures TYPE STANDARD TABLE OF edisegstru WITH DEFAULT KEY, END OF ty_segment_definition. TYPES: ty_segment_definitions TYPE STANDARD TABLE OF ty_segment_definition WITH DEFAULT KEY. TYPES: BEGIN OF ty_tabl_extras, tddat TYPE tddat, END OF ty_tabl_extras. ""! get additional data like table authorization group ""! @parameter iv_tabname | name of the table METHODS read_extras IMPORTING iv_tabname TYPE ddobjname RETURNING VALUE(rs_tabl_extras) TYPE ty_tabl_extras. ""! Update additional data ""! @parameter iv_tabname | name of the table ""! @parameter is_tabl_extras | additional table data METHODS update_extras IMPORTING iv_tabname TYPE ddobjname is_tabl_extras TYPE ty_tabl_extras. ""! Delete additional data ""! @parameter iv_tabname | name of the table METHODS delete_extras IMPORTING iv_tabname TYPE ddobjname. ""! Serialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @raising zcx_abapgit_exception | Exceptions METHODS serialize_idoc_segment IMPORTING io_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception. ""! Deserialize IDoc Segment type/definition if exits ""! @parameter io_xml | XML writer ""! @parameter iv_package | Target package ""! @parameter rv_deserialized | It's a segment and was desserialized ""! @raising zcx_abapgit_exception | Exceptions METHODS deserialize_idoc_segment IMPORTING io_xml TYPE REF TO zif_abapgit_xml_input iv_package TYPE devclass RETURNING VALUE(rv_deserialized) TYPE abap_bool RAISING zcx_abapgit_exception. ""! Delete the IDoc Segment type if exists ""! @parameter rv_deleted | It's a segment and was deleted ""! @raising zcx_abapgit_exception | Exceptions METHODS delete_idoc_segment RETURNING VALUE(rv_deleted) TYPE abap_bool RAISING zcx_abapgit_exception. PRIVATE SECTION. TYPES: ty_dd03p_tt TYPE STANDARD TABLE OF dd03p . TYPES: BEGIN OF ty_dd02_text, ddlanguage TYPE dd02t-ddlanguage, ddtext TYPE dd02t-ddtext, END OF ty_dd02_text, ty_dd02_texts TYPE STANDARD TABLE OF ty_dd02_text. CONSTANTS c_longtext_id_tabl TYPE dokil-id VALUE 'TB' ##NO_TEXT. CONSTANTS: BEGIN OF c_s_dataname, segment_definition TYPE string VALUE 'SEGMENT_DEFINITION', tabl_extras TYPE string VALUE 'TABL_EXTRAS', END OF c_s_dataname. METHODS clear_dd03p_fields CHANGING !ct_dd03p TYPE ty_dd03p_tt . ""! Check if structure is an IDoc segment ""! @parameter rv_is_idoc_segment | It's an IDoc segment or not METHODS is_idoc_segment RETURNING VALUE(rv_is_idoc_segment) TYPE abap_bool. METHODS clear_dd03p_fields_common CHANGING !cs_dd03p TYPE dd03p . METHODS clear_dd03p_fields_dataelement CHANGING !cs_dd03p TYPE dd03p . METHODS: serialize_texts IMPORTING io_xml TYPE REF TO zif_abapgit_xml_output RAISING zcx_abapgit_exception, deserialize_texts IMPORTING io_xml TYPE REF TO zif_abapgit_xml_input is_dd02v TYPE dd02v RAISING zcx_abapgit_exception, is_db_table_category IMPORTING iv_tabclass TYPE dd02l-tabclass RETURNING VALUE(rv_is_db_table_type) TYPE dd02l-tabclass. ENDCLASS. CLASS zcl_abapgit_object_tabl IMPLEMENTATION. METHOD clear_dd03p_fields. CONSTANTS lc_comptype_dataelement TYPE comptype VALUE 'E'. DATA: lv_masklen TYPE c LENGTH 4. FIELD-SYMBOLS: TYPE dd03p. * remove nested structures DELETE ct_dd03p WHERE depth <> '00'. * remove fields from .INCLUDEs DELETE ct_dd03p WHERE adminfield <> '0'. LOOP AT ct_dd03p ASSIGNING WHERE NOT rollname IS INITIAL. clear_dd03p_fields_common( CHANGING cs_dd03p = ). lv_masklen = -masklen. IF lv_masklen = '' OR NOT lv_masklen CO '0123456789'. * make sure the field contains valid data, or the XML will dump CLEAR -masklen. ENDIF. IF -comptype = lc_comptype_dataelement. clear_dd03p_fields_dataelement( CHANGING cs_dd03p = ). ENDIF. IF -shlporigin = 'D'. * search help from domain CLEAR: -shlpfield, -shlpname. ENDIF. * XML output assumes correct field content IF -routputlen = ' '. CLEAR -routputlen. ENDIF. ENDLOOP. ENDMETHOD. METHOD clear_dd03p_fields_common. CLEAR: cs_dd03p-ddlanguage, cs_dd03p-dtelmaster, cs_dd03p-logflag, cs_dd03p-ddtext, cs_dd03p-reservedte, cs_dd03p-reptext, cs_dd03p-scrtext_s, cs_dd03p-scrtext_m, cs_dd03p-scrtext_l. ENDMETHOD. METHOD clear_dd03p_fields_dataelement. * type specified via data element CLEAR: cs_dd03p-domname, cs_dd03p-inttype, cs_dd03p-intlen, cs_dd03p-mask, cs_dd03p-memoryid, cs_dd03p-headlen, cs_dd03p-scrlen1, cs_dd03p-scrlen2, cs_dd03p-scrlen3, cs_dd03p-datatype, cs_dd03p-leng, cs_dd03p-outputlen, cs_dd03p-deffdname, cs_dd03p-convexit, cs_dd03p-entitytab, cs_dd03p-dommaster, cs_dd03p-domname3l, cs_dd03p-decimals, cs_dd03p-lowercase, cs_dd03p-signflag. ENDMETHOD. METHOD delete_extras. DELETE FROM tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD delete_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. IF is_idoc_segment( ) = abap_false. rv_deleted = abap_false. RETURN. ""previous XML version or no IDoc segment ENDIF. rv_deleted = abap_true. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_DELETE' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD deserialize_idoc_segment. DATA lv_result LIKE sy-subrc. DATA lt_segment_definitions TYPE ty_segment_definitions. DATA lv_package TYPE devclass. DATA lv_uname TYPE sy-uname. FIELD-SYMBOLS TYPE ty_segment_definition. rv_deserialized = abap_false. TRY. io_xml->read( EXPORTING iv_name = c_s_dataname-segment_definition CHANGING cg_data = lt_segment_definitions ). CATCH zcx_abapgit_exception. RETURN. ""previous XML version or no IDoc segment ENDTRY. IF lines( lt_segment_definitions ) = 0. RETURN. ""no IDoc segment ENDIF. rv_deserialized = abap_true. lv_package = iv_package. LOOP AT lt_segment_definitions ASSIGNING . -segmentheader-presp = -segmentheader-pwork = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = -segmentheader-segtyp IMPORTING result = lv_result EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. CALL FUNCTION 'SEGMENT_CREATE' IMPORTING segmentdefinition = -segmentdefinition TABLES segmentstructure = -segmentstructures CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. ELSE. CALL FUNCTION 'SEGMENT_MODIFY' CHANGING segmentheader = -segmentheader devclass = lv_package EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. CALL FUNCTION 'SEGMENTDEFINITION_MODIFY' TABLES segmentstructure = -segmentstructures CHANGING segmentdefinition = -segmentdefinition EXCEPTIONS OTHERS = 1. ENDIF. ENDIF. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDLOOP. lv_uname = cl_abap_syst=>get_user_name( ). CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_test_modus = abap_false wi_tadir_pgmid = 'R3TR' wi_tadir_object = ms_item-obj_type wi_tadir_obj_name = ms_item-obj_name wi_tadir_author = lv_uname wi_tadir_devclass = iv_package wi_tadir_masterlang = mv_language iv_set_edtflag = abap_true iv_delflag = abap_false EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from TR_TADIR_INTERFACE' ). ENDIF. ENDMETHOD. METHOD deserialize_texts. DATA: lv_name TYPE ddobjname, ls_dd02v_tmp TYPE dd02v, lt_i18n_langs TYPE TABLE OF langu, lt_dd02_texts TYPE ty_dd02_texts. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. lv_name = ms_item-obj_name. io_xml->read( EXPORTING iv_name = 'I18N_LANGS' CHANGING cg_data = lt_i18n_langs ). io_xml->read( EXPORTING iv_name = 'DD02_TEXTS' CHANGING cg_data = lt_dd02_texts ). SORT lt_i18n_langs. SORT lt_dd02_texts BY ddlanguage. "" Optimization LOOP AT lt_i18n_langs ASSIGNING . "" Table description ls_dd02v_tmp = is_dd02v. READ TABLE lt_dd02_texts ASSIGNING WITH KEY ddlanguage = . IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |DD02_TEXTS cannot find lang { } in XML| ). ENDIF. MOVE-CORRESPONDING TO ls_dd02v_tmp. CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v_tmp EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |error from DDIF_TABL_PUT @TEXTS, { sy-subrc }| ). ENDIF. ENDLOOP. ENDMETHOD. METHOD is_db_table_category. "" values from domain TABCLASS rv_is_db_table_type = boolc( iv_tabclass = 'TRANSP' OR iv_tabclass = 'CLUSTER' OR iv_tabclass = 'POOL' ). ENDMETHOD. METHOD is_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. lv_segment_type = ms_item-obj_name. SELECT SINGLE segtyp FROM edisegment INTO lv_segment_type WHERE segtyp = lv_segment_type. rv_is_idoc_segment = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD read_extras. SELECT SINGLE * FROM tddat INTO rs_tabl_extras-tddat WHERE tabname = iv_tabname. ENDMETHOD. METHOD serialize_idoc_segment. DATA lv_segment_type TYPE edilsegtyp. DATA lv_result LIKE sy-subrc. DATA lv_devclass TYPE devclass. DATA lt_segmentdefinitions TYPE STANDARD TABLE OF edisegmdef. DATA ls_segment_definition TYPE ty_segment_definition. DATA lt_segment_definitions TYPE ty_segment_definitions. FIELD-SYMBOLS: TYPE edisegmdef. IF is_idoc_segment( ) = abap_false. RETURN. ENDIF. lv_segment_type = ms_item-obj_name. CALL FUNCTION 'SEGMENT_READ' EXPORTING segmenttyp = lv_segment_type IMPORTING result = lv_result TABLES segmentdefinition = lt_segmentdefinitions EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. LOOP AT lt_segmentdefinitions ASSIGNING . CLEAR ls_segment_definition. CALL FUNCTION 'SEGMENTDEFINITION_READ' EXPORTING segmenttyp = -segtyp IMPORTING result = lv_result devclass = lv_devclass segmentheader = ls_segment_definition-segmentheader segmentdefinition = ls_segment_definition-segmentdefinition TABLES segmentstructure = ls_segment_definition-segmentstructures CHANGING version = -version EXCEPTIONS no_authority = 1 segment_not_existing = 2 OTHERS = 3. IF sy-subrc <> 0 OR lv_result <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentdefinition ). zcl_abapgit_object_idoc=>clear_idoc_segement_fields( CHANGING cg_structure = ls_segment_definition-segmentheader ). APPEND ls_segment_definition TO lt_segment_definitions. ENDLOOP. io_xml->add( iv_name = c_s_dataname-segment_definition ig_data = lt_segment_definitions ). ENDMETHOD. METHOD serialize_texts. DATA: lv_name TYPE ddobjname, lv_index TYPE i, ls_dd02v TYPE dd02v, lt_dd02_texts TYPE ty_dd02_texts, lt_i18n_langs TYPE TABLE OF langu. FIELD-SYMBOLS: LIKE LINE OF lt_i18n_langs, LIKE LINE OF lt_dd02_texts. IF io_xml->i18n_params( )-main_language_only = abap_true. RETURN. ENDIF. lv_name = ms_item-obj_name. "" Collect additional languages, skip main lang - it was serialized already SELECT DISTINCT ddlanguage AS langu INTO TABLE lt_i18n_langs FROM dd02v WHERE tabname = lv_name AND ddlanguage <> mv_language. ""#EC CI_SUBRC LOOP AT lt_i18n_langs ASSIGNING . lv_index = sy-tabix. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = IMPORTING dd02v_wa = ls_dd02v EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0 OR ls_dd02v-ddlanguage IS INITIAL. DELETE lt_i18n_langs INDEX lv_index. "" Don't save this lang CONTINUE. ENDIF. APPEND INITIAL LINE TO lt_dd02_texts ASSIGNING . MOVE-CORRESPONDING ls_dd02v TO . ENDLOOP. SORT lt_i18n_langs ASCENDING. SORT lt_dd02_texts BY ddlanguage ASCENDING. IF lines( lt_i18n_langs ) > 0. io_xml->add( iv_name = 'I18N_LANGS' ig_data = lt_i18n_langs ). io_xml->add( iv_name = 'DD02_TEXTS' ig_data = lt_dd02_texts ). ENDIF. ENDMETHOD. METHOD update_extras. IF is_tabl_extras-tddat IS INITIAL. delete_extras( iv_tabname ). ELSE. MODIFY tddat FROM is_tabl_extras-tddat. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~changed_by. TYPES: BEGIN OF ty_data, as4user TYPE dd02l-as4user, as4date TYPE dd02l-as4date, as4time TYPE dd02l-as4time, END OF ty_data. DATA: lt_data TYPE STANDARD TABLE OF ty_data WITH DEFAULT KEY, ls_data LIKE LINE OF lt_data. SELECT as4user as4date as4time FROM dd02l INTO TABLE lt_data WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd09l WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SELECT as4user as4date as4time APPENDING TABLE lt_data FROM dd12l WHERE sqltab = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. SORT lt_data BY as4date DESCENDING as4time DESCENDING. READ TABLE lt_data INDEX 1 INTO ls_data. IF sy-subrc = 0. rv_user = ls_data-as4user. ELSE. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lv_objname TYPE rsedd0-ddobjname, lv_no_ask TYPE abap_bool, lv_subrc TYPE sy-subrc, BEGIN OF ls_dd02l, tabname TYPE dd02l-tabname, tabclass TYPE dd02l-tabclass, sqltab TYPE dd02l-sqltab, END OF ls_dd02l. IF zif_abapgit_object~exists( ) = abap_false. "" Proxies e.g. delete on its own, nothing todo here then. RETURN. ENDIF. lv_objname = ms_item-obj_name. IF delete_idoc_segment( ) = abap_false. lv_no_ask = abap_true. SELECT SINGLE tabname tabclass sqltab FROM dd02l INTO CORRESPONDING FIELDS OF ls_dd02l WHERE tabname = ms_item-obj_name AND as4local = 'A' AND as4vers = '0000'. IF sy-subrc = 0 AND is_db_table_category( ls_dd02l-tabclass ) = abap_true. CALL FUNCTION 'DD_EXISTS_DATA' EXPORTING reftab = ls_dd02l-sqltab tabclass = ls_dd02l-tabclass tabname = ls_dd02l-tabname IMPORTING subrc = lv_subrc EXCEPTIONS missing_reftab = 1 sql_error = 2 buffer_overflow = 3 unknown_error = 4 OTHERS = 5. IF sy-subrc = 0 AND lv_subrc = 0. lv_no_ask = abap_false. ENDIF. ENDIF. delete_ddic( iv_objtype = 'T' iv_no_ask = lv_no_ask ). delete_longtexts( c_longtext_id_tabl ). delete_extras( lv_objname ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lv_name TYPE ddobjname, lv_tname TYPE trobj_name, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE TABLE OF dd03p, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, ls_dd17v LIKE LINE OF lt_dd17v, lt_secondary LIKE lt_dd17v, lt_dd35v TYPE TABLE OF dd35v, lt_dd36m TYPE dd36mttyp, ls_dd12v LIKE LINE OF lt_dd12v, lv_refs TYPE abap_bool, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: TYPE dd03p. IF deserialize_idoc_segment( io_xml = io_xml iv_package = iv_package ) = abap_false. io_xml->read( EXPORTING iv_name = 'DD02V' CHANGING cg_data = ls_dd02v ). io_xml->read( EXPORTING iv_name = 'DD09L' CHANGING cg_data = ls_dd09l ). io_xml->read( EXPORTING iv_name = 'DD03P_TABLE' CHANGING cg_data = lt_dd03p ). "" DDIC Step: Replace REF TO class/interface with generic reference to avoid cyclic dependency LOOP AT lt_dd03p ASSIGNING WHERE datatype = 'REF'. IF iv_step = zif_abapgit_object=>gc_step_id-ddic. -rollname = 'OBJECT'. ELSE. lv_refs = abap_true. ENDIF. ENDLOOP. io_xml->read( EXPORTING iv_name = 'DD05M_TABLE' CHANGING cg_data = lt_dd05m ). io_xml->read( EXPORTING iv_name = 'DD08V_TABLE' CHANGING cg_data = lt_dd08v ). io_xml->read( EXPORTING iv_name = 'DD12V' CHANGING cg_data = lt_dd12v ). io_xml->read( EXPORTING iv_name = 'DD17V' CHANGING cg_data = lt_dd17v ). io_xml->read( EXPORTING iv_name = 'DD35V_TALE' CHANGING cg_data = lt_dd35v ). io_xml->read( EXPORTING iv_name = 'DD36M' CHANGING cg_data = lt_dd36m ). "" DDIC Step: Remove references to search helps and foreign keys IF iv_step = zif_abapgit_object=>gc_step_id-ddic. CLEAR: lt_dd08v, lt_dd35v, lt_dd36m. ENDIF. IF iv_step = zif_abapgit_object=>gc_step_id-late AND lv_refs = abap_false AND lines( lt_dd35v ) = 0 AND lines( lt_dd08v ) = 0. RETURN. "" already active ENDIF. corr_insert( iv_package = iv_package ig_object_class = 'DICT' ). lv_name = ms_item-obj_name. "" type conversion CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING name = lv_name dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS tabl_not_found = 1 name_inconsistent = 2 tabl_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_TABL_PUT' ). ENDIF. zcl_abapgit_objects_activation=>add_item( ms_item ). * handle indexes LOOP AT lt_dd12v INTO ls_dd12v. * todo, call corr_insert? CLEAR lt_secondary. LOOP AT lt_dd17v INTO ls_dd17v WHERE sqltab = ls_dd12v-sqltab AND indexname = ls_dd12v-indexname. APPEND ls_dd17v TO lt_secondary. ENDLOOP. CALL FUNCTION 'DDIF_INDX_PUT' EXPORTING name = ls_dd12v-sqltab id = ls_dd12v-indexname dd12v_wa = ls_dd12v TABLES dd17v_tab = lt_secondary EXCEPTIONS indx_not_found = 1 name_inconsistent = 2 indx_inconsistent = 3 put_failure = 4 put_refused = 5 OTHERS = 6. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_INDX_PUT' ). ENDIF. CALL FUNCTION 'DD_DD_TO_E071' EXPORTING type = 'INDX' name = ls_dd12v-sqltab id = ls_dd12v-indexname IMPORTING obj_name = lv_tname. zcl_abapgit_objects_activation=>add( iv_type = 'INDX' iv_name = lv_tname ). ENDLOOP. deserialize_texts( io_xml = io_xml is_dd02v = ls_dd02v ). deserialize_longtexts( io_xml ). io_xml->read( EXPORTING iv_name = c_s_dataname-tabl_extras CHANGING cg_data = ls_extras ). update_extras( iv_tabname = lv_name is_tabl_extras = ls_extras ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_tabname TYPE dd02l-tabname. lv_tabname = ms_item-obj_name. "" Check nametab because it's fast CALL FUNCTION 'DD_GET_NAMETAB_HEADER' EXPORTING tabname = lv_tabname EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc <> 0. "" Check for new, inactive, or modified versions that might not be in nametab SELECT SINGLE tabname FROM dd02l INTO lv_tabname WHERE tabname = lv_tabname. ENDIF. rv_bool = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. DATA: li_local_version_output TYPE REF TO zif_abapgit_xml_output, li_local_version_input TYPE REF TO zif_abapgit_xml_input. CREATE OBJECT li_local_version_output TYPE zcl_abapgit_xml_output. zif_abapgit_object~serialize( li_local_version_output ). CREATE OBJECT li_local_version_input TYPE zcl_abapgit_xml_input EXPORTING iv_xml = li_local_version_output->render( ). CREATE OBJECT ri_comparator TYPE zcl_abapgit_object_tabl_compar EXPORTING ii_local = li_local_version_input. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-ddic TO rt_steps. APPEND zif_abapgit_object=>gc_step_id-late TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). rs_metadata-ddic = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'ESDICT' iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. jump_se11( iv_radio = 'RSRD1-DDTYPE' iv_field = 'RSRD1-DDTYPE_VAL' ). ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lv_name TYPE ddobjname, ls_dd02v TYPE dd02v, ls_dd09l TYPE dd09l, lt_dd03p TYPE ty_dd03p_tt, lt_dd05m TYPE TABLE OF dd05m, lt_dd08v TYPE TABLE OF dd08v, lt_dd12v TYPE dd12vtab, lt_dd17v TYPE dd17vtab, lt_dd35v TYPE TABLE OF dd35v, lv_index LIKE sy-index, lt_dd36m TYPE dd36mttyp, ls_extras TYPE ty_tabl_extras. FIELD-SYMBOLS: LIKE LINE OF lt_dd12v, LIKE LINE OF lt_dd05m, LIKE LINE OF lt_dd36m, TYPE any. lv_name = ms_item-obj_name. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = lv_name langu = mv_language IMPORTING dd02v_wa = ls_dd02v dd09l_wa = ls_dd09l TABLES dd03p_tab = lt_dd03p dd05m_tab = lt_dd05m dd08v_tab = lt_dd08v dd12v_tab = lt_dd12v dd17v_tab = lt_dd17v dd35v_tab = lt_dd35v dd36m_tab = lt_dd36m EXCEPTIONS illegal_input = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'error from DDIF_TABL_GET' ). ENDIF. IF ls_dd02v IS INITIAL. RETURN. "" object does not exits ENDIF. CLEAR: ls_dd02v-as4user, ls_dd02v-as4date, ls_dd02v-as4time. * reset numeric field, so XML does not crash IF ls_dd02v-prozpuff = ''. CLEAR ls_dd02v-prozpuff. ENDIF. IF ls_dd02v-datmin = ''. CLEAR ls_dd02v-datmin. ENDIF. IF ls_dd02v-datmax = ''. CLEAR ls_dd02v-datmax. ENDIF. IF ls_dd02v-datavg = ''. CLEAR ls_dd02v-datavg. ENDIF. CLEAR: ls_dd09l-as4user, ls_dd09l-as4date, ls_dd09l-as4time. ASSIGN COMPONENT 'ROWORCOLST' OF STRUCTURE ls_dd09l TO . IF sy-subrc = 0 AND = 'C'. CLEAR . ""To avoid diff errors. This field doesn't exists in all releases ENDIF. LOOP AT lt_dd12v ASSIGNING . CLEAR: -as4user, -as4date, -as4time. ENDLOOP. clear_dd03p_fields( CHANGING ct_dd03p = lt_dd03p ). * remove foreign keys inherited from .INCLUDEs DELETE lt_dd08v WHERE noinherit = 'N'. LOOP AT lt_dd05m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd08v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd05m INDEX lv_index. ENDIF. ENDLOOP. * remove inherited search helps DELETE lt_dd35v WHERE shlpinher = abap_true. LOOP AT lt_dd36m ASSIGNING . lv_index = sy-tabix. READ TABLE lt_dd35v WITH KEY fieldname = -fieldname TRANSPORTING NO FIELDS. IF sy-subrc <> 0. DELETE lt_dd36m INDEX lv_index. ENDIF. ENDLOOP. io_xml->add( iv_name = 'DD02V' ig_data = ls_dd02v ). IF NOT ls_dd09l IS INITIAL. io_xml->add( iv_name = 'DD09L' ig_data = ls_dd09l ). ENDIF. io_xml->add( iv_name = 'DD03P_TABLE' ig_data = lt_dd03p ). io_xml->add( iv_name = 'DD05M_TABLE' ig_data = lt_dd05m ). io_xml->add( iv_name = 'DD08V_TABLE' ig_data = lt_dd08v ). io_xml->add( iv_name = 'DD12V' ig_data = lt_dd12v ). io_xml->add( iv_name = 'DD17V' ig_data = lt_dd17v ). io_xml->add( iv_name = 'DD35V_TALE' ig_data = lt_dd35v ). io_xml->add( iv_name = 'DD36M' ig_data = lt_dd36m ). serialize_texts( io_xml ). serialize_longtexts( ii_xml = io_xml iv_longtext_id = c_longtext_id_tabl ). serialize_idoc_segment( io_xml ). ls_extras = read_extras( lv_name ). io_xml->add( iv_name = c_s_dataname-tabl_extras ig_data = ls_extras ). ENDMETHOD. ENDCLASS. ",8404,False,1880.8835343056364,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 zif_abapgit_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 zcx_abapgit_ajson_error. ENDCLASS. CLASS lcl_utils IMPLEMENTATION. METHOD validate_array_index. IF NOT iv_index CO '0123456789'. zcx_abapgit_ajson_error=>raise( |Cannot add non-numeric key [{ iv_index }] to array [{ iv_path }]| ). ENDIF. rv_index = iv_index. IF rv_index = 0. zcx_abapgit_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 zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. PRIVATE SECTION. TYPES: ty_stack_tt TYPE STANDARD TABLE OF REF TO zif_abapgit_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 zcx_abapgit_ajson_error. METHODS _parse IMPORTING iv_json TYPE string RETURNING VALUE(rt_json_tree) TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_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 ). zcx_abapgit_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. zcx_abapgit_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. zcx_abapgit_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 zif_abapgit_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 zcx_abapgit_ajson_error. CLASS-METHODS class_constructor. PRIVATE SECTION. CLASS-DATA gv_comma_with_lf TYPE string. DATA mt_json_tree TYPE zif_abapgit_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 zcx_abapgit_ajson_error. METHODS stringify_node IMPORTING is_node TYPE zif_abapgit_ajson=>ty_node RAISING zcx_abapgit_ajson_error. METHODS stringify_set IMPORTING iv_parent_path TYPE string iv_array TYPE abap_bool RAISING zcx_abapgit_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 zif_abapgit_ajson=>node_type-array. lv_item = lv_item && '['. WHEN zif_abapgit_ajson=>node_type-object. lv_item = lv_item && '{'. WHEN zif_abapgit_ajson=>node_type-string. lv_item = lv_item && |""{ escape( is_node-value ) }""|. WHEN zif_abapgit_ajson=>node_type-boolean OR zif_abapgit_ajson=>node_type-number. lv_item = lv_item && is_node-value. WHEN zif_abapgit_ajson=>node_type-null. lv_item = lv_item && 'null'. WHEN OTHERS. zcx_abapgit_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 = zif_abapgit_ajson=>node_type-array OR is_node-type = zif_abapgit_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 = zif_abapgit_ajson=>node_type-array OR is_node-type = zif_abapgit_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 zif_abapgit_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 zif_abapgit_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 zif_abapgit_ajson_mapping OPTIONAL. METHODS to_abap IMPORTING it_nodes TYPE zif_abapgit_ajson=>ty_nodes_ts CHANGING c_container TYPE any RAISING zcx_abapgit_ajson_error. METHODS to_timestamp IMPORTING iv_value TYPE zif_abapgit_ajson=>ty_node-value RETURNING VALUE(rv_result) TYPE timestamp RAISING zcx_abapgit_ajson_error. METHODS to_date IMPORTING iv_value TYPE zif_abapgit_ajson=>ty_node-value RETURNING VALUE(rv_result) TYPE d RAISING zcx_abapgit_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 zif_abapgit_ajson=>ty_nodes_ts. DATA mi_custom_mapping TYPE REF TO zif_abapgit_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 zcx_abapgit_ajson_error. METHODS value_to_abap IMPORTING is_node TYPE zif_abapgit_ajson=>ty_node is_node_type TYPE ty_type_cache i_container_ref TYPE REF TO data RAISING zcx_abapgit_ajson_error cx_sy_conversion_no_number. METHODS get_node_type IMPORTING is_node TYPE zif_abapgit_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 zcx_abapgit_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. zcx_abapgit_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. zcx_abapgit_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 zcx_abapgit_ajson_error. DATA lx_root TYPE REF TO cx_root. DATA lr_target_field TYPE REF TO data. FIELD-SYMBOLS TYPE zif_abapgit_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 zcx_abapgit_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 zcx_abapgit_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. zcx_abapgit_ajson_error=>raise( 'Unexpected parent type' ). ENDCASE. "" Process value assignment CASE -type. WHEN zif_abapgit_ajson=>node_type-object. IF NOT ls_node_type-type_kind CO 'uv'. zcx_abapgit_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 zif_abapgit_ajson=>node_type-array. IF NOT ls_node_type-type_kind = 'h'. zcx_abapgit_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. zcx_abapgit_ajson_error=>raise( 'Duplicate insertion' ). ENDIF. ENDIF. ENDLOOP. CATCH zcx_abapgit_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. zcx_abapgit_ajson_error=>raise( iv_msg = 'Source is not a number' iv_location = -path && -name ). CATCH cx_root INTO lx_root. zcx_abapgit_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 zcx_abapgit_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 zif_abapgit_ajson=>node_type-null. "" Do nothing WHEN zif_abapgit_ajson=>node_type-boolean. "" TODO: check type ? = boolc( is_node-value = 'true' ). WHEN zif_abapgit_ajson=>node_type-number. "" TODO: check type ? = is_node-value. WHEN zif_abapgit_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. zcx_abapgit_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|$)' IN iv_value SUBMATCHES lv_y lv_m lv_d. IF sy-subrc <> 0. zcx_abapgit_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})`. CONSTANTS lc_regex_ts_utc TYPE string VALUE `^(\\d{4})-(\\d{2})-(\\d{2})(T)(\\d{2}):(\\d{2}):(\\d{2})(Z|$)`. 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. zcx_abapgit_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. zcx_abapgit_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 zif_abapgit_ajson=>ty_path_name OPTIONAL iv_array_index TYPE i DEFAULT 0 ii_custom_mapping TYPE REF TO zif_abapgit_ajson_mapping OPTIONAL iv_keep_item_order TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rt_nodes) TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. CLASS-METHODS insert_with_type IMPORTING iv_data TYPE any iv_type TYPE string is_prefix TYPE zif_abapgit_ajson=>ty_path_name OPTIONAL iv_array_index TYPE i DEFAULT 0 ii_custom_mapping TYPE REF TO zif_abapgit_ajson_mapping OPTIONAL iv_keep_item_order TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rt_nodes) TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. CLASS-METHODS class_constructor. PRIVATE SECTION. CLASS-DATA gv_ajson_absolute_type_name TYPE string. DATA mi_custom_mapping TYPE REF TO zif_abapgit_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 zif_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. METHODS convert_ajson IMPORTING io_json TYPE REF TO zcl_abapgit_ajson is_prefix TYPE zif_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. METHODS convert_value IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zif_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. METHODS convert_ref IMPORTING iv_data TYPE any is_prefix TYPE zif_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. METHODS convert_struc IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zif_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt cs_root TYPE zif_abapgit_ajson=>ty_node OPTIONAL RAISING zcx_abapgit_ajson_error. METHODS convert_table IMPORTING iv_data TYPE any io_type TYPE REF TO cl_abap_typedescr is_prefix TYPE zif_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_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 zif_abapgit_ajson=>ty_path_name iv_index TYPE i DEFAULT 0 iv_item_order TYPE i DEFAULT 0 CHANGING ct_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt RAISING zcx_abapgit_ajson_error. ENDCLASS. CLASS lcl_abap_to_json IMPLEMENTATION. METHOD class_constructor. DATA lo_dummy TYPE REF TO zcl_abapgit_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. zcx_abapgit_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 = zif_abapgit_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 = zif_abapgit_ajson=>node_type-string. ls_node-value = |{ iv_data }|. ELSEIF io_type->type_kind CO 'bsI8PaeF'. "" Numeric ls_node-type = zif_abapgit_ajson=>node_type-number. ls_node-value = |{ iv_data }|. ELSE. zcx_abapgit_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 = zif_abapgit_ajson=>node_type-null. ls_node-value = 'null'. ELSE. "" TODO support data references zcx_abapgit_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 = zif_abapgit_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 = zif_abapgit_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 = zif_abapgit_ajson=>node_type-boolean AND iv_data <> 'true' AND iv_data <> 'false'. zcx_abapgit_ajson_error=>raise( |Unexpected boolean value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type = zif_abapgit_ajson=>node_type-null AND iv_data IS NOT INITIAL. zcx_abapgit_ajson_error=>raise( |Unexpected null value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type = zif_abapgit_ajson=>node_type-number AND iv_data CN '0123456789. E+-'. zcx_abapgit_ajson_error=>raise( |Unexpected numeric value [{ iv_data }] @{ lv_prefix }| ). ELSEIF iv_type <> zif_abapgit_ajson=>node_type-string AND iv_type <> zif_abapgit_ajson=>node_type-boolean AND iv_type <> zif_abapgit_ajson=>node_type-null AND iv_type <> zif_abapgit_ajson=>node_type-number. zcx_abapgit_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 <> zif_abapgit_ajson=>node_type-number. zcx_abapgit_ajson_error=>raise( |Unexpected value for numeric [{ iv_data }] @{ lv_prefix }| ). ENDIF. ELSE. zcx_abapgit_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 zif_abapgit_ajson_filter it_source_tree TYPE zif_abapgit_ajson=>ty_nodes_ts CHANGING ct_dest_tree TYPE zif_abapgit_ajson=>ty_nodes_ts RAISING zcx_abapgit_ajson_error. PRIVATE SECTION. DATA mi_filter TYPE REF TO zif_abapgit_ajson_filter. DATA mr_source_tree TYPE REF TO zif_abapgit_ajson=>ty_nodes_ts. DATA mr_dest_tree TYPE REF TO zif_abapgit_ajson=>ty_nodes_ts. METHODS walk IMPORTING iv_path TYPE string CHANGING cs_parent TYPE zif_abapgit_ajson=>ty_node OPTIONAL RAISING zcx_abapgit_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 zif_abapgit_ajson=>ty_node. LOOP AT mr_source_tree->* INTO ls_node WHERE path = iv_path. CASE ls_node-type. WHEN zif_abapgit_ajson=>node_type-boolean OR zif_abapgit_ajson=>node_type-null OR zif_abapgit_ajson=>node_type-number OR zif_abapgit_ajson=>node_type-string. IF mi_filter->keep_node( ls_node ) = abap_false. CONTINUE. ENDIF. WHEN zif_abapgit_ajson=>node_type-array OR zif_abapgit_ajson=>node_type-object. IF mi_filter->keep_node( is_node = ls_node iv_visit = zif_abapgit_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 = zif_abapgit_ajson_filter=>visit_type-close ) = abap_false. CONTINUE. ENDIF. WHEN OTHERS. zcx_abapgit_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 = zif_abapgit_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. ",12434,True,2644.7597909208052,median "CLASS zcl_abapgit_gui_router DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES zif_abapgit_gui_event_handler. PROTECTED SECTION. PRIVATE SECTION. METHODS general_page_routing IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS abapgit_services_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS db_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. CLASS-METHODS file_download IMPORTING !iv_package TYPE devclass !iv_xstr TYPE xstring RAISING zcx_abapgit_exception . METHODS git_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS remote_origin_manipulations IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS sap_gui_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS other_utilities IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS zip_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS repository_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS get_page_diff IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_branch_overview IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_stage IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_background IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . CLASS-METHODS jump_display_transport IMPORTING !iv_transport TYPE trkorr RAISING zcx_abapgit_exception . CLASS-METHODS jump_display_user IMPORTING !iv_username TYPE xubname RAISING zcx_abapgit_exception . METHODS call_browser IMPORTING !iv_url TYPE csequence RAISING zcx_abapgit_exception. METHODS get_state_settings IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i. METHODS get_state_diff IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i. METHODS get_state_db_edit IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i. ENDCLASS. CLASS ZCL_ABAPGIT_GUI_ROUTER IMPLEMENTATION. METHOD abapgit_services_actions. DATA li_main_page TYPE REF TO zcl_abapgit_gui_page_main. IF ii_event->mv_action = zif_abapgit_definitions=>c_action-abapgit_home. CREATE OBJECT li_main_page. rs_handled-page = li_main_page. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ENDIF. ENDMETHOD. METHOD call_browser. cl_gui_frontend_services=>execute( EXPORTING document = |{ iv_url }| EXCEPTIONS cntl_error = 1 error_no_gui = 2 bad_parameter = 3 file_not_found = 4 path_not_found = 5 file_extension_unknown = 6 error_execute_failed = 7 synchronous_failed = 8 not_supported_by_gui = 9 OTHERS = 10 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD db_actions. DATA ls_db_key TYPE zif_abapgit_persistence=>ty_content. DATA lo_query TYPE REF TO zcl_abapgit_string_map. lo_query = ii_event->query( ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-db_edit. lo_query->to_abap( CHANGING cs_container = ls_db_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db_edit EXPORTING is_key = ls_db_key. rs_handled-state = get_state_db_edit( ii_event ). WHEN zif_abapgit_definitions=>c_action-db_display. lo_query->to_abap( CHANGING cs_container = ls_db_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db_dis EXPORTING is_key = ls_db_key. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ENDCASE. ENDMETHOD. METHOD file_download. DATA: lv_path TYPE string, lv_default TYPE string, li_fe_serv TYPE REF TO zif_abapgit_frontend_services, lv_package TYPE devclass. lv_package = iv_package. TRANSLATE lv_package USING '/#'. CONCATENATE lv_package '_' sy-datlo '_' sy-timlo INTO lv_default. li_fe_serv = zcl_abapgit_ui_factory=>get_frontend_services( ). lv_path = li_fe_serv->show_file_save_dialog( iv_title = 'Export ZIP' iv_extension = 'zip' iv_default_filename = lv_default ). li_fe_serv->file_download( iv_path = lv_path iv_xstr = iv_xstr ). ENDMETHOD. METHOD general_page_routing. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_last_repo_key TYPE zif_abapgit_persistence=>ty_repo-key, lt_repo_list TYPE zif_abapgit_persistence=>ty_repos. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zcl_abapgit_gui=>c_action-go_home. lv_last_repo_key = zcl_abapgit_persistence_user=>get_instance( )->get_repo_show( ). lt_repo_list = zcl_abapgit_persist_factory=>get_repo( )->list( ). IF lv_last_repo_key IS NOT INITIAL. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lv_last_repo_key. ELSEIF lt_repo_list IS NOT INITIAL. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main. ELSE. rs_handled-page = zcl_abapgit_gui_page_tutorial=>create( ). ENDIF. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_db. "" Go DB util page CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_debuginfo. "" Go debug info CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_debuginfo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_settings. "" Go global settings rs_handled-page = zcl_abapgit_gui_page_sett_glob=>create( ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_settings_personal. "" Go personal settings rs_handled-page = zcl_abapgit_gui_page_sett_pers=>create( ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_background_run. "" Go background run page CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_bkg_run. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_background. "" Go Background page rs_handled-page = get_page_background( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_diff. "" Go Diff page rs_handled-page = get_page_diff( ii_event ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. WHEN zif_abapgit_definitions=>c_action-go_stage. "" Go Staging page rs_handled-page = get_page_stage( ii_event ). rs_handled-state = get_state_diff( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_branch_overview. "" Go repo branch overview rs_handled-page = get_page_branch_overview( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_tutorial. "" Go to tutorial rs_handled-page = zcl_abapgit_gui_page_tutorial=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-documentation. "" abapGit docs zcl_abapgit_services_abapgit=>open_abapgit_wikipage( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-go_explore. "" dotabap zcl_abapgit_services_abapgit=>open_dotabap_homepage( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-changelog. "" abapGit full changelog zcl_abapgit_services_abapgit=>open_abapgit_changelog( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD get_page_background. CREATE OBJECT ri_page TYPE zcl_abapgit_gui_page_bkg EXPORTING iv_key = iv_key. ENDMETHOD. METHOD get_page_branch_overview. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lo_page TYPE REF TO zcl_abapgit_gui_page_boverview. lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). CREATE OBJECT lo_page EXPORTING io_repo = lo_repo. ri_page = lo_page. ENDMETHOD. METHOD get_page_diff. DATA: ls_file TYPE zif_abapgit_definitions=>ty_file, ls_object TYPE zif_abapgit_definitions=>ty_item, lo_page TYPE REF TO zcl_abapgit_gui_page_diff, lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). ls_file-path = ii_event->query( )->get( 'PATH' ). ls_file-filename = ii_event->query( )->get( 'FILENAME' ). "" unescape ? ls_object-obj_type = ii_event->query( )->get( 'OBJ_TYPE' ). ls_object-obj_name = ii_event->query( )->get( 'OBJ_NAME' ). "" unescape ? CREATE OBJECT lo_page EXPORTING iv_key = lv_key is_file = ls_file is_object = ls_object. ri_page = lo_page. ENDMETHOD. METHOD get_page_stage. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_seed TYPE string, lo_stage_page TYPE REF TO zcl_abapgit_gui_page_stage, lo_code_inspector_page TYPE REF TO zcl_abapgit_gui_page_code_insp, lo_page_repo TYPE REF TO zcl_abapgit_gui_page_repo_view, lv_answer TYPE c LENGTH 1, lv_question_text TYPE string, lv_question_title TYPE string, lv_show_create_branch_popup TYPE c LENGTH 1. lv_key = ii_event->query( )->get( 'KEY' ). lv_seed = ii_event->query( )->get( 'SEED' ). lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). IF lo_repo->get_local_settings( )-code_inspector_check_variant IS NOT INITIAL. CREATE OBJECT lo_code_inspector_page EXPORTING io_repo = lo_repo. ri_page = lo_code_inspector_page. ELSEIF lo_repo->get_selected_branch( ) CP zif_abapgit_definitions=>c_git_branch-tags. lv_show_create_branch_popup = abap_true. lv_question_title = 'Staging on a tag'. lv_question_text = 'You are currently working on a tag.'. lv_question_text = |{ lv_question_text } You must be on a branch to stage.|. lv_question_text = |{ lv_question_text } Create new branch?|. ELSEIF lo_repo->get_selected_commit( ) IS NOT INITIAL. lv_show_create_branch_popup = abap_true. lv_question_title = 'Staging on a checked out commit'. lv_question_text = 'You are currently checked out in a commit.'. lv_question_text = |{ lv_question_text } You must be on a branch to stage.|. lv_question_text = |{ lv_question_text } Create new branch?|. ELSE. "" force refresh on stage, to make sure the latest local and remote files are used lo_repo->refresh( ). CREATE OBJECT lo_stage_page EXPORTING io_repo = lo_repo iv_seed = lv_seed. ri_page = lo_stage_page. ENDIF. IF lv_show_create_branch_popup = abap_true. lv_answer = zcl_abapgit_ui_factory=>get_popups( )->popup_to_confirm( iv_titlebar = lv_question_title iv_text_question = lv_question_text iv_text_button_1 = 'New branch' ""Ideally the button name would be Create branch, but it did not fit iv_icon_button_1 = 'ICON_OKAY' iv_text_button_2 = 'Cancel' iv_icon_button_2 = 'ICON_CANCEL' iv_default_button = '2' iv_display_cancel_button = abap_false ). IF lv_answer = '1'. TRY. zcl_abapgit_services_git=>create_branch( iv_key = lo_repo->get_key( ) ). CATCH zcx_abapgit_cancel. ""Continue processing so we can return to the correct page ENDTRY. ENDIF. CREATE OBJECT lo_page_repo TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lo_repo->get_key( ). ri_page = lo_page_repo. ENDIF. ENDMETHOD. METHOD get_state_db_edit. "" In display mode, replace the page IF ii_event->mv_current_page_name = 'ZCL_ABAPGIT_GUI_PAGE_DB_DIS'. rv_state = zcl_abapgit_gui=>c_event_state-new_page_replacing. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page. ENDIF. ENDMETHOD. METHOD get_state_diff. "" Bookmark current page before jumping to diff page IF ii_event->mv_current_page_name CP 'ZCL_ABAPGIT_GUI_PAGE_DIFF'. rv_state = zcl_abapgit_gui=>c_event_state-new_page. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. ENDIF. ENDMETHOD. METHOD get_state_settings. "" Bookmark current page before jumping to any settings page IF ii_event->mv_current_page_name CP 'ZCL_ABAPGIT_GUI_PAGE_SETT_*'. rv_state = zcl_abapgit_gui=>c_event_state-new_page_replacing. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. ENDIF. ENDMETHOD. METHOD git_services. DATA lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-git_pull. "" GIT Pull zcl_abapgit_services_git=>pull( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_reset. "" GIT Reset zcl_abapgit_services_git=>reset( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_checkout_commit. "" GIT Checkout commit zcl_abapgit_services_git=>checkout_commit( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_create. "" GIT Create new branch zcl_abapgit_services_git=>create_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_delete. "" GIT Delete remote branch zcl_abapgit_services_git=>delete_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_switch. "" GIT Switch branch zcl_abapgit_services_git=>switch_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-go_tag_overview. "" GIT Tag overview zcl_abapgit_services_git=>tag_overview( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_create. "" GIT Tag create CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_tag EXPORTING io_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-git_tag_delete. "" GIT Tag create zcl_abapgit_services_git=>delete_tag( lv_key ). zcl_abapgit_services_repo=>refresh( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_switch. "" GIT Switch Tag zcl_abapgit_services_git=>switch_tag( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD jump_display_transport. DATA: lv_transport_adt_uri TYPE string, lv_adt_link TYPE string, lv_adt_jump_enabled TYPE abap_bool. lv_adt_jump_enabled = zcl_abapgit_persist_settings=>get_instance( )->read( )->get_adt_jump_enabled( ). IF lv_adt_jump_enabled = abap_true. TRY. CALL METHOD ('CL_CTS_ADT_TM_URI_BUILDER')=>('CREATE_ADT_URI') EXPORTING trnumber = iv_transport RECEIVING result = lv_transport_adt_uri. lv_adt_link = |adt://{ sy-sysid }{ lv_transport_adt_uri }|. cl_gui_frontend_services=>execute( EXPORTING document = lv_adt_link EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'ADT Jump Error' ). ENDIF. CATCH cx_root. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = iv_transport. ENDTRY. ELSE. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = iv_transport. ENDIF. ENDMETHOD. METHOD jump_display_user. "" todo, user display in ADT CALL FUNCTION 'BAPI_USER_DISPLAY' EXPORTING username = iv_username. ENDMETHOD. METHOD other_utilities. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-changed_by. zcl_abapgit_services_basis=>test_changed_by( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-performance_test. zcl_abapgit_services_basis=>run_performance_test( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-ie_devtools. zcl_abapgit_services_basis=>open_ie_devtools( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD remote_origin_manipulations. DATA lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-repo_remote_attach. "" Remote attach zcl_abapgit_services_repo=>remote_attach( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_remote_detach. "" Remote detach zcl_abapgit_services_repo=>remote_detach( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_remote_change. "" Remote change zcl_abapgit_services_repo=>remote_change( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD repository_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_repo TYPE REF TO zcl_abapgit_repo, li_log TYPE REF TO zif_abapgit_log. lv_key = ii_event->query( )->get( 'KEY' ). IF lv_key IS NOT INITIAL. lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). ENDIF. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-repo_newoffline. "" New offline repo rs_handled-page = zcl_abapgit_gui_page_addofflin=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req. "" Add objects to transport zcl_abapgit_transport=>add_all_objects_to_trans_req( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_refresh. "" Repo refresh zcl_abapgit_services_repo=>refresh( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_syntax_check. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_syntax "" Syntax check EXPORTING io_repo = lo_repo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_code_inspector. "" Code inspector CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_code_insp EXPORTING io_repo = lo_repo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_purge. "" Repo purge all objects (uninstall) zcl_abapgit_services_repo=>purge( lv_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN zif_abapgit_definitions=>c_action-repo_remove. "" Repo remove zcl_abapgit_services_repo=>remove( lv_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN zif_abapgit_definitions=>c_action-repo_newonline. "" New offline repo rs_handled-page = zcl_abapgit_gui_page_addonline=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_refresh_checksums. "" Rebuild local checksums zcl_abapgit_services_repo=>refresh_local_checksums( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_toggle_fav. "" Toggle repo as favorite zcl_abapgit_services_repo=>toggle_favorite( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_transport_to_branch. "" Transport to branch zcl_abapgit_services_repo=>transport_to_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_settings. "" Repo settings rs_handled-page = zcl_abapgit_gui_page_sett_repo=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_local_settings. "" Local repo settings rs_handled-page = zcl_abapgit_gui_page_sett_locl=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_infos. "" Repo infos rs_handled-page = zcl_abapgit_gui_page_sett_info=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_log. "" Repo log li_log = lo_repo->get_log( ). zcl_abapgit_log_viewer=>show_log( li_log ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD sap_gui_actions. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, lx_ex TYPE REF TO zcx_abapgit_exception, li_html_viewer TYPE REF TO zif_abapgit_html_viewer. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-jump. "" Open object editor ls_item-obj_type = ii_event->query( )->get( 'TYPE' ). ls_item-obj_name = ii_event->query( )->get( 'NAME' ). li_html_viewer = zcl_abapgit_ui_factory=>get_html_viewer( ). TRY. "" Hide HTML Viewer in dummy screen0 for direct CALL SCREEN to work li_html_viewer->set_visiblity( abap_false ). zcl_abapgit_objects=>jump( ls_item ). li_html_viewer->set_visiblity( abap_true ). CATCH zcx_abapgit_exception INTO lx_ex. li_html_viewer->set_visiblity( abap_true ). RAISE EXCEPTION lx_ex. ENDTRY. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-jump_transport. jump_display_transport( |{ ii_event->query( )->get( 'TRANSPORT' ) }| ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-jump_user. jump_display_user( |{ ii_event->query( )->get( 'USER' ) }| ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-url. call_browser( ii_event->query( )->get( 'URL' ) ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. rs_handled = general_page_routing( ii_event ). IF rs_handled-state IS INITIAL. rs_handled = repository_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = git_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = zip_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = db_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = abapgit_services_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = remote_origin_manipulations( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = sap_gui_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = other_utilities( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled-state = zcl_abapgit_gui=>c_event_state-not_handled. ENDIF. ENDMETHOD. METHOD zip_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_repo TYPE REF TO zcl_abapgit_repo, lv_package TYPE devclass, lv_path TYPE string, lv_xstr TYPE xstring. CONSTANTS: BEGIN OF lc_page, main_view TYPE string VALUE 'ZCL_ABAPGIT_GUI_PAGE_MAIN', repo_view TYPE string VALUE 'ZCL_ABAPGIT_GUI_PAGE_REPO_VIEW', END OF lc_page. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-zip_import. "" Import repo from ZIP lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). lv_path = zcl_abapgit_ui_factory=>get_frontend_services( )->show_file_open_dialog( iv_title = 'Import ZIP' iv_extension = 'zip' iv_default_filename = '*.zip' ). lv_xstr = zcl_abapgit_ui_factory=>get_frontend_services( )->file_upload( lv_path ). lo_repo->set_files_remote( zcl_abapgit_zip=>load( lv_xstr ) ). zcl_abapgit_services_repo=>refresh( lv_key ). CASE ii_event->mv_current_page_name. WHEN lc_page-repo_view. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN lc_page-main_view. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lo_repo->get_key( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN OTHERS. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. WHEN zif_abapgit_definitions=>c_action-zip_export. "" Export repo as ZIP lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). lv_xstr = zcl_abapgit_zip=>encode_files( lo_repo->get_files_local( ) ). file_download( iv_package = lo_repo->get_package( ) iv_xstr = lv_xstr ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_package. "" Export package as ZIP zcl_abapgit_zip=>export_package( IMPORTING ev_xstr = lv_xstr ev_package = lv_package ). file_download( iv_package = lv_package iv_xstr = lv_xstr ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_transport. "" Export transports as ZIP zcl_abapgit_transport_mass=>run( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_object. "" Export object as ZIP zcl_abapgit_zip=>export_object( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. ENDCLASS. ",7951,False,1884.3239737027368,median "package Ankama_Grimoire.ui { import Ankama_Cartography.Cartography; import Ankama_ContextMenu.ContextMenu; import com.ankamagames.berilia.components.Grid; import com.ankamagames.berilia.components.Label; import com.ankamagames.berilia.components.TextureBitmap; import com.ankamagames.berilia.components.gridRenderer.MultiGridRenderer; import com.ankamagames.berilia.enums.StrataEnum; import com.ankamagames.berilia.enums.UIEnum; import com.ankamagames.berilia.types.graphic.ButtonContainer; import com.ankamagames.berilia.types.graphic.GraphicContainer; import com.ankamagames.berilia.types.graphic.ScrollContainer; import com.ankamagames.dofus.datacenter.quest.Quest; import com.ankamagames.dofus.datacenter.quest.QuestObjective; import com.ankamagames.dofus.datacenter.quest.QuestStep; import com.ankamagames.dofus.logic.game.common.actions.FollowQuestAction; import com.ankamagames.dofus.logic.game.common.actions.RefreshFollowedQuestsOrderAction; import com.ankamagames.dofus.logic.game.common.actions.quest.QuestInfosRequestAction; import com.ankamagames.dofus.misc.lists.CustomUiHookList; import com.ankamagames.dofus.misc.lists.HookList; import com.ankamagames.dofus.misc.lists.QuestHookList; import com.ankamagames.dofus.network.ProtocolConstantsEnum; import com.ankamagames.dofus.network.enums.CompassTypeEnum; import com.ankamagames.dofus.uiApi.ChatApi; import com.ankamagames.dofus.uiApi.ConfigApi; import com.ankamagames.dofus.uiApi.DataApi; import com.ankamagames.dofus.uiApi.QuestApi; import com.ankamagames.jerakine.types.enums.DataStoreEnum; import flash.events.MouseEvent; import flash.geom.ColorTransform; import flash.geom.Rectangle; import flash.ui.Mouse; import flash.ui.MouseCursor; import flash.utils.Dictionary; public class QuestList extends AbstractQuestList { private static const MAX_OBJECTIVES:uint = 3; private static const QUEST_TYPE:String = ""ctr_quest""; private static const OBJECTIVE_TYPE:String = ""ctr_objective""; private static const RIGHT_MARGIN:uint = 40; private static const BOTTOM_MARGIN:uint = 15; public static const MAX_FOLLOWED_QUESTS_DATA_ID:String = ""maxFollowedQuests""; private static const FOLLOWED_QUESTS_RESIZE_MODE_DATA_ID:String = ""followedQuestsResizeMode""; private static const OPACITY_DATA_ID:String = ""followedQuestsBackgroundOpacity""; private static const FONT_SIZE_DATA_ID:String = ""followedQuestsFontSize""; private static const QUEST_LIST_MINIMIZED_DATA_ID:String = ""questListMinimized""; private static const AUTO_RESIZE_MODE:uint = 1; private static const FREE_RESIZE_MODE:uint = 2; private static const FONT_SMALL_SIZE:uint = 15; private static const FONT_MEDIUM_SIZE:uint = 16; private static const ITEM_ID_REGEXP:RegExp = /\\d+/g; private static const ITEM_LINK_REGEX:RegExp = /{item(,|::)(.*?)}/g; [Api(name=""QuestApi"")] public var questApi:QuestApi; [Api(name=""DataApi"")] public var dataApi:DataApi; [Api(name=""ChatApi"")] public var chatApi:ChatApi; [Api(name=""ConfigApi"")] public var configApi:ConfigApi; [Module(name=""Ankama_ContextMenu"")] public var modContextMenu:ContextMenu; [Module(name=""Ankama_Cartography"")] public var modCartography:Cartography; private var _quests:Array; private var _maxQuests:uint; private var _offsetY:Number; private var _listRendered:Boolean; private var _colors:Array; private var _defaultColorTransform:ColorTransform; private var _numQuests:uint; private var _previousItemIsQuest:Boolean; private var _components:Dictionary; private var _updating:Boolean; private var _startedQuests:Vector.; private var _resizeMode:uint; private var _flagsQuestData:Dictionary; private var _opacity:Number; private var _fontSize:uint; private var _mouseScrollEvent:MouseEvent; private var _questsFollowAll:Dictionary; private var _questsObjectivesOrder:Dictionary; public var tx_minMax:TextureBitmap; public var tx_title:TextureBitmap; public var ctr_list:GraphicContainer; public var ctr_main:GraphicContainer; public var btn_options:ButtonContainer; public var btn_minimize:ButtonContainer; public var gd_quests:Grid; public var lbl_title:Label; public var gridScrollContainer:ScrollContainer; public function QuestList() { this._questsFollowAll = new Dictionary(); this._questsObjectivesOrder = new Dictionary(); super(); } override public function main(params:Object) : void { var i:int = 0; var questParam:Object = null; var needInfosQuestsIds:Vector. = null; super.main(params); this._maxQuests = sysApi.getSetData(MAX_FOLLOWED_QUESTS_DATA_ID,ProtocolConstantsEnum.MAX_FOLLOWED_QUESTS,DataStoreEnum.BIND_ACCOUNT); this._resizeMode = sysApi.getSetData(FOLLOWED_QUESTS_RESIZE_MODE_DATA_ID,AUTO_RESIZE_MODE,DataStoreEnum.BIND_ACCOUNT); this.ctr_list.getResizeController().bottomResize = this._resizeMode == FREE_RESIZE_MODE; this._opacity = sysApi.getSetData(OPACITY_DATA_ID,0.7,DataStoreEnum.BIND_ACCOUNT); this.changeOpacity(this._opacity); this._fontSize = sysApi.getSetData(FONT_SIZE_DATA_ID,FONT_MEDIUM_SIZE,DataStoreEnum.BIND_ACCOUNT); this._mouseScrollEvent = new MouseEvent(MouseEvent.MOUSE_WHEEL); this.gridScrollContainer.verticalScrollSpeed = 20; this.gridScrollContainer.addContent(this.gd_quests); sysApi.addHook(QuestHookList.QuestValidated,this.onQuestValidated); sysApi.addHook(QuestHookList.QuestObjectiveValidated,this.onQuestObjectiveValidated); sysApi.addHook(QuestHookList.QuestStepValidated,this.onQuestStepValidated); sysApi.addHook(QuestHookList.QuestStarted,this.onQuestStarted); sysApi.addHook(QuestHookList.QuestInfosUpdated,this.onQuestInfosUpdated); sysApi.addHook(HookList.FontActiveTypeChanged,this.onFontActiveTypeChanged); sysApi.addHook(HookList.RemoveAllFlags,this.removeAllFlags); sysApi.addHook(CustomUiHookList.FlagRemoved,this.onFlagRemoved); sysApi.addHook(CustomUiHookList.FlagAdded,this.onFlagAdded); this._quests = new Array(); this._startedQuests = new Vector.(); this._components = new Dictionary(); this._colors = [false,false,false,false,false,false,false,false,false,false]; this._defaultColorTransform = new ColorTransform(); this._flagsQuestData = new Dictionary(); if(params) { for(i = params.quests.length - 1; i >= 0; i--) { questParam = params.quests[i]; if(!questParam.hasOwnProperty(""objectives"")) { if(!needInfosQuestsIds) { needInfosQuestsIds = new Vector.(); } needInfosQuestsIds.push(questParam.questId); } else { this.addQuest(params.quests[i],false); } } if(this._numQuests > 0) { this.update(); } if(needInfosQuestsIds && needInfosQuestsIds.length) { for(i = 0; i < needInfosQuestsIds.length; i++) { this.onQuestStarted(needInfosQuestsIds[i]); } } if(!params.visible && !sysApi.isFightContext()) { this.minimize(); } } } public function unload() : void { } public function update() : void { this._updating = true; this._listRendered = false; this._offsetY = 0; this.gd_quests.finalized = false; this.gd_quests.height = this._quests.length * this.gd_quests.slotHeight; this.gd_quests.dataProvider = this._quests; this.updateListSize(); this._listRendered = true; this._updating = false; this.restrictPosition(); } public function updateLine(data:*, componentsRef:*, selected:Boolean, line:uint) : void { var questOffset:Number = NaN; var objectiveY:Number = NaN; var objectiveCssClass:String = null; var objectiveText:String = null; var objective:QuestObjective = null; this._components[data] = componentsRef; if(this._listRendered) { return; } var lineType:String = this.getLineType(data,line); var offset:Number = 0; if(lineType.length) { if(lineType == QUEST_TYPE) { questOffset = this._quests.indexOf(data) > 0 ? Number(10) : Number(0); componentsRef.lbl_quest.setCssSize(this._fontSize,""questtitle""); componentsRef.lbl_quest.width = this.ctr_list.width - RIGHT_MARGIN; componentsRef.lbl_quest.y = this._offsetY + questOffset; componentsRef.lbl_quest.text = this.dataApi.getQuest(data.id).name + (!!sysApi.getPlayerManager().hasRights ? "" ("" + data.id + "")"" : """"); offset = componentsRef.lbl_quest.textHeight - (this.gd_quests.slotHeight - 5) + questOffset; this._previousItemIsQuest = true; } else { objectiveY = this._offsetY; if(this._previousItemIsQuest) { objectiveY -= 2; this._previousItemIsQuest = false; } else { objectiveY -= 3; } componentsRef.lbl_objective.width = this.ctr_list.width - RIGHT_MARGIN; componentsRef.lbl_objective.x = componentsRef.btn_loc.x + componentsRef.btn_loc.width - 5; componentsRef.lbl_objective.y = componentsRef.btn_loc.y = objectiveY; if(data.hasOwnProperty(""seeLess"")) { objectiveCssClass = ""seemore""; objectiveText = uiApi.getText(""ui.quest.seeLess""); } else if(data.visible) { objective = this.dataApi.getQuestObjective(data.id); objectiveCssClass = ""questobjective""; objectiveText = objective.text + (!!sysApi.getPlayerManager().hasRights ? "" ("" + data.id + "")"" : """"); objectiveText = objectiveText.replace(ITEM_LINK_REGEX,""{encyclopediaItem$1$2}""); this.setFlagColor(componentsRef.btn_loc,data.color,!data.follow); } else { objectiveCssClass = ""seemore""; objectiveText = uiApi.getText(""ui.quest.seeMore""); } componentsRef.lbl_objective.cssClass = objectiveCssClass; componentsRef.lbl_objective.setCssSize(this._fontSize,objectiveCssClass); componentsRef.lbl_objective.text = objectiveText; offset = componentsRef.lbl_objective.textHeight - (this.gd_quests.slotHeight - 5); componentsRef.lbl_objective.fullSize(componentsRef.lbl_objective.width); componentsRef.btn_loc.visible = data.visible && data.flagData; } if(offset < 0) { offset = 0; } this._offsetY += offset; } } public function getLineType(data:*, line:uint) : String { if(!data) { return """"; } return !!data.isQuest ? QUEST_TYPE : OBJECTIVE_TYPE; } public function addQuest(questParams:Object, toTheTop:Boolean = true) : void { var i:int = 0; var questData:Object = null; var questExists:Boolean = false; var flagColor:uint = 0; var objectiveParam:Object = null; var objectiveData:Object = null; var objectiveExists:Boolean = false; var objectiveIndex:int = 0; var maxObjectivesReached:Boolean = false; var objectiveDictionnaryIndex:uint = 0; var flag:Object = null; var flagExists:* = false; var addFlag:Boolean = false; var checkedObjFollow:Boolean = false; var newIndex:int = 0; var flagSavedData:* = undefined; var x:uint = 0; var questDataObj:* = undefined; var quest:Quest = this.dataApi.getQuest(questParams.questId); if(!quest.followable) { return; } var followedObjectiveId:int = questParams.followedObjectiveID; var followAll:Boolean = followedObjectiveId > 0 ? false : true; for each(questData in this._quests) { if(questData.isQuest && questData.id == questParams.questId) { questExists = true; break; } } if(!questExists) { questData = { ""id"":questParams.questId, ""isQuest"":true, ""color"":this.getUnusedColor() }; questData.objectives = []; if(toTheTop) { this._quests.unshift(questData); } else { this._quests.push(questData); } ++this._numQuests; this._questsFollowAll[questData.id] = followAll; } flagColor = questData.color; var numObjectives:uint = questParams.objectives.length; for(i = 0; i < numObjectives; i++) { objectiveParam = questParams.objectives[i]; for each(objectiveData in questData.objectives) { if(objectiveData.id == objectiveParam.id) { objectiveExists = true; break; } } if(!objectiveExists) { questData.objectives.push({ ""id"":objectiveParam.id, ""flagData"":objectiveParam.flagData, ""isQuest"":false, ""questId"":questData.id, ""color"":flagColor }); this._questsObjectivesOrder[questData.id + ""_"" + i] = questData.objectives[i]; } } var numObjectivesData:uint = questData.objectives.length; var objectivesStartIndex:int = this._quests.indexOf(questData) + 1; var singleObjectiveAdded:Boolean = false; var followedObjectives:int = 0; var displayShowOption:Boolean = false; var maxIndex:int = 0; if(followAll) { this.clearQuestDisplay(questData,this._quests.indexOf(questData) + 1); } for(i = 0; i < numObjectivesData; i++) { objectiveDictionnaryIndex = this.GetObjectiveDictionaryOrder(questData,questData.objectives[i]); checkedObjFollow = false; newIndex = 0; if(questData.objectives[i].flagData) { questData.objectives[i].color = questData.color; } if(followAll) { if(questData.objectives[i].flagData) { flagSavedData = sysApi.getData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + questData.objectives[i].flagData.id); questData.objectives[i].follow = flagSavedData != null ? flagSavedData === true : false; if(questData.objectives[i].follow) { followedObjectives++; checkedObjFollow = true; } } else { questData.objectives[i].follow = false; } objectiveIndex = objectivesStartIndex + i; if(i + 1 <= MAX_OBJECTIVES) { questData.objectives[i].visible = true; this._quests.splice(objectiveIndex,0,questData.objectives[i]); if(checkedObjFollow) { this.changeObjectivesOrder(questData.objectives[i],true); } } else { displayShowOption = true; maxIndex = objectivesStartIndex + MAX_OBJECTIVES; if(checkedObjFollow) { if(followedObjectives > 0) { this.ReOrderObjectiveDictionary(objectiveDictionnaryIndex,followedObjectives - 1,questData.id); } newIndex = objectivesStartIndex + followedObjectives; if(followedObjectives <= MAX_OBJECTIVES) { this._quests[maxIndex - 1].visible = false; this._quests.splice(maxIndex - 1,1); questData.objectives[i].visible = true; this._quests.splice(newIndex - 1,0,questData.objectives[i]); } } } } else if(questData.objectives[i].id == followedObjectiveId && !questData.objectives[i].visible) { maxObjectivesReached = false; this.addObjective(questData,questData.objectives[i],numObjectivesData,objectiveDictionnaryIndex); } else if(questData.objectives[i].id == followedObjectiveId && questData.objectives[i].visible) { questData.objectives[i].follow = true; this.changeObjectivesOrder(questData.objectives[i],true); } flagExists = false; if(questData.objectives[i].flagData) { this._flagsQuestData[questData.objectives[i].flagData.id] = questData.objectives[i]; flag = this.getFlag(questData.objectives[i].flagData.id,questData.objectives[i].flagData.worldMapId); flagExists = flag != null; if(!questData.objectives[i].follow) { if(flagExists) { sysApi.dispatchHook(HookList.RemoveMapFlag,questData.objectives[i].flagData.id,questData.objectives[i].flagData.worldMapId); } } else { addFlag = false; if(!flagExists) { addFlag = true; } else if(flag.color != questData.objectives[i].color) { sysApi.dispatchHook(HookList.RemoveMapFlag,questData.objectives[i].flagData.id,questData.objectives[i].flagData.worldMapId); addFlag = true; } if(addFlag) { sysApi.dispatchHook(HookList.AddMapFlag,questData.objectives[i].flagData.id,questData.objectives[i].flagData.text,questData.objectives[i].flagData.worldMapId,questData.objectives[i].flagData.x,questData.objectives[i].flagData.y,questData.objectives[i].color); } } } if(!maxObjectivesReached && (followAll && !questData.objectives[i].visible || singleObjectiveAdded)) { maxObjectivesReached = true; } else if(maxObjectivesReached) { continue; } singleObjectiveAdded = !followAll && questData.objectives[i].id == followedObjectiveId; } if(displayShowOption) { this._questsObjectivesOrder[questData.id + ""_"" + MAX_OBJECTIVES].visible = false; if(this._quests[maxIndex]) { this._quests.splice(maxIndex,!!this._quests[maxIndex].isQuest ? 0 : 1,this._questsObjectivesOrder[questData.id + ""_"" + MAX_OBJECTIVES]); } else { this._quests.splice(maxIndex,0,this._questsObjectivesOrder[questData.id + ""_"" + MAX_OBJECTIVES]); } } if(followAll && followedObjectives == 0) { for(x = 0; x < MAX_OBJECTIVES; ) { if(questData.objectives[x] && questData.objectives[x].flagData) { questData.objectives[x].follow = true; questDataObj = questData.objectives[x]; this._flagsQuestData[questDataObj.flagData.id] = questDataObj; flag = this.getFlag(questDataObj.flagData.id,questDataObj.flagData.worldMapId); flagExists = flag != null; addFlag = false; if(!flagExists) { addFlag = true; } else if(flag.color != questDataObj.color) { sysApi.dispatchHook(HookList.RemoveMapFlag,questDataObj.flagData.id,questDataObj.flagData.worldMapId); addFlag = true; } if(addFlag) { sysApi.dispatchHook(HookList.AddMapFlag,questDataObj.flagData.id,questDataObj.flagData.text,questDataObj.flagData.worldMapId,questDataObj.flagData.x,questDataObj.flagData.y,questDataObj.color); } } x++; } } if(!questParams.hasOwnProperty(""fromServer"")) { sysApi.sendAction(new FollowQuestAction([questParams.questId,!!followAll ? -1 : questParams.objectives[0].id,true])); } } public function unfollowQuest(questId:uint) : void { this.removeQuest(questId); if(!this._quests.length) { if(sysApi.getData(QUEST_LIST_MINIMIZED_DATA_ID,DataStoreEnum.BIND_ACCOUNT)) { uiApi.unloadUi(""questListMinimized""); } uiApi.unloadUi(uiApi.me().name); } else { this.update(); } } public function renderUpdate() : void { var i:int = 0; var dataLen:uint = 0; this.tx_title.width = this.ctr_list.width; this.tx_title.x = this.ctr_list.x - 1; this.lbl_title.x = this.tx_title.x; this.lbl_title.y = 3; this.lbl_title.width = this.tx_title.width - 15; this.btn_options.x = this.tx_title.x + this.tx_title.width - this.btn_options.width - 22; this.btn_options.y = 0; this.btn_minimize.x = this.tx_title.x + this.tx_title.width - this.btn_minimize.width - 5; this.btn_minimize.y = 4; if(this._quests && !this._updating) { dataLen = this._quests.length; this._listRendered = false; for(this._offsetY = 0; i < dataLen; ) { if(this._components[this._quests[i]]) { this.updateLine(this._quests[i],this._components[this._quests[i]],false,0); } i++; } this.updateListSize(); this._listRendered = true; } this.restrictPosition(); } public function restrictPosition() : void { var visibleBounds:Rectangle = uiApi.getVisibleStageBounds(); var x:Number = this.ctr_main.x + this.ctr_list.x; if(x + this.ctr_list.width > visibleBounds.right) { this.ctr_main.x = visibleBounds.right - (this.ctr_list.x + this.ctr_list.width); } if(x < visibleBounds.left) { this.ctr_main.x = visibleBounds.left - this.ctr_list.x; } if(this.ctr_main.y < visibleBounds.top) { this.ctr_main.y = 0; } if(this.ctr_main.y + this.ctr_list.height > visibleBounds.bottom) { this.ctr_main.y = visibleBounds.bottom - Math.min(this.ctr_list.height,visibleBounds.bottom); } } public function changeObjectivesOrder(objectiveData:Object, confirmFollow:Boolean, selectedQuestID:int = -1, objectiveID:int = -1, newObj:Boolean = false) : void { var questID:uint = 0; var objID:int = 0; var objData:Object = null; var obj:Object = null; var targetObjective:Object = null; var nextMaskedObjective:Object = null; if(objectiveData != null) { questID = objectiveData.questId; objID = objectiveData.id; objData = objectiveData; } else { questID = selectedQuestID; objID = objectiveID; } var objectivesNumber:uint = 0; var visibleObjectives:uint = 0; var followedObjectives:uint = 0; for(var i:uint = 0; this._questsObjectivesOrder[questID + ""_"" + i] != null; ) { obj = this._questsObjectivesOrder[questID + ""_"" + i]; if(obj.visible) { visibleObjectives++; } if(obj.follow) { followedObjectives++; } if(objData == null && obj.id == objID) { objData = obj; } objectivesNumber++; i++; } if(objData == null) { return; } if(objectiveData == null && !confirmFollow) { objData.follow = false; followedObjectives--; } var objectiveDictionnaryIndex:uint = this.GetObjectiveOrderDictionaryNoData(questID,objectivesNumber,objID); var startIndex:uint = this._quests.indexOf(objData); var questIndex:uint = this.GetQuestOrder(questID); if(confirmFollow) { if(followedObjectives > 0) { this.ReOrderObjectiveDictionary(objectiveDictionnaryIndex,followedObjectives - 1,questID); } this.SwapObjectiveQuestOrder(startIndex,questIndex,followedObjectives); } else { followedObjectives++; targetObjective = null; this.ReOrderObjectiveDictionary(objectiveDictionnaryIndex,followedObjectives - 1,questID); if(visibleObjectives > MAX_OBJECTIVES || followedObjectives > MAX_OBJECTIVES) { if(visibleObjectives == objectivesNumber) { if(followedObjectives > 1) { this.SwapObjectiveQuestOrder(startIndex,questIndex,followedObjectives); } } else if(visibleObjectives < followedObjectives) { targetObjective = this._quests[startIndex]; if(targetObjective == null) { return; } nextMaskedObjective = this._questsObjectivesOrder[questID + ""_"" + (visibleObjectives - 1)]; targetObjective.visible = false; this._quests.splice(startIndex,1); this._quests.splice(questIndex + visibleObjectives,0,nextMaskedObjective); nextMaskedObjective.visible = true; this._questsObjectivesOrder[questID + ""_"" + visibleObjectives].visible = false; this._quests.splice(questIndex + visibleObjectives + 1,!!this._quests[questIndex + visibleObjectives].isQuest ? 0 : 1,this._questsObjectivesOrder[questID + ""_"" + visibleObjectives]); } else { targetObjective = this._quests[startIndex]; targetObjective.visible = false; this._quests.splice(startIndex,1); this._quests.splice(questIndex + visibleObjectives,!!this._quests[questIndex + visibleObjectives].isQuest ? 0 : 1,targetObjective); } } else if(followedObjectives > 1) { this.SwapObjectiveQuestOrder(startIndex,questIndex,followedObjectives); } } this.update(); } private function getFlag(flagId:String, worldMapId:int) : Object { var flag:Object = null; var flagList:* = this.modCartography.getFlags(worldMapId); for each(flag in flagList) { if(flag.id == flagId) { return flag; } } return null; } private function GetQuestOrder(questID:uint) : int { var maxIteration:uint = this._quests.length; for(var i:uint = 0; i < maxIteration; ) { if(this._quests[i].isQuest && this._quests[i].id == questID) { return i; } i++; } return -1; } private function SwapObjectiveQuestOrder(startIndex:uint, questIndex:uint, questIndexOffset:uint = 0) : void { var stockedObjective:Object = this._quests[startIndex]; this._quests.splice(startIndex,1); this._quests.splice(questIndex + questIndexOffset,0,stockedObjective); } private function GetObjectiveDictionaryOrder(questData:Object, Objective:Object) : int { for(var i:uint = 0; i < questData.objectives.length; ) { if(this._questsObjectivesOrder[questData.id + ""_"" + i] == Objective) { return i; } i++; } return -1; } private function GetObjectiveOrderDictionaryNoData(questID:uint, questObjectiveNumber:uint, ObjectiveId:uint) : int { for(var i:uint = 0; i < questObjectiveNumber; i++) { if(this._questsObjectivesOrder[questID + ""_"" + i].id == ObjectiveId) { return i; } } return -1; } private function ReOrderObjectiveDictionary(formerIndex:uint, newIndex:uint, questID:uint) : void { var movedObjective:Object = this._questsObjectivesOrder[questID + ""_"" + formerIndex]; var i:uint = formerIndex; if(formerIndex > newIndex) { while(i > newIndex) { this._questsObjectivesOrder[questID + ""_"" + i] = this._questsObjectivesOrder[questID + ""_"" + (i - 1)]; i--; } } else if(formerIndex < newIndex) { while(i < newIndex) { this._questsObjectivesOrder[questID + ""_"" + i] = this._questsObjectivesOrder[questID + ""_"" + (i + 1)]; i++; } } this._questsObjectivesOrder[questID + ""_"" + newIndex] = movedObjective; } private function updateListSize() : void { var useScrollBar:Boolean = false; var height:Number = NaN; this.gridScrollContainer.width = this.ctr_list.width - 11; if(this._resizeMode == AUTO_RESIZE_MODE) { height = this._quests.length * this.gd_quests.slotHeight + this._offsetY; if(this.gridScrollContainer.y + height + BOTTOM_MARGIN > uiApi.getVisibleStageBounds().height) { height = uiApi.getVisibleStageBounds().height - this.gridScrollContainer.y - BOTTOM_MARGIN; useScrollBar = true; } this.gridScrollContainer.useVerticalScroll = useScrollBar; this.gridScrollContainer.height = height; this.gridScrollContainer.finalize(); this.ctr_list.height = this.gridScrollContainer.y + height + BOTTOM_MARGIN; } else if(this._resizeMode == FREE_RESIZE_MODE) { this.gridScrollContainer.height = this.ctr_list.height - this.gridScrollContainer.y - BOTTOM_MARGIN; this.gridScrollContainer.useVerticalScroll = true; this.gridScrollContainer.finalize(); } if(this.gridScrollContainer.useVerticalScroll && this.gridScrollContainer.hasVerticalScrollBar) { this.gridScrollContainer.verticalScrollbarValue = this.gridScrollContainer.lastVerticalScrollValue; } } private function removeLastQuests(numQuestsToDelete:uint) : void { var numDeletedQuests:uint = 0; var i:int = this._quests.length - 1; while(numDeletedQuests < numQuestsToDelete) { if(this._quests[i].isQuest) { this.removeQuest(this._quests[i].id); numDeletedQuests++; i = this._quests.length - 1; } else { i--; } } } private function removeQuest(questId:uint, removeColorAndFlags:Boolean = true) : Array { var i:int = 0; var endIndex:int = 0; var questData:Object = null; var questExists:Boolean = false; var k:int = 0; var objRef:Object = null; var deletedQuest:Array = null; var deletedQuestLen:uint = 0; var j:int = 0; var dataLen:uint = this._quests.length; var numColors:uint = this._colors.length; var startIndex:int = -1; for each(questData in this._quests) { if(questData.isQuest && questData.id == questId) { questExists = true; break; } } if(!questExists) { return null; } if(removeColorAndFlags) { for(k = 0; this._questsObjectivesOrder[questId + ""_"" + k] != null; k++) { objRef = this._questsObjectivesOrder[questId + ""_"" + k]; if(objRef.flagData) { delete this._flagsQuestData[objRef.flagData.id]; sysApi.dispatchHook(HookList.RemoveMapFlag,objRef.flagData.id,objRef.flagData.worldMapId); sysApi.setData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + objRef.flagData.id,null); } delete this._questsObjectivesOrder[questId + ""_"" + k]; } } while(i < dataLen) { if(this._quests[i].isQuest && this._quests[i].id == questId) { startIndex = i; } if(startIndex != -1 && (this._quests[i].isQuest && i != startIndex || i == dataLen - 1)) { endIndex = this._quests[i].isQuest && i < dataLen - 1 ? int(i) : int(i + 1); deletedQuest = this._quests.slice(startIndex,endIndex); deletedQuestLen = deletedQuest.length; this._quests.splice(startIndex,deletedQuestLen); if(removeColorAndFlags) { delete this._components[deletedQuest[0]]; for(j = 0; j < numColors; j++) { if(this._colors[j] == deletedQuest[0].color) { this._colors[j] = false; break; } } --this._numQuests; sysApi.sendAction(new FollowQuestAction([questId,-1,false])); } return deletedQuest; } i++; } return null; } private function removeObjective(objectiveData:Object, askInfos:Boolean = false) : void { var i:int = 0; var j:int = 0; var questData:Object = null; var objIndex:int = 0; var objStartIndex:int = 0; var numObjectives:uint = 0; var lastVisibleObjective:Object = null; var hiddenObjective:Object = null; var endIndex:int = 0; var objRef:Object = null; var dataLen:uint = this._quests.length; var deletedObjectiveIndex:int = -1; for(i = 0; i < dataLen; i++) { if(this._quests[i].isQuest && this._quests[i].id == objectiveData.questId) { questData = this._quests[i]; } else if(this._quests[i].id == objectiveData.id) { deletedObjectiveIndex = i; break; } } objIndex = this.GetObjectiveDictionaryOrder(questData,objectiveData); this.ReOrderObjectiveDictionary(objIndex,questData.objectives.length - 1,questData.id); delete this._questsObjectivesOrder[questData.id + ""_"" + (questData.objectives.length - 1)]; questData.objectives.splice(questData.objectives.indexOf(objectiveData),1); if(deletedObjectiveIndex != -1) { this._quests.splice(deletedObjectiveIndex,1); } delete this._components[objectiveData]; if(objectiveData.flagData) { delete this._flagsQuestData[objectiveData.flagData.id]; if(objectiveData.follow) { sysApi.dispatchHook(HookList.RemoveMapFlag,objectiveData.flagData.id,objectiveData.flagData.worldMapId); } sysApi.setData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + objectiveData.flagData.id,null); } if(questData.objectives.length) { sysApi.sendAction(new FollowQuestAction([questData.id,objectiveData.id,false])); objStartIndex = this._quests.indexOf(questData) + 1; this.clearQuestDisplay(questData,objStartIndex); numObjectives = questData.objectives.length; for(j = 0; j < numObjectives; j++) { objRef = this._questsObjectivesOrder[questData.id + ""_"" + j]; if(j < MAX_OBJECTIVES) { this._questsObjectivesOrder[questData.id + ""_"" + j].visible = true; lastVisibleObjective = this._questsObjectivesOrder[questData.id + ""_"" + j]; this._quests.splice(objStartIndex + j,0,this._questsObjectivesOrder[questData.id + ""_"" + j]); } else if(!objRef.visible && !hiddenObjective) { hiddenObjective = objRef; } } endIndex = this._quests.indexOf(lastVisibleObjective) + 1; if(hiddenObjective) { this._quests.splice(endIndex,0,hiddenObjective); } } if(askInfos) { sysApi.sendAction(new QuestInfosRequestAction([questData.id])); } else if(!questData.objectives.length) { this.unfollowQuest(questData.id); } } private function clearQuestDisplay(questData:Object, objStartIndex:int, clearSavedData:Boolean = false) : void { var k:int = 0; var j:int = 0; var objRef:Object = null; var numObj:int = questData.objectives.length; for(k = 0; k < numObj + 1; k++) { if(!this._quests[objStartIndex]) { break; } if(this._quests[objStartIndex].seeLess) { this._quests.splice(objStartIndex,1); } else { if(!(!this._quests[objStartIndex].isQuest && this._quests[objStartIndex].questId == questData.id)) { break; } this._quests[objStartIndex].visible = false; this._quests.splice(objStartIndex,1); } } if(clearSavedData) { for(j = 0; j < numObj; j++) { objRef = this._questsObjectivesOrder[questData.id + ""_"" + j]; if(objRef.flagData) { sysApi.dispatchHook(HookList.RemoveMapFlag,objRef.flagData.id,objRef.flagData.worldMapId); sysApi.setData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + objRef.flagData.id,null); } this._questsObjectivesOrder[questData.id + ""_"" + j].follow = false; this._questsObjectivesOrder[questData.id + ""_"" + j].visible = false; } } } private function addObjective(questData:Object, objAdded:Object, numObjectivesData:int, objectiveDictionnaryIndex:int) : void { var targetObjective:Object = null; var overrideLastIndex:* = false; var finalIndex:int = 0; objAdded.visible = true; objAdded.follow = true; var obj:Object = null; var objectivesStartIndex:int = this._quests.indexOf(questData) + 1; var newIndex:int = 0; var nextObjectiveIndex:int = -1; var nextObjectiveFound:Boolean = false; var followedObjectives:int = 0; var visibleObjectives:int = 0; for(var k:int = 0; k < numObjectivesData; k++) { if(this._questsObjectivesOrder[questData.id + ""_"" + k]) { obj = this._questsObjectivesOrder[questData.id + ""_"" + k]; if(obj.follow) { followedObjectives++; } if(obj.visible) { visibleObjectives++; } else if(!nextObjectiveFound) { nextObjectiveIndex = k; nextObjectiveFound = true; } } } var optionalLabelIndex:int = objectivesStartIndex + visibleObjectives - 1; var objectiveMasked:int = 0; newIndex = objectivesStartIndex + followedObjectives - 1; if(this._questsObjectivesOrder[questData.id + ""_"" + nextObjectiveIndex]) { targetObjective = this._questsObjectivesOrder[questData.id + ""_"" + nextObjectiveIndex]; } if(this._quests[optionalLabelIndex] != null) { overrideLastIndex = !this._quests[optionalLabelIndex].isQuest; } else { overrideLastIndex = false; } if(followedObjectives < visibleObjectives) { if(followedObjectives > 0) { this.ReOrderObjectiveDictionary(objectiveDictionnaryIndex,followedObjectives - 1,questData.id); } if(visibleObjectives > MAX_OBJECTIVES) { targetObjective = this._questsObjectivesOrder[questData.id + ""_"" + (visibleObjectives - 1)]; targetObjective.visible = false; nextObjectiveFound = true; objectiveMasked = 1; this._quests.splice(optionalLabelIndex - objectiveMasked,!this._quests[optionalLabelIndex - objectiveMasked].isQuest ? 1 : 0); this._quests.splice(newIndex,0,objAdded); } else { this._quests.splice(newIndex,0,objAdded); } } else if(followedObjectives == visibleObjectives) { if(followedObjectives > 0) { this.ReOrderObjectiveDictionary(objectiveDictionnaryIndex,followedObjectives - 1,questData.id); } if(visibleObjectives > MAX_OBJECTIVES) { this._quests.splice(optionalLabelIndex,!!overrideLastIndex ? 1 : 0,objAdded); } else { this._quests.splice(newIndex,0,objAdded); } } else { this._quests.splice(optionalLabelIndex,!!overrideLastIndex ? 1 : 0,objAdded); this.ReOrderObjectiveDictionary(objectiveDictionnaryIndex,visibleObjectives - 1,questData.id); } if(visibleObjectives + 1 - objectiveMasked > MAX_OBJECTIVES) { if(nextObjectiveFound) { finalIndex = optionalLabelIndex + 1 - objectiveMasked; if(targetObjective != null) { if(this._quests[finalIndex]) { this._quests.splice(finalIndex,!this._quests[finalIndex].isQuest ? 1 : 0,targetObjective); } else { this._quests.splice(finalIndex,0,targetObjective); } } } else if(questData.objectives.length != MAX_OBJECTIVES) { this._quests.splice(optionalLabelIndex + 1,0,{ ""isQuest"":false, ""seeLess"":true, ""questId"":questData.id }); } } this.renderUpdate(); this.toggleObjectivesFlag(objAdded,false,questData.color); } private function getUnusedColor() : int { var i:int = 0; var color:uint = 0; var numColors:uint = this._colors.length; for(i = 0; i < numColors; i++) { if(this._colors[i] == false) { color = parseInt(sysApi.getConfigEntry(""colors.flag.quest"" + (i + 1))); this._colors[i] = color; return color; } } return -1; } private function setFlagColor(target:Object, color:uint, remove:Boolean = false) : void { var R:* = 0; var G:* = 0; var B:* = 0; if(!remove) { R = color >> 16 & 255; G = color >> 8 & 255; B = color >> 0 & 255; target.transform.colorTransform = new ColorTransform(0.6,0.6,0.6,1,R - 80,G - 80,B - 80); } else { target.transform.colorTransform = this._defaultColorTransform; } } private function getDataFromTarget(target:Object) : Object { var i:int = (this.gd_quests.renderer as MultiGridRenderer).getItemIndex(target); if(i != -1 && i <= this._quests.length - 1) { return this._quests[i]; } return null; } private function moveQuestToTheTop(questId:uint) : void { var i:int = 0; var deletedQuest:Array = this.removeQuest(questId,false); for(i = deletedQuest.length - 1; i >= 0; i--) { this._quests.unshift(deletedQuest[i]); } this.update(); var questsIds:Vector. = new Vector.(); var dataLen:uint = this._quests.length; for(i = 0; i < dataLen; i++) { if(this._quests[i].isQuest) { questsIds.push(this._quests[i].id); } } sysApi.sendAction(new RefreshFollowedQuestsOrderAction([questsIds])); } private function removeAllFlags() : void { var i:int = 0; var j:int = 0; var numObjectives:uint = 0; var dataLen:uint = this._quests.length; for(i = 0; i < dataLen; i++) { if(this._quests[i].isQuest) { numObjectives = this._quests[i].objectives.length; for(j = 0; j < numObjectives; j++) { if(this._quests[i].objectives[j].flagData) { sysApi.dispatchHook(HookList.RemoveMapFlag,this._quests[i].objectives[j].flagData.id,this._quests[i].objectives[j].flagData.worldMapId); } } } } } private function changeMaxDisplayedQuests(max:uint) : void { if(this._numQuests > max) { this.removeLastQuests(this._numQuests - max); this.update(); } this._maxQuests = max; sysApi.setData(MAX_FOLLOWED_QUESTS_DATA_ID,this._maxQuests,DataStoreEnum.BIND_ACCOUNT); } private function changeResizeMode() : void { this._resizeMode = this._resizeMode == FREE_RESIZE_MODE ? uint(AUTO_RESIZE_MODE) : uint(FREE_RESIZE_MODE); this.ctr_list.getResizeController().bottomResize = this._resizeMode == FREE_RESIZE_MODE; sysApi.setData(FOLLOWED_QUESTS_RESIZE_MODE_DATA_ID,this._resizeMode,DataStoreEnum.BIND_ACCOUNT); this.updateListSize(); } private function changeOpacity(opacity:Number) : void { this.ctr_list.bgAlpha = opacity; this._opacity = opacity; sysApi.setData(OPACITY_DATA_ID,this._opacity,DataStoreEnum.BIND_ACCOUNT); } private function changeFontSize(fontSize:uint) : void { this._fontSize = fontSize; sysApi.setData(FONT_SIZE_DATA_ID,this._fontSize,DataStoreEnum.BIND_ACCOUNT); this.update(); } private function minimize() : void { if(!sysApi.getData(QUEST_LIST_MINIMIZED_DATA_ID,DataStoreEnum.BIND_ACCOUNT)) { uiApi.me().visible = false; uiApi.me().isMagnetic = false; this.ctr_list.isMagnetic = false; sysApi.setData(QUEST_LIST_MINIMIZED_DATA_ID,true,DataStoreEnum.BIND_ACCOUNT); } } public function maximize() : void { if(sysApi.getData(QUEST_LIST_MINIMIZED_DATA_ID,DataStoreEnum.BIND_ACCOUNT)) { uiApi.me().visible = true; uiApi.me().isMagnetic = true; this.ctr_list.isMagnetic = true; sysApi.setData(QUEST_LIST_MINIMIZED_DATA_ID,false,DataStoreEnum.BIND_ACCOUNT); } } private function hasFlags() : Boolean { var i:int = 0; var dataLen:uint = this._quests.length; for(i = 0; i < dataLen; i++) { if(!this._quests[i].isQuest && this._quests[i].flagData && this._quests[i].follow) { return true; } } return false; } private function getQuestActiveObjectivesData(questId:uint) : Array { var questObjectives:Array = null; var i:int = 0; var objective:QuestObjective = null; var objectiveFlagInfos:Object = null; var questInfos:Object = this.questApi.getQuestInformations(questId); if(!questInfos) { return null; } var step:QuestStep = this.dataApi.getQuestStep(questInfos.stepId); if(step && step.objectives.length) { questObjectives = new Array(); for(i = 0; i < step.objectives.length; i++) { objective = this.dataApi.getQuestObjective(step.objectives[i].id); if(questInfos.objectives[objective.id]) { objectiveFlagInfos = objective.coords || objective.mapId ? this.questApi.getQuestObjectiveFlagInfos(questId,objective.id) : null; questObjectives.push({ ""id"":objective.id, ""flagData"":(!!objectiveFlagInfos ? { ""id"":objectiveFlagInfos.id, ""text"":objectiveFlagInfos.text, ""worldMapId"":objectiveFlagInfos.worldMapId, ""x"":objectiveFlagInfos.x, ""y"":objectiveFlagInfos.y } : null), ""isQuest"":false, ""questId"":questId }); } } } return questObjectives; } override protected function setVisible(value:Boolean) : void { var isInTutorial:Boolean = false; var hasQuest:Boolean = false; if(!sysApi.getData(QUEST_LIST_MINIMIZED_DATA_ID,DataStoreEnum.BIND_ACCOUNT)) { isInTutorial = playerApi.isInTutorialArea(); hasQuest = this._quests && this._quests.length > 0; super.setVisible(value && !isInTutorial && hasQuest); this.ctr_list.isMagnetic = value && !isInTutorial; } } private function toggleObjectivesFlag(objectiveData:Object, changeOrder:Boolean = true, color:int = -1, forceFollow:Boolean = false, forceFollowValue:Boolean = false) : void { var confirmFollow:Boolean = false; var followed:Boolean = false; if(objectiveData.flagData) { followed = objectiveData.follow; objectiveData.color = color != -1 ? color : objectiveData.color; objectiveData.questId; sysApi.dispatchHook(HookList.AddMapFlag,objectiveData.flagData.id,objectiveData.flagData.text,objectiveData.flagData.worldMapId,objectiveData.flagData.x,objectiveData.flagData.y,objectiveData.color,true); if(forceFollow) { if(forceFollowValue) { if(objectiveData.follow && this._components[objectiveData]) { this.setFlagColor(this._components[objectiveData].btn_loc,objectiveData.color); } sysApi.setData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + objectiveData.flagData.id,objectiveData.follow); objectiveData.follow = true; confirmFollow = true; } else { sysApi.dispatchHook(HookList.RemoveMapFlag,objectiveData.flagData.id,objectiveData.flagData.worldMapId); objectiveData.follow = false; confirmFollow = false; } } else if(objectiveData.follow == followed) { if(objectiveData.follow && this._components[objectiveData]) { this.setFlagColor(this._components[objectiveData].btn_loc,objectiveData.color); } sysApi.setData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + objectiveData.flagData.id,objectiveData.follow); objectiveData.follow = true; confirmFollow = true; } else { sysApi.dispatchHook(HookList.RemoveMapFlag,objectiveData.flagData.id,objectiveData.flagData.worldMapId); objectiveData.follow = false; confirmFollow = false; } if(changeOrder) { this.changeObjectivesOrder(objectiveData,confirmFollow); } } } private function questHasFlags(questData:Object) : Boolean { var i:int = 0; var objectiveData:Object = null; var numObjectives:uint = questData.objectives.length; for(i = 0; i < numObjectives; i++) { objectiveData = questData.objectives[i]; if(objectiveData.flagData) { return true; } } return false; } private function showQuestFlags(questData:Object, show:Boolean) : void { var i:int = 0; var objKey:String = null; var objectiveData:Object = null; var numObjectives:uint = questData.objectives.length; if(show) { this.clearQuestDisplay(questData,this._quests.indexOf(questData) + 1,true); } for(i = 0; i < numObjectives; i++) { objKey = questData.id + ""_"" + (!!show ? i : numObjectives - 1 - i); objectiveData = this._questsObjectivesOrder[objKey]; if(objectiveData.flagData) { if(show) { this.addObjective(questData,objectiveData,numObjectives,this.GetObjectiveDictionaryOrder(questData,objectiveData)); } else if(objectiveData.follow) { sysApi.dispatchHook(HookList.RemoveMapFlag,objectiveData.flagData.id,objectiveData.flagData.worldMapId); this.toggleObjectivesFlag(objectiveData,true,-1,true,false); } } } this.update(); } public function onWheel(target:Object, delta:int) : void { if(this.gridScrollContainer.useVerticalScroll && this.gridScrollContainer.hasVerticalScrollBar) { this._mouseScrollEvent.delta = delta; this.gridScrollContainer.verticalScrollBar.onWheel(this._mouseScrollEvent); } } public function onQuestValidated(questId:uint) : void { var followedQuests:Object = this.questApi.getFollowedQuests(); if(followedQuests.indexOf(questId) != -1) { this.unfollowQuest(questId); } } public function onQuestObjectiveValidated(questId:uint, objectiveId:uint) : void { var i:int = 0; var dataLen:uint = 0; var objectiveData:Object = null; var followedQuests:Object = this.questApi.getFollowedQuests(); if(followedQuests.indexOf(questId) != -1) { dataLen = this._quests.length; for(i = 0; i < dataLen; i++) { if(this._quests[i].isQuest && this._quests[i].id == questId) { for each(objectiveData in this._quests[i].objectives) { if(objectiveData.id == objectiveId) { this.removeObjective(objectiveData,true); return; } } } } } } public function onQuestStepValidated(questId:uint, stepId:uint) : void { var i:int = 0; var dataLen:uint = 0; var followedQuests:Object = this.questApi.getFollowedQuests(); if(followedQuests.indexOf(questId) != -1) { dataLen = this._quests.length; for(i = 0; i < dataLen; i++) { if(this._quests[i].isQuest && this._quests[i].id == questId) { while(this._quests[i].objectives.length) { this.removeObjective(this._quests[i].objectives[0],true); } return; } } } } public function onQuestStarted(questId:uint) : void { var followedQuests:Object = null; var requestInfos:Boolean = false; var followQuest:Boolean = this.configApi.getConfigProperty(""dofus"",""followQuestOnStarted""); if(followQuest) { followedQuests = this.questApi.getFollowedQuests(); if(followedQuests.indexOf(questId) != -1) { requestInfos = true; } else if(this._numQuests + this._startedQuests.length + 1 <= this._maxQuests) { this._startedQuests.push(questId); requestInfos = true; } if(requestInfos) { sysApi.sendAction(new QuestInfosRequestAction([questId])); } } } public function onQuestInfosUpdated(questId:uint, infosAvailable:Boolean) : void { var questObjectives:Array = null; var questData:Object = null; var numNewObjectives:int = 0; var numCurrentObjectives:int = 0; var objChangeNumber:int = 0; var followedObjectives:int = 0; var visibleObjectives:int = 0; var objectivesStartIndex:int = 0; var objDisplay:int = 0; var k:int = 0; var i:int = 0; var obj:Object = null; var objStillValid:Boolean = false; var j:int = 0; if(this.questApi.getFollowedQuests().indexOf(questId) != -1) { for each(questData in this._quests) { if(questData.isQuest && questData.id == questId) { questObjectives = this.getQuestActiveObjectivesData(questId); if(infosAvailable && questObjectives && questObjectives.length) { numNewObjectives = questObjectives.length; numCurrentObjectives = questData.objectives.length; objChangeNumber = 0; followedObjectives = 0; visibleObjectives = 0; objectivesStartIndex = this._quests.indexOf(questData) + 1; k = 0; while(true) { if(k < numCurrentObjectives) { if(this._questsObjectivesOrder[questData.id + ""_"" + k]) { obj = this._questsObjectivesOrder[questData.id + ""_"" + k]; objStillValid = false; for(j = 0; j < numCurrentObjectives; j++) { if(obj.id == questObjectives[j].id) { objStillValid = true; break; } } if(!objStillValid) { break; } if(obj.follow) { followedObjectives++; } if(obj.visible) { visibleObjectives++; } } continue; } for(i = 0; i < numNewObjectives; i++) { if(!questData.objectives[i] || questObjectives[i].id != questData.objectives[i].id) { questObjectives[i].follow = false; questObjectives[i].visible = false; questObjectives[i].color = questData.color; questData.objectives.splice(i,0,questObjectives[i]); this._questsObjectivesOrder[questData.id + ""_"" + (numCurrentObjectives + objChangeNumber)] = questObjectives[i]; objDisplay = followedObjectives + objChangeNumber; if(objDisplay < MAX_OBJECTIVES) { if(questObjectives[i].flagData) { questObjectives[i].follow = true; sysApi.sendAction(new FollowQuestAction([questId,questObjectives[i].id,true])); } questObjectives[i].visible = true; this.addObjective(questData,questObjectives[i],numNewObjectives,this.GetObjectiveDictionaryOrder(questData,questData.objectives[i])); } else if(objDisplay == MAX_OBJECTIVES) { if(!this._quests[objectivesStartIndex + objDisplay] || this._quests[objectivesStartIndex + objDisplay].isQuest) { this._quests.splice(objectivesStartIndex + objDisplay,0,questObjectives[i]); } else if(this._quests[objectivesStartIndex + objDisplay].seeLess) { this._quests.splice(objectivesStartIndex + objDisplay,1,questObjectives[i]); } } objChangeNumber++; } } this.update(); } this.removeObjective(obj,true); return; } this.unfollowQuest(questId); break; } } } else if(this._startedQuests.length && this._startedQuests.indexOf(questId) != -1) { if(infosAvailable && this._numQuests + 1 <= this._maxQuests) { questObjectives = this.getQuestActiveObjectivesData(questId); if(questObjectives && questObjectives.length) { this.addQuest({ ""questId"":questId, ""objectives"":questObjectives },false); this.update(); if(!sysApi.getData(QUEST_LIST_MINIMIZED_DATA_ID,DataStoreEnum.BIND_ACCOUNT)) { this.maximize(); } } } this._startedQuests.splice(this._startedQuests.indexOf(questId),1); } } public function onRelease(target:Object) : void { var targetData:Object = null; var visibleObjectives:uint = 0; var questId:int = 0; var numObjectives:uint = 0; var i:int = 0; var param:Object = null; var data:Object = null; var j:int = 0; var startIndex:int = 0; var tmpIndex:int = 0; var invisibleObjectivesNumber:uint = 0; var currentObjective:Object = null; var menu:Array = null; var followQuestOnStarted:Boolean = false; var nResizeMode:uint = 0; var fontSizes:Array = null; var opacities:Array = null; var questListMinimized:* = undefined; var k:uint = 0; if(target.name.indexOf(""btn_quest"") == 0 || target.name.indexOf(""btn_objective"") == 0) { targetData = this.getDataFromTarget(target); if(targetData) { questId = !!targetData.isQuest ? int(targetData.id) : int(targetData.questId); if(targetData.isQuest) { param = { ""quest"":this.dataApi.getQuest(questId), ""forceOpen"":true }; sysApi.dispatchHook(HookList.OpenBook,""questTab"",param); } else if(targetData.hasOwnProperty(""seeLess"")) { for each(data in this._quests) { if(data.isQuest && data.id == questId) { numObjectives = data.objectives.length; visibleObjectives = 0; for(i = 0; i < numObjectives; i++) { if(data.objectives[i].visible) { visibleObjectives++; } } for(i = MAX_OBJECTIVES; i < visibleObjectives; i++) { this._questsObjectivesOrder[data.id + ""_"" + i].visible = false; } startIndex = this._quests.indexOf(data) + 1 + MAX_OBJECTIVES; this._quests.splice(startIndex,numObjectives - MAX_OBJECTIVES); this._quests[startIndex] = this._questsObjectivesOrder[data.id + ""_"" + MAX_OBJECTIVES]; break; } } this.update(); } else if(!targetData.visible) { for each(data in this._quests) { if(data.isQuest && data.id == questId) { invisibleObjectivesNumber = 0; startIndex = this._quests.indexOf(data) + 1; numObjectives = data.objectives.length; visibleObjectives = 0; for(k = 0; k < numObjectives; k++) { if(data.objectives[k].visible) { visibleObjectives++; } } invisibleObjectivesNumber = numObjectives - visibleObjectives; for(j = 0; j < invisibleObjectivesNumber; j++) { tmpIndex = startIndex + visibleObjectives + j; currentObjective = this._questsObjectivesOrder[data.id + ""_"" + (visibleObjectives + j)]; currentObjective.visible = true; currentObjective.follow = currentObjective.flagData && this.getFlag(currentObjective.flagData.id,currentObjective.flagData.worldMapId) != null; this._quests.splice(tmpIndex,0,currentObjective); } this._quests.splice(tmpIndex + 1,1,{ ""isQuest"":false, ""seeLess"":true, ""questId"":data.id }); break; } } this.update(); } } } else if(target.name.indexOf(""btn_loc"") == 0) { targetData = this.getDataFromTarget(target); if(targetData) { this.toggleObjectivesFlag(targetData,true,-1,true,!targetData.follow); } } else { switch(target) { case this.btn_options: menu = new Array(); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.followMaxQuests"",3),this.changeMaxDisplayedQuests,[3],false,null,this._maxQuests == 3)); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.followMaxQuests"",5),this.changeMaxDisplayedQuests,[5],false,null,this._maxQuests == 5)); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.followMaxQuests"",10),this.changeMaxDisplayedQuests,[10],false,null,this._maxQuests == 10)); menu.push(this.modContextMenu.createContextMenuSeparatorObject()); followQuestOnStarted = this.configApi.getConfigProperty(""dofus"",""followQuestOnStarted""); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.followOnStarted""),this.configApi.setConfigProperty,[""dofus"",""followQuestOnStarted"",!followQuestOnStarted],false,null,followQuestOnStarted == true,false)); menu.push(this.modContextMenu.createContextMenuSeparatorObject()); if(this._resizeMode == AUTO_RESIZE_MODE) { nResizeMode = FREE_RESIZE_MODE; } else if(this._resizeMode == FREE_RESIZE_MODE) { nResizeMode = AUTO_RESIZE_MODE; } menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.followedQuests.autoResize""),this.changeResizeMode,null,false,null,this._resizeMode == AUTO_RESIZE_MODE,false)); menu.push(this.modContextMenu.createContextMenuSeparatorObject()); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.removeAllFlags""),this.removeAllFlags,null,!this.hasFlags())); menu.push(this.modContextMenu.createContextMenuSeparatorObject()); fontSizes = new Array(); fontSizes.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.option.small""),this.changeFontSize,[FONT_SMALL_SIZE],false,null,this._fontSize == FONT_SMALL_SIZE)); fontSizes.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.option.medium""),this.changeFontSize,[FONT_MEDIUM_SIZE],false,null,this._fontSize == FONT_MEDIUM_SIZE)); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.option.fontSize""),null,null,false,fontSizes)); menu.push(this.modContextMenu.createContextMenuSeparatorObject()); opacities = new Array(); opacities.push(this.modContextMenu.createContextMenuItemObject(""50%"",this.changeOpacity,[0.5],false,null,this._opacity == 0.5)); opacities.push(this.modContextMenu.createContextMenuItemObject(""70%"",this.changeOpacity,[0.7],false,null,this._opacity == 0.7)); opacities.push(this.modContextMenu.createContextMenuItemObject(""90%"",this.changeOpacity,[0.9],false,null,this._opacity == 0.9)); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.cartography.opacitymenu""),null,null,false,opacities)); this.modContextMenu.createContextMenu(menu); break; case this.btn_minimize: this.minimize(); questListMinimized = uiApi.getUi(UIEnum.QUEST_LIST_MINIMIZED); if(questListMinimized && questListMinimized.uiClass) { questListMinimized.uiClass.visible = true; } else { uiApi.loadUi(UIEnum.QUEST_LIST_MINIMIZED,UIEnum.QUEST_LIST_MINIMIZED,null,StrataEnum.STRATA_TOP); } } } } public function onRightClick(target:Object) : void { var menu:Array = null; var objective:QuestObjective = null; var targetData:Object = this.getDataFromTarget(target); if(targetData && (targetData.isQuest || targetData.visible && !targetData.hasOwnProperty(""seeLess""))) { if(target.name.indexOf(""btn_quest"") == 0) { menu = new Array(); menu.push(this.modContextMenu.createContextMenuTitleObject(this.dataApi.getQuest(targetData.id).name)); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.unfollow""),this.unfollowQuest,[targetData.id])); if(this._quests.indexOf(targetData) > 0) { menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.moveToTheTop""),this.moveQuestToTheTop,[targetData.id])); } if(this.questHasFlags(targetData)) { menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.showQuestObjectivesFlags""),this.showQuestFlags,[targetData,true])); menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.hideQuestObjectivesFlags""),this.showQuestFlags,[targetData,false])); } this.modContextMenu.createContextMenu(menu); } else if(target.name.indexOf(""btn_objective"") == 0) { objective = this.dataApi.getQuestObjective(targetData.id); menu = new Array(); if(targetData.flagData) { if(targetData.follow) { menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.removeFlag""),this.toggleObjectivesFlag,[targetData,true,-1,true,false])); } else { menu.push(this.modContextMenu.createContextMenuItemObject(uiApi.getText(""ui.quest.addFlag""),this.toggleObjectivesFlag,[targetData,true,-1,true,true])); } } this.modContextMenu.createContextMenu(menu); } } } public function onRollOver(target:Object) : void { var targetData:Object = this.getDataFromTarget(target); if(targetData && (targetData.hasOwnProperty(""seeLess"") || !targetData.visible)) { Mouse.cursor = MouseCursor.BUTTON; } } public function onRollOut(target:Object) : void { var targetData:Object = this.getDataFromTarget(target); if(targetData && (targetData.hasOwnProperty(""seeLess"") || !targetData.visible)) { Mouse.cursor = MouseCursor.AUTO; } } public function onFontActiveTypeChanged() : void { this.renderUpdate(); } public function onFlagRemoved(flagId:String, worldmapId:int) : void { var objectiveData:Object = null; if(flagId.indexOf(""flag_srv"" + CompassTypeEnum.COMPASS_TYPE_QUEST) == 0) { objectiveData = this._flagsQuestData[flagId]; if(objectiveData && this._quests.indexOf(objectiveData) != -1) { objectiveData.follow = false; this.setFlagColor(this._components[objectiveData].btn_loc,objectiveData.color,true); sysApi.setData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + flagId,false); } } } public function onFlagAdded(flagId:String, worldmapId:int, x:int, y:int, color:int, flagLegend:String, canBeManuallyRemoved:Boolean = true, allowDuplicate:Boolean = false) : void { var objectiveData:Object = null; if(flagId.indexOf(""flag_srv"" + CompassTypeEnum.COMPASS_TYPE_QUEST) == 0) { objectiveData = this._flagsQuestData[flagId]; if(objectiveData && this._quests.indexOf(objectiveData) != -1) { sysApi.setData(playerApi.getPlayedCharacterInfo().id + ""-questFlag-"" + flagId,true); } } } } } ",16324,True,3338.5034820650703,median "CLASS zcl_abapgit_gui_router DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES zif_abapgit_gui_event_handler. PROTECTED SECTION. PRIVATE SECTION. METHODS general_page_routing IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS abapgit_services_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS db_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. CLASS-METHODS file_download IMPORTING !iv_package TYPE devclass !iv_xstr TYPE xstring RAISING zcx_abapgit_exception . METHODS git_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS remote_origin_manipulations IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS sap_gui_actions IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS other_utilities IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS zip_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS repository_services IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result RAISING zcx_abapgit_exception. METHODS get_page_diff IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_branch_overview IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_stage IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS get_page_background IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . CLASS-METHODS jump_display_transport IMPORTING !iv_transport TYPE trkorr RAISING zcx_abapgit_exception . CLASS-METHODS jump_display_user IMPORTING !iv_username TYPE xubname RAISING zcx_abapgit_exception . METHODS call_browser IMPORTING !iv_url TYPE csequence RAISING zcx_abapgit_exception. METHODS get_state_settings IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i. METHODS get_state_diff IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i. METHODS get_state_db_edit IMPORTING !ii_event TYPE REF TO zif_abapgit_gui_event RETURNING VALUE(rv_state) TYPE i. ENDCLASS. CLASS zcl_abapgit_gui_router IMPLEMENTATION. METHOD abapgit_services_actions. DATA: li_main_page TYPE REF TO zcl_abapgit_gui_page_main. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-abapgit_home. CREATE OBJECT li_main_page. rs_handled-page = li_main_page. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-abapgit_install. "" Install abapGit zcl_abapgit_services_abapgit=>install_abapgit( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD call_browser. cl_gui_frontend_services=>execute( EXPORTING document = |{ iv_url }| EXCEPTIONS cntl_error = 1 error_no_gui = 2 bad_parameter = 3 file_not_found = 4 path_not_found = 5 file_extension_unknown = 6 error_execute_failed = 7 synchronous_failed = 8 not_supported_by_gui = 9 OTHERS = 10 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD db_actions. DATA ls_db_key TYPE zif_abapgit_persistence=>ty_content. DATA lo_query TYPE REF TO zcl_abapgit_string_map. lo_query = ii_event->query( ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-db_edit. lo_query->to_abap( CHANGING cs_container = ls_db_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db_edit EXPORTING is_key = ls_db_key. rs_handled-state = get_state_db_edit( ii_event ). WHEN zif_abapgit_definitions=>c_action-db_display. lo_query->to_abap( CHANGING cs_container = ls_db_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db_dis EXPORTING is_key = ls_db_key. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. ENDCASE. ENDMETHOD. METHOD file_download. DATA: lv_path TYPE string, lv_default TYPE string, li_fe_serv TYPE REF TO zif_abapgit_frontend_services, lv_package TYPE devclass. lv_package = iv_package. TRANSLATE lv_package USING '/#'. CONCATENATE lv_package '_' sy-datlo '_' sy-timlo INTO lv_default. li_fe_serv = zcl_abapgit_ui_factory=>get_frontend_services( ). lv_path = li_fe_serv->show_file_save_dialog( iv_title = 'Export ZIP' iv_extension = 'zip' iv_default_filename = lv_default ). li_fe_serv->file_download( iv_path = lv_path iv_xstr = iv_xstr ). ENDMETHOD. METHOD general_page_routing. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_last_repo_key TYPE zif_abapgit_persistence=>ty_repo-key, lt_repo_list TYPE zif_abapgit_persistence=>ty_repos. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zcl_abapgit_gui=>c_action-go_home. lv_last_repo_key = zcl_abapgit_persistence_user=>get_instance( )->get_repo_show( ). lt_repo_list = zcl_abapgit_persist_factory=>get_repo( )->list( ). IF lv_last_repo_key IS NOT INITIAL. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lv_last_repo_key. ELSEIF lt_repo_list IS NOT INITIAL. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main. ELSE. rs_handled-page = zcl_abapgit_gui_page_tutorial=>create( ). ENDIF. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_db. "" Go DB util page CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_db. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_debuginfo. "" Go debug info CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_debuginfo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_settings. "" Go global settings rs_handled-page = zcl_abapgit_gui_page_sett_glob=>create( ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_settings_personal. "" Go personal settings rs_handled-page = zcl_abapgit_gui_page_sett_pers=>create( ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_background_run. "" Go background run page CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_bkg_run. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_background. "" Go Background page rs_handled-page = get_page_background( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_diff. "" Go Diff page rs_handled-page = get_page_diff( ii_event ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. WHEN zif_abapgit_definitions=>c_action-go_stage. "" Go Staging page rs_handled-page = get_page_stage( ii_event ). rs_handled-state = get_state_diff( ii_event ). WHEN zif_abapgit_definitions=>c_action-go_branch_overview. "" Go repo branch overview rs_handled-page = get_page_branch_overview( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-go_tutorial. "" Go to tutorial rs_handled-page = zcl_abapgit_gui_page_tutorial=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-documentation. "" abapGit docs zcl_abapgit_services_abapgit=>open_abapgit_wikipage( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-go_explore. "" dotabap zcl_abapgit_services_abapgit=>open_dotabap_homepage( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-changelog. "" abapGit full changelog zcl_abapgit_services_abapgit=>open_abapgit_changelog( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD get_page_background. CREATE OBJECT ri_page TYPE zcl_abapgit_gui_page_bkg EXPORTING iv_key = iv_key. ENDMETHOD. METHOD get_page_branch_overview. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lo_page TYPE REF TO zcl_abapgit_gui_page_boverview. lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ). CREATE OBJECT lo_page EXPORTING io_repo = lo_repo. ri_page = lo_page. ENDMETHOD. METHOD get_page_diff. DATA: ls_file TYPE zif_abapgit_definitions=>ty_file, ls_object TYPE zif_abapgit_definitions=>ty_item, lo_page TYPE REF TO zcl_abapgit_gui_page_diff, lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). ls_file-path = ii_event->query( )->get( 'PATH' ). ls_file-filename = ii_event->query( )->get( 'FILENAME' ). "" unescape ? ls_object-obj_type = ii_event->query( )->get( 'OBJ_TYPE' ). ls_object-obj_name = ii_event->query( )->get( 'OBJ_NAME' ). "" unescape ? CREATE OBJECT lo_page EXPORTING iv_key = lv_key is_file = ls_file is_object = ls_object. ri_page = lo_page. ENDMETHOD. METHOD get_page_stage. DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online, lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lv_seed TYPE string, lo_stage_page TYPE REF TO zcl_abapgit_gui_page_stage, lo_code_inspector_page TYPE REF TO zcl_abapgit_gui_page_code_insp, lo_page_repo TYPE REF TO zcl_abapgit_gui_page_repo_view, lv_answer TYPE c LENGTH 1, lv_question_text TYPE string, lv_question_title TYPE string, lv_show_create_branch_popup TYPE c LENGTH 1. lv_key = ii_event->query( )->get( 'KEY' ). lv_seed = ii_event->query( )->get( 'SEED' ). lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). IF lo_repo->get_local_settings( )-code_inspector_check_variant IS NOT INITIAL. CREATE OBJECT lo_code_inspector_page EXPORTING io_repo = lo_repo. ri_page = lo_code_inspector_page. ELSEIF lo_repo->get_selected_branch( ) CP zif_abapgit_definitions=>c_git_branch-tags. lv_show_create_branch_popup = abap_true. lv_question_title = 'Staging on a tag'. lv_question_text = 'You are currently working on a tag.'. lv_question_text = |{ lv_question_text } You must be on a branch to stage.|. lv_question_text = |{ lv_question_text } Create new branch?|. ELSEIF lo_repo->get_selected_commit( ) IS NOT INITIAL. lv_show_create_branch_popup = abap_true. lv_question_title = 'Staging on a checked out commit'. lv_question_text = 'You are currently checked out in a commit.'. lv_question_text = |{ lv_question_text } You must be on a branch to stage.|. lv_question_text = |{ lv_question_text } Create new branch?|. ELSE. "" force refresh on stage, to make sure the latest local and remote files are used lo_repo->refresh( ). CREATE OBJECT lo_stage_page EXPORTING io_repo = lo_repo iv_seed = lv_seed. ri_page = lo_stage_page. ENDIF. IF lv_show_create_branch_popup = abap_true. lv_answer = zcl_abapgit_ui_factory=>get_popups( )->popup_to_confirm( iv_titlebar = lv_question_title iv_text_question = lv_question_text iv_text_button_1 = 'New branch' ""Ideally the button name would be Create branch, but it did not fit iv_icon_button_1 = 'ICON_OKAY' iv_text_button_2 = 'Cancel' iv_icon_button_2 = 'ICON_CANCEL' iv_default_button = '2' iv_display_cancel_button = abap_false ). IF lv_answer = '1'. TRY. zcl_abapgit_services_git=>create_branch( iv_key = lo_repo->get_key( ) ). CATCH zcx_abapgit_cancel. ""Continue processing so we can return to the correct page ENDTRY. ENDIF. CREATE OBJECT lo_page_repo TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lo_repo->get_key( ). ri_page = lo_page_repo. ENDIF. ENDMETHOD. METHOD get_state_db_edit. "" In display mode, replace the page IF ii_event->mv_current_page_name = 'ZCL_ABAPGIT_GUI_PAGE_DB_DIS'. rv_state = zcl_abapgit_gui=>c_event_state-new_page_replacing. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page. ENDIF. ENDMETHOD. METHOD get_state_diff. "" Bookmark current page before jumping to diff page IF ii_event->mv_current_page_name CP 'ZCL_ABAPGIT_GUI_PAGE_DIFF'. rv_state = zcl_abapgit_gui=>c_event_state-new_page. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. ENDIF. ENDMETHOD. METHOD get_state_settings. "" Bookmark current page before jumping to any settings page IF ii_event->mv_current_page_name CP 'ZCL_ABAPGIT_GUI_PAGE_SETT_*'. rv_state = zcl_abapgit_gui=>c_event_state-new_page_replacing. ELSE. rv_state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark. ENDIF. ENDMETHOD. METHOD git_services. DATA lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-git_pull. "" GIT Pull zcl_abapgit_services_git=>pull( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_reset. "" GIT Reset zcl_abapgit_services_git=>reset( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_checkout_commit. "" GIT Checkout commit zcl_abapgit_services_git=>checkout_commit( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_create. "" GIT Create new branch zcl_abapgit_services_git=>create_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_delete. "" GIT Delete remote branch zcl_abapgit_services_git=>delete_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_branch_switch. "" GIT Switch branch zcl_abapgit_services_git=>switch_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-go_tag_overview. "" GIT Tag overview zcl_abapgit_services_git=>tag_overview( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_create. "" GIT Tag create CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_tag EXPORTING io_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-git_tag_delete. "" GIT Tag create zcl_abapgit_services_git=>delete_tag( lv_key ). zcl_abapgit_services_repo=>refresh( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-git_tag_switch. "" GIT Switch Tag zcl_abapgit_services_git=>switch_tag( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD jump_display_transport. DATA: lv_transport_adt_uri TYPE string, lv_adt_link TYPE string, lv_adt_jump_enabled TYPE abap_bool. lv_adt_jump_enabled = zcl_abapgit_persist_settings=>get_instance( )->read( )->get_adt_jump_enabled( ). IF lv_adt_jump_enabled = abap_true. TRY. CALL METHOD ('CL_CTS_ADT_TM_URI_BUILDER')=>('CREATE_ADT_URI') EXPORTING trnumber = iv_transport RECEIVING result = lv_transport_adt_uri. lv_adt_link = |adt://{ sy-sysid }{ lv_transport_adt_uri }|. cl_gui_frontend_services=>execute( EXPORTING document = lv_adt_link EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'ADT Jump Error' ). ENDIF. CATCH cx_root. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = iv_transport. ENDTRY. ELSE. CALL FUNCTION 'TR_DISPLAY_REQUEST' EXPORTING i_trkorr = iv_transport. ENDIF. ENDMETHOD. METHOD jump_display_user. "" todo, user display in ADT CALL FUNCTION 'BAPI_USER_DISPLAY' EXPORTING username = iv_username. ENDMETHOD. METHOD other_utilities. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-changed_by. zcl_abapgit_services_basis=>test_changed_by( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-performance_test. zcl_abapgit_services_basis=>run_performance_test( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-ie_devtools. zcl_abapgit_services_basis=>open_ie_devtools( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD remote_origin_manipulations. DATA lv_key TYPE zif_abapgit_persistence=>ty_repo-key. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-repo_remote_attach. "" Remote attach zcl_abapgit_services_repo=>remote_attach( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_remote_detach. "" Remote detach zcl_abapgit_services_repo=>remote_detach( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_remote_change. "" Remote change zcl_abapgit_services_repo=>remote_change( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. ENDCASE. ENDMETHOD. METHOD repository_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_repo TYPE REF TO zcl_abapgit_repo, li_log TYPE REF TO zif_abapgit_log. lv_key = ii_event->query( )->get( 'KEY' ). IF lv_key IS NOT INITIAL. lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). ENDIF. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-repo_newoffline. "" New offline repo rs_handled-page = zcl_abapgit_gui_page_addofflin=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_add_all_obj_to_trans_req. "" Add objects to transport zcl_abapgit_transport=>add_all_objects_to_trans_req( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_refresh. "" Repo refresh zcl_abapgit_services_repo=>refresh( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_syntax_check. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_syntax "" Syntax check EXPORTING io_repo = lo_repo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_code_inspector. "" Code inspector CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_code_insp EXPORTING io_repo = lo_repo. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_purge. "" Repo purge all objects (uninstall) zcl_abapgit_services_repo=>purge( lv_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN zif_abapgit_definitions=>c_action-repo_remove. "" Repo remove zcl_abapgit_services_repo=>remove( lv_key ). CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_main. rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_replacing. WHEN zif_abapgit_definitions=>c_action-repo_newonline. "" New offline repo rs_handled-page = zcl_abapgit_gui_page_addonline=>create( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN zif_abapgit_definitions=>c_action-repo_refresh_checksums. "" Rebuild local checksums zcl_abapgit_services_repo=>refresh_local_checksums( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_toggle_fav. "" Toggle repo as favorite zcl_abapgit_services_repo=>toggle_favorite( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_transport_to_branch. "" Transport to branch zcl_abapgit_services_repo=>transport_to_branch( lv_key ). rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN zif_abapgit_definitions=>c_action-repo_settings. "" Repo settings rs_handled-page = zcl_abapgit_gui_page_sett_repo=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_local_settings. "" Local repo settings rs_handled-page = zcl_abapgit_gui_page_sett_locl=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_infos. "" Repo infos rs_handled-page = zcl_abapgit_gui_page_sett_info=>create( lo_repo ). rs_handled-state = get_state_settings( ii_event ). WHEN zif_abapgit_definitions=>c_action-repo_log. "" Repo log li_log = lo_repo->get_log( ). zcl_abapgit_log_viewer=>show_log( li_log ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD sap_gui_actions. DATA: ls_item TYPE zif_abapgit_definitions=>ty_item, lx_ex TYPE REF TO zcx_abapgit_exception, li_html_viewer TYPE REF TO zif_abapgit_html_viewer. CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-jump. "" Open object editor ls_item-obj_type = ii_event->query( )->get( 'TYPE' ). ls_item-obj_name = ii_event->query( )->get( 'NAME' ). li_html_viewer = zcl_abapgit_ui_factory=>get_html_viewer( ). TRY. "" Hide HTML Viewer in dummy screen0 for direct CALL SCREEN to work li_html_viewer->set_visiblity( abap_false ). zcl_abapgit_objects=>jump( ls_item ). li_html_viewer->set_visiblity( abap_true ). CATCH zcx_abapgit_exception INTO lx_ex. li_html_viewer->set_visiblity( abap_true ). RAISE EXCEPTION lx_ex. ENDTRY. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-jump_transport. jump_display_transport( |{ ii_event->query( )->get( 'TRANSPORT' ) }| ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-jump_user. jump_display_user( |{ ii_event->query( )->get( 'USER' ) }| ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-url. call_browser( ii_event->query( )->get( 'URL' ) ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. rs_handled = general_page_routing( ii_event ). IF rs_handled-state IS INITIAL. rs_handled = repository_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = git_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = zip_services( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = db_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = abapgit_services_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = remote_origin_manipulations( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = sap_gui_actions( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled = other_utilities( ii_event ). ENDIF. IF rs_handled-state IS INITIAL. rs_handled-state = zcl_abapgit_gui=>c_event_state-not_handled. ENDIF. ENDMETHOD. METHOD zip_services. DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_repo TYPE REF TO zcl_abapgit_repo, lv_package TYPE devclass, lv_path TYPE string, lv_xstr TYPE xstring. CONSTANTS: BEGIN OF lc_page, main_view TYPE string VALUE 'ZCL_ABAPGIT_GUI_PAGE_MAIN', repo_view TYPE string VALUE 'ZCL_ABAPGIT_GUI_PAGE_REPO_VIEW', END OF lc_page. lv_key = ii_event->query( )->get( 'KEY' ). CASE ii_event->mv_action. WHEN zif_abapgit_definitions=>c_action-zip_import. "" Import repo from ZIP lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). lv_path = zcl_abapgit_ui_factory=>get_frontend_services( )->show_file_open_dialog( iv_title = 'Import ZIP' iv_extension = 'zip' iv_default_filename = '*.zip' ). lv_xstr = zcl_abapgit_ui_factory=>get_frontend_services( )->file_upload( lv_path ). lo_repo->set_files_remote( zcl_abapgit_zip=>load( lv_xstr ) ). zcl_abapgit_services_repo=>refresh( lv_key ). CASE ii_event->mv_current_page_name. WHEN lc_page-repo_view. rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. WHEN lc_page-main_view. CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view EXPORTING iv_key = lo_repo->get_key( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. WHEN OTHERS. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. WHEN zif_abapgit_definitions=>c_action-zip_export. "" Export repo as ZIP lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ). lv_xstr = zcl_abapgit_zip=>encode_files( lo_repo->get_files_local( ) ). file_download( iv_package = lo_repo->get_package( ) iv_xstr = lv_xstr ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_package. "" Export package as ZIP zcl_abapgit_zip=>export_package( IMPORTING ev_xstr = lv_xstr ev_package = lv_package ). file_download( iv_package = lv_package iv_xstr = lv_xstr ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_transport. "" Export transports as ZIP zcl_abapgit_transport_mass=>run( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. WHEN zif_abapgit_definitions=>c_action-zip_object. "" Export object as ZIP zcl_abapgit_zip=>export_object( ). rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. ENDCASE. ENDMETHOD. ENDCLASS. ",8013,False,1911.7695597580616,median "package raix.reactive { import flash.errors.IllegalOperationError; import flash.utils.getQualifiedClassName; import raix.reactive.impl.*; import raix.reactive.scheduling.*; import raix.reactive.subjects.AsyncSubject; import raix.reactive.subjects.ConnectableObservable; import raix.reactive.subjects.IConnectableObservable; import raix.reactive.subjects.ReplaySubject; /** * Subclass this class only if you want to implement a completely custom IObservable. * *

If you can avoid it, however, try to stick to subclassing Subject or using * one of the creation methods.

* *

This class may be made inaccessible in future revisions

*/ public class AbsObservable implements IObservable { public function AbsObservable() { } /** * @inheritDoc */ public function subscribeWith(observer : IObserver) : ICancelable { // Abstract methods not supported by AS3 throw new IllegalOperationError(""subscribe() must be overriden""); } /** * @inheritDoc */ public function subscribe(onNext : Function, onComplete : Function = null, onError : Function = null) : ICancelable { var observer : IObserver = new ClosureObserver(onNext, onComplete, onError); return subscribeWith(observer); } /** * @inheritDoc */ public function and(right : IObservable) : Pattern { return new Pattern([this, right]); } /** * @inheritDoc */ public function reduce(accumulator : Function, initialValue : Object = null, useInitialValue : Boolean = false) : IObservable { return scan(accumulator, initialValue, useInitialValue).last(); } /** * @inheritDoc */ public function aggregate(accumulator : Function, initialValue : Object = null, useInitialValue : Boolean = false) : IObservable { return reduce(accumulator, initialValue, useInitialValue); } /** * @inheritDoc */ public function average(valueSelector : Function = null):IObservable { var source : IObservable = (valueSelector == null) ? this : this.map(valueSelector); return new ClosureObservable(function(obs:IObserver):ICancelable { var total : Number = 0; var count : Number = 0; return source.subscribe( function(v:Number):void { count++; total += v; }, function():void { if (count == 0) { obs.onError(new Error(""Sequence contained no elements"")); } else { obs.onNext(total / count); obs.onCompleted(); } }, obs.onError); }); return reduce(function(x:Number, y:Number):Number { return x+y; }, 0); } /** * @inheritDoc */ public function any(predicate : Function = null) : IObservable { var source : IObservable = this; predicate = predicate || function(o:Object):Boolean { return true; } return new ClosureObservable(function(observer : IObserver):ICancelable { return source.subscribe( function(pl : Object) : void { var result : Boolean = false; try { result = predicate(pl); } catch(error : Error) { observer.onError(error); return; } if (result) { observer.onNext(true); observer.onCompleted(); } }, function () : void { observer.onNext(false); observer.onCompleted(); }, observer.onError ); }); } /** * @inheritDoc */ public function all(predicate : Function) : IObservable { var source : IObservable = this; predicate = predicate || function(o:Object):Boolean { return true; } return new ClosureObservable(function(observer : IObserver):ICancelable { return source.subscribe( function(pl : Object) : void { var result : Boolean = false; try { result = predicate(pl); } catch(error : Error) { observer.onError(error); return; } if (!result) { observer.onNext(false); observer.onCompleted(); } }, function () : void { observer.onNext(true); observer.onCompleted(); }, observer.onError ); }); } /** * @inheritDoc */ public function bufferWithCount(count:uint, skip:uint=0):IObservable { return windowWithCount(count, skip) .mapMany(function(v:IObservable):IObservable { return v.toArray(); }) .filter(function(v:Array):Boolean { return v.length > 0; }); } /** * @inheritDoc */ public function windowWithCount(count:uint, skip:uint=0):IObservable { if (count == 0) { throw new ArgumentError(""count must be > 0""); } // skip == count and skip == 0 are functionally equivalent if (skip == 0) { skip = count; } var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var activeWindows : Array = new Array(); var valueCount : int = 0; var createWindow : Function = function():void { var window : Subject = new Subject(); activeWindows.push(window); observer.onNext(window); }; createWindow(); return source.subscribe( function(v:Object) : void { for each(var subject : Subject in activeWindows) { subject.onNext(v); } var unusedValues : int = (valueCount - count + 1); if (unusedValues >= 0 && (unusedValues % skip) == 0) { activeWindows.splice(0, 1)[0].onCompleted(); } valueCount++; if ((valueCount % skip) == 0) { createWindow(); } }, function():void { for (var i:int=0; i 0""); } // skip == count and skip == 0 are functionally equivalent if (timeShiftMs == 0) { timeShiftMs = timeMs; } scheduler = scheduler || Scheduler.synchronous; var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var activeWindows : Array = new Array(); var nextSpanTime : Number = timeMs; var nextShiftTime : Number = timeShiftMs; var totalTime : Number = 0; var subscriptions : CompositeCancelable = new CompositeCancelable([]); var checkWindowSchedule : MutableCancelable = new MutableCancelable(); subscriptions.add(checkWindowSchedule); var checkWindow : Function; checkWindow = function():void { var isSpan : Boolean = false, isShift : Boolean = false; if (nextSpanTime == nextShiftTime) { isSpan = true; isShift = true; } else if (nextSpanTime < nextShiftTime) { isSpan = true; } else { isShift = true; } var scheduleMs : Number = isSpan ? nextSpanTime : nextShiftTime; var dueTime : Number = scheduleMs - totalTime; totalTime = scheduleMs; if (isSpan) { nextSpanTime += timeShiftMs; } if (isShift) { nextShiftTime += timeShiftMs; } checkWindowSchedule.cancelable = scheduler.schedule(function():void { if (isShift) { var window : Subject = new Subject(); activeWindows.push(window); observer.onNext(window); } if (isSpan) { activeWindows.splice(0, 1)[0].onCompleted(); } checkWindow(); }, dueTime); }; subscriptions.add(scheduler.schedule(function():void { var window : Subject = new Subject(); activeWindows.push(window); observer.onNext(window); checkWindow(); var sourceSubscription : MutableCancelable = new MutableCancelable(); subscriptions.add(sourceSubscription); sourceSubscription.cancelable = source.subscribe( function(v:Object) : void { for each(var subject : Subject in activeWindows) { subject.onNext(v); } }, function():void { for each(var subject : Subject in activeWindows) { subject.onCompleted(); } observer.onCompleted(); }, function(e:Error):void { for each(var subject : Subject in activeWindows) { subject.onError(e); } observer.onError(e); }); })); return subscriptions; }); } /** * @inheritDoc */ public function bufferWithTimeOrCount(timeMs:uint, count:uint, scheduler:IScheduler=null):IObservable { return windowWithTimeOrCount(timeMs, count, scheduler) .mapMany(function(v:IObservable):IObservable { return v.toArray(); }); } /** * @inheritDoc */ public function windowWithTimeOrCount(timeMs:uint, count:uint, scheduler:IScheduler=null):IObservable { if (timeMs == 0) { throw new ArgumentError(""timeMs must be > 0""); } if (count == 0) { throw new ArgumentError(""count must be > 0""); } scheduler ||= Scheduler.synchronous; var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var currentTimeout : MutableCancelable = new MutableCancelable(); var sourceSubscription : MutableCancelable = new MutableCancelable(); var subscriptions : CompositeCancelable = new CompositeCancelable([currentTimeout, sourceSubscription]); var window : Subject = null; var createNewWindow : Function = null; var windowItemCount : uint = 0; createNewWindow = function():void { if (window != null) { window.onCompleted(); } windowItemCount = 0; window = new Subject(); observer.onNext(window); currentTimeout.cancelable = scheduler.schedule(createNewWindow, timeMs); }; createNewWindow(); sourceSubscription.cancelable = source.subscribe( function(v:Object) : void { window.onNext(v); windowItemCount++; if (windowItemCount == count) { createNewWindow(); } }, function():void { window.onCompleted(); observer.onCompleted(); }, function(e:Error):void { window.onError(e); observer.onError(e); }); return subscriptions; }); } /** * @inheritDoc */ public function cast(valueClass : Class) : IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver) : ICancelable { return source.subscribe( function(x : Object) : void { if (x == null) { observer.onNext(x); } else { var obj : Object = x as valueClass; if (obj == null) { var fromClassName : String = getQualifiedClassName(x); var toClassName : String = getQualifiedClassName(valueClass); var error : Error = new TypeError( ""Error #1034: Type Coercion failed: cannot convert "" + fromClassName + "" to "" + toClassName ); observer.onError(error); return; } else { observer.onNext(obj); } } }, observer.onCompleted, observer.onError); }); } /** * @inheritDoc */ public function catchError(second : IObservable) : IObservable { return Observable.catchErrors([this, second]); } /** * @inheritDoc */ public function catchErrorDefer(errorClass : Class, deferFunc : Function) : IObservable { var source : IObservable = this; if (deferFunc == null) { throw new ArgumentError(""deferFunc""); } errorClass = errorClass || Error; return new ClosureObservable(function(obs:IObserver) : ICancelable { var subscription : ICancelable = null; subscription = source.subscribe( function(pl:Object) : void { obs.onNext(pl); }, function() : void { obs.onCompleted(); }, function(e : Error) : void { if (e is errorClass) { var catchObservable : IObservable = null; try { catchObservable = IObservable(deferFunc(e)); } catch(funcErr : Error) { obs.onError(funcErr); return; } if (catchObservable == null) { obs.onError(e); } else { subscription = catchObservable.subscribeWith(obs); } } else { obs.onError(e); } }); return new ClosureCancelable(function():void { if (subscription != null) { subscription.cancel(); } }); }); } /** * @inheritDoc */ public function chain(functions : Array) : IObservable { var source : IObservable = this; for each(var selector : Function in functions) { source = source.mapMany(selector); } return source; } /** * @inheritDoc */ public function combineLatest(right:IObservable, selector:Function):IObservable { var left : IObservable = this; return new ClosureObservable(function(observer : IObserver) : ICancelable { var leftSubscription : MutableCancelable = new MutableCancelable(); var leftValue : Object = null; var leftComplete : Object = null; var leftHasValue : Object = null; var rightSubscription : MutableCancelable = new MutableCancelable(); var rightValue : Object = null; var rightComplete : Object = null; var rightHasValue : Object = null; var subscriptions : CompositeCancelable = new CompositeCancelable( [leftSubscription, rightSubscription]); var checkValue : Function = function():void { if (leftHasValue && rightHasValue) { try { var value : Object = selector(leftValue, rightValue); observer.onNext(value); } catch(err : Error) { observer.onError(err); } } }; var checkComplete : Function = function():void { if (leftComplete && rightComplete) { observer.onCompleted(); } }; Scheduler.immediate.schedule(function():void { leftSubscription.cancelable = left.subscribe( function(v:Object) : void { leftValue = v; leftHasValue = true; checkValue(); }, function():void { leftComplete = true; checkComplete(); }, observer.onError); rightSubscription.cancelable = right.subscribe( function(v:Object) : void { rightValue = v; rightHasValue = true; checkValue(); }, function():void { rightComplete = true; checkComplete(); }, observer.onError); }); return subscriptions; }); } /** * @inheritDoc */ public function concat(source:IObservable):IObservable { return Observable.concat([this, source]); } /** * @inheritDoc */ public function concatMany(selector : Function) : IObservable { return Observable.concat(this.map(function(v:Object):IObservable { return Observable.defer(function():IObservable { return selector(v) as IObservable; }); })); } /** * @inheritDoc */ public function contains(value : Object, comparer : Function = null) : IObservable { var source : IObservable = this; var defaultComparer : Function = function(a:Object, b:Object) : Boolean { return a == b; } comparer = (comparer == null) ? defaultComparer : normalizeComparer(comparer); return new ClosureObservable(function(observer : IObserver) : ICancelable { return source.subscribe( function(pl:Object) : void { var result : Boolean = false try { result = (comparer(pl, value) == true); } catch(err : Error) { observer.onError(err); return; } if (result) { observer.onNext(true); observer.onCompleted(); } }, function():void { observer.onNext(false); observer.onCompleted(); }, function(e : Error):void { observer.onError(e); } ); }); } /** * @inheritDoc */ public function count():IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var count : uint = 0; var dec : IObserver = new ClosureObserver( function(pl : Object) : void { count++; }, function () : void { observer.onNext(count); observer.onCompleted(); }, observer.onError); return source.subscribeWith(dec); }); } /** * @inheritDoc */ public function delay(delayMs:uint, scheduler:IScheduler=null):IObservable { var source : IObservable = this; scheduler = scheduler || scheduler || Scheduler.synchronous; return new ClosureObservable(function(observer : IObserver):ICancelable { var scheduledActions : CompositeCancelable = new CompositeCancelable([]); var nextScheduledAction : ICancelable = null; var completeScheduledAction : ICancelable = null; var future : MutableCancelable = new MutableCancelable(); var composite : ICancelable = new CompositeCancelable([scheduledActions, future]); future.cancelable = source.subscribe( function(pl : Object) : void { scheduledActions.add(scheduler.schedule(function():void { observer.onNext(pl); }, delayMs)); }, function () : void { scheduledActions.add(scheduler.schedule(function():void { observer.onCompleted(); }, delayMs)); }, function (error : Error) : void { scheduledActions.cancel(); observer.onError(error); } ); return composite; }); } /** * @inheritDoc */ public function delayUntil(dt:Date, scheduler:IScheduler=null):IObservable { var source : IObservable = this; var dtValue : Number = dt.time; return new ClosureObservable(function(observer : IObserver):ICancelable { scheduler = scheduler || scheduler || Scheduler.synchronous; var isPastDate : Boolean = (scheduler.now.time >= dtValue); var scheduledActions : CompositeCancelable = new CompositeCancelable([]); var future : MutableCancelable = new MutableCancelable(); scheduledActions.add(future); future.cancelable = source.materialize().subscribe( function(pl : Notification) : void { var now : Number = 0; if (!isPastDate) { now = scheduler.now.time; if (now >= dtValue) { isPastDate = true; } } if (isPastDate) { scheduledActions.add( scheduler.schedule(function():void { pl.acceptWith(observer); }) ); } else { var delayMs : Number = dtValue - now; scheduledActions.push( scheduler.schedule(function():void { pl.acceptWith(observer); }, delayMs) ); } } ); return scheduledActions; }); } /** * @inheritDoc */ public function dematerialize():IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { return source.subscribe( function(pl : Notification) : void { pl.acceptWith(observer); } ); }); } /** * @inheritDoc */ public function peek(nextAction:Function, completeAction:Function = null, errorAction:Function = null):IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var dec : IObserver = new ClosureObserver( function(pl : Object) : void { try { if (nextAction != null) nextAction(pl); } catch(err : Error) { observer.onError(err); return; } observer.onNext(pl); }, function () : void { if (completeAction != null) { completeAction(); } observer.onCompleted(); }, function (error : Error) : void { if (errorAction != null) { errorAction(error); } observer.onError(error); }); return source.subscribeWith(dec); }); } /** * @inheritDoc */ public function peekWith(observer : IObserver):IObservable { return peek(observer.onNext, observer.onCompleted, observer.onError); } /** * @inheritDoc */ public function expand(selector : Function) : IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var sources : Subject = new Subject(); var subscription : MutableCancelable = new MutableCancelable(); var activeCount : uint = 1; var sourceWithPeek : IObservable = source.peek(null, function():void { activeCount--; if (activeCount == 0) { sources.onCompleted(); } }); subscription.cancelable = Observable.merge(sources.startWith(Observable.value(sourceWithPeek))) .subscribe(function(v:Object):void { observer.onNext(v); var inner : IObservable; try { inner = selector(v); } catch(err : Error) { sources.onError(err); return; } activeCount++; sources.onNext(inner.peek(null, function():void { activeCount--; if (activeCount == 0) { sources.onCompleted(); } })); }, observer.onCompleted, observer.onError); return subscription; }); } /** * @inheritDoc */ public function finallyAction(action:Function):IObservable { if (action == null) throw new ArgumentError(""finallyAction""); var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var subscription : ICancelable = source.subscribeWith(observer); return new ClosureCancelable(function():void { try { subscription.cancel() } finally { action(); } }); }); } /** * @inheritDoc */ public function first():IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var dec : IObserver = new ClosureObserver( function(pl : Object) : void { observer.onNext(pl); observer.onCompleted(); }, function () : void { observer.onError(new Error(""The sequence contained no values"")); }, observer.onError); return source.subscribeWith(dec); }); } /** * @inheritDoc */ public function firstOrDefault():IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var dec : IObserver = new ClosureObserver( function(pl : Object) : void { observer.onNext(pl); observer.onCompleted(); }, function () : void { observer.onNext(null); observer.onCompleted(); }, observer.onError); return source.subscribeWith(dec); }); } /** * @inheritDoc */ public function forkJoin(right : IObservable, selector : Function):IObservable { return this.combineLatest(right, selector).takeLast(1); } /** * @inheritDoc */ public function join(right : IObservable, leftWindowSelector : Function, rightWindowSelector : Function, joinSelector : Function) : IObservable { var source : IObservable = this; return Observable.createWithCancelable(function(observer:IObserver) : ICancelable { return source.groupJoin(right, leftWindowSelector, rightWindowSelector, function(leftValue:Object, joinedRightValues:IObservable) : Object { // TODO: Should we bother track subscriptions here? groupJoin should avoid any memleaks return joinedRightValues.subscribe(function(rightValue:Object) : void { var resultValue : Object; try { resultValue = joinSelector(leftValue, rightValue); } catch(error : Error) { observer.onError(error); return; } observer.onNext(resultValue); }); }) .ignoreValues() .subscribeWith(observer); }); } /** * @inheritDoc */ public function groupJoin(right : IObservable, leftWindowSelector : Function, rightWindowSelector : Function, joinSelector : Function) : IObservable { var source : IObservable = this; return Observable.createWithCancelable(function(observer:IObserver) : ICancelable { var leftSubscription : MutableCancelable = new MutableCancelable(); var rightSubscription : MutableCancelable = new MutableCancelable(); var windowSubscriptions : CompositeCancelable = new CompositeCancelable(); var activeLeftSubjects : Array = new Array(); // Need to track key/values seperately because Dictionary does not // guarantee enumeration order var activeRightKeys : Array = new Array(); var activeRightValues : Array = new Array(); var rightID : int = int.MIN_VALUE; var subscription : CompositeCancelable = new CompositeCancelable([ leftSubscription, rightSubscription, windowSubscriptions]); var leftComplete : Boolean = false; var rightComplete : Boolean = false; var onError : Function = function(error : Error) : void { for each(var leftWindow : Subject in activeLeftSubjects) { leftWindow.onError(error) } observer.onError(error); }; leftSubscription.cancelable = source .subscribe(function(leftValue : Object) : void { var leftWindow : IObservable; var rightValuesSubject : Subject = new Subject(); var returnValue : Object; try { leftWindow = IObservable(leftWindowSelector(leftValue)); returnValue = joinSelector(leftValue, rightValuesSubject.asObservable()); } catch(error : Error) { onError(error); return; } observer.onNext(returnValue); for each(var activeRightValue : Object in activeRightValues) { rightValuesSubject.onNext(activeRightValue); } var leftWindowSubscription : MutableCancelable = new MutableCancelable(); windowSubscriptions.add(leftWindowSubscription); activeLeftSubjects.push(rightValuesSubject); leftWindowSubscription.cancelable = leftWindow .take(1) .finallyAction(function():void { activeLeftSubjects.splice(activeLeftSubjects.indexOf(rightValuesSubject), 1); windowSubscriptions.remove(leftWindowSubscription); }) .subscribe(null, function():void { rightValuesSubject.onCompleted(); if (leftComplete && activeLeftSubjects.length == 1) { observer.onCompleted(); } }, onError); }, function():void { leftComplete = true; if (rightComplete || activeLeftSubjects.length == 0) { observer.onCompleted(); } }, onError); rightSubscription.cancelable = right.subscribe( function(rightValue : Object) : void { var rightWindow : IObservable; var activeRightValueID : int = rightID++; for each(var subject : Subject in activeLeftSubjects) { subject.onNext(rightValue); } try { rightWindow = IObservable(rightWindowSelector(rightWindow)); } catch(error : Error) { onError(error); return; } activeRightKeys.push(activeRightValueID);; activeRightValues.push(rightValue); var rightWindowSubscription : MutableCancelable = new MutableCancelable(); windowSubscriptions.add(rightWindowSubscription); rightWindowSubscription.cancelable = rightWindow .take(1) .finallyAction(function():void { var index : int = activeRightKeys.indexOf(activeRightValueID); activeRightKeys.splice(index, 1); activeRightValues.splice(index, 1); windowSubscriptions.remove(rightWindowSubscription); }) .subscribe(null, function():void { if (rightComplete && activeRightValues.length == 1) { for each(var activeSubject : Subject in activeLeftSubjects) { activeSubject.onCompleted(); } observer.onCompleted(); } }, onError); }, function() : void { rightComplete = true; if ((leftComplete && activeLeftSubjects.length == 0) || activeRightValues.length == 0) { for each(var activeSubject : Subject in activeLeftSubjects) { activeSubject.onCompleted(); } observer.onCompleted(); } }, onError); return subscription; }); } /** * @inheritDoc */ public function groupBy(keySelector : Function, elementSelector : Function = null, keyComparer : Function = null) : IObservable { var never : IObservable = Observable.never(); return groupByUntil(keySelector, function(groupedObservable : IGroupedObservable) : IObservable { return never; }, elementSelector, keyComparer); } /** * @inheritDoc */ public function groupByUntil(keySelector : Function, durationSelector : Function, elementSelector : Function = null, keyComparer : Function = null) : IObservable { var source : IObservable = this; var defaultComparer : Function = function(a:Object, b:Object) : Boolean { return a == b; } keyComparer = (keyComparer == null) ? defaultComparer : normalizeComparer(keyComparer); elementSelector = (elementSelector == null) ? function(x:Object) : Object { return x; } : elementSelector; return Observable.createWithCancelable(function(observer : IObserver) : ICancelable { var activeGroupKeys : Array = new Array(); var activeGroupSubjects : Array = new Array(); var onError : Function = function(error : Error) : void { for each(var activeGroupSubject : Subject in activeGroupSubjects) { activeGroupSubject.onError(error); } observer.onError(error); }; var findKey : Function = function(key : Object) : int { for (var i:int=0; i 0) { Scheduler.immediate.schedule(function():void { subscription.cancelable = source.subscribeWith(recursiveObserver); }); } else { observer.onCompleted(); } }, observer.onError); Scheduler.immediate.schedule(function():void { subscription.cancelable = source.subscribeWith(recursiveObserver); }); return subscription; }); } /** * @inheritDoc */ public function retry(retryCount:uint = 0):IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var isInfinite : Boolean = (retryCount == 0); var iterationsRemaining : int = retryCount - 1; var subscription : MutableCancelable = new MutableCancelable(); var recursiveObserver : IObserver = null; recursiveObserver = new ClosureObserver( function(pl:Object) : void { observer.onNext(pl); }, observer.onCompleted, function(err : Error):void { if (isInfinite || iterationsRemaining-- > 0) { Scheduler.immediate.schedule(function():void { subscription.cancelable = source.subscribeWith(recursiveObserver); }); } else { observer.onError(err); } }); Scheduler.immediate.schedule(function():void { subscription.cancelable = source.subscribeWith(recursiveObserver); }); return subscription; }); } /** * @inheritDoc */ public function sample(intervalMs : uint, scheduler : IScheduler = null) : IObservable { scheduler = scheduler || Scheduler.synchronous; var source : IObservable = this; return new ClosureObservable(function(observer : IObserver) : ICancelable { var subscription : CompositeCancelable = new CompositeCancelable([]); var isComplete : Boolean = false; var valueChanged : Boolean = false; var value : Object = null; subscription.add(Observable.interval(intervalMs, scheduler).subscribe( function(i:int):void { if (valueChanged) { observer.onNext(value); valueChanged = false; } if (isComplete) { observer.onCompleted(); } })); subscription.add(source.subscribe( function(v:Object):void { valueChanged = true; value = v; }, function():void { isComplete = true; }, observer.onError)); return subscription; }); } /** * @inheritDoc */ public function scan(accumulator : Function, initialValue : Object = null, useInitialValue : Boolean = false) : IObservable { var source : IObservable = this; return Observable.defer(function():IObservable { var skipFirst : Boolean = true; var accumulatedValue : Object = null; if (useInitialValue) { skipFirst = false; accumulatedValue = initialValue; } return source.map(function(value:Object):Object { if (skipFirst) { skipFirst = false; accumulatedValue = value; } else { accumulatedValue = accumulator(accumulatedValue, value); } return accumulatedValue; }); }); return new ClosureObservable(function(obs:IObserver):ICancelable { var aggregate : Object = null; return }); } /** * @inheritDoc */ public function map(selector:Function):IObservable { return mapInternal(selector); } /** * @inheritDoc */ [Deprecated(replacement=""map"")] public function select(selector:Function):IObservable { return map(selector); } private function mapInternal(selector:Function):IObservable { var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var subscription : MutableCancelable = new MutableCancelable(); subscription.cancelable = source.subscribe( function (value : Object) : void { try { value = selector(value); } catch(err : Error) { observer.onError(err); return; } observer.onNext(value); }, observer.onCompleted, observer.onError ); return subscription; }); } [Deprecated(replacement=""mapMany"")] /** * @inheritDoc */ public function selectMany(selector:Function):IObservable { return mapMany(selector); } /** * @inheritDoc */ public function mapMany(selector:Function):IObservable { var source : IObservable = this; return Observable.merge(this.map(selector)); } /** * @inheritDoc */ public function sequenceEqual(other : IObservable, valueComparer : Function = null) : IObservable { var defaultComparer : Function = function(a:Object, b:Object) : Boolean { return a == b; } valueComparer = (valueComparer == null) ? defaultComparer : normalizeComparer(valueComparer); var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var connectableSource : IConnectableObservable = source.publish(); var connectableOther : IConnectableObservable = other.publish(); var zipComplete : Boolean = false; connectableSource .zip(connectableOther, function(l:Object,r:Object) : Boolean { return valueComparer(l,r); }) .all(function(v:Boolean):Boolean { return v; }) .subscribe(function(valid : Boolean) : void { if (!valid) { observer.onNext(false); observer.onCompleted(); } }, function():void { zipComplete = true; }); Observable.merge([ connectableSource, connectableOther ]) .subscribe(function(v:Object):void { if (zipComplete) { observer.onNext(false); observer.onCompleted(); } }, function():void { observer.onNext(true); observer.onCompleted(); }, observer.onError); return new CompositeCancelable([ connectableSource.connect(), connectableOther.connect() ]); }); } /** * @inheritDoc */ public function single():IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var hasValue : Boolean = false; var value : Object = null; var dec : IObserver = new ClosureObserver( function(pl : Object) : void { if (hasValue) { observer.onError(new Error(""The sequence contained more than one value"")); } else { value = pl; hasValue = true; } }, function () : void { if (hasValue) { observer.onNext(value); observer.onCompleted(); } else { observer.onError(new Error(""The sequence contained no values"")); } }, observer.onError); return source.subscribeWith(dec); }); } /** * @inheritDoc */ public function singleOrDefault():IObservable { var source : IObservable = this; return new ClosureObservable(function(observer : IObserver):ICancelable { var hasValue : Boolean = false; var value : Object = null; return source.subscribe( function(pl : Object) : void { if (hasValue) { observer.onError(new Error(""The sequence contained more than one value"")); } else { value = pl; hasValue = true; } }, function () : void { observer.onNext(value); observer.onCompleted(); }, observer.onError); }); } /** * @inheritDoc */ public function skip(count:uint):IObservable { var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var skippedSoFar : uint = 0; var subscription : ICancelable; return source.subscribe( function (value : Object) : void { if (++skippedSoFar > count) { observer.onNext(value); } }, observer.onCompleted, observer.onError ); }); } /** * @inheritDoc */ public function skipLast(count : uint) : IObservable { if (count == 0) { throw new ArgumentError(""count cannot be 0""); } var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var buffer : Array = new Array(); var futureSubscription : MutableCancelable = new MutableCancelable(); futureSubscription.cancelable = source.subscribe( function(v:Object):void { buffer.push(v); }, function():void { while(buffer.length > count) { observer.onNext(buffer.shift()); } observer.onCompleted(); }, observer.onError); return futureSubscription; }); } /** * @inheritDoc */ public function skipUntil(other:IObservable):IObservable { var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var subscription : ICancelable; var pastSkip : Boolean = false; var primarySubscription : ICancelable; var otherSubscription : ICancelable; primarySubscription = source.subscribe( function (value : Object) : void { if (pastSkip) { observer.onNext(value); } }, observer.onCompleted, observer.onError ); otherSubscription = other.subscribe( function (value : Object) : void { pastSkip = true; if (otherSubscription != null) { otherSubscription.cancel(); } }, function () : void { }, observer.onError ); if (pastSkip) { otherSubscription.cancel(); otherSubscription = null; } return new ClosureCancelable(function():void { if (primarySubscription != null) { primarySubscription.cancel(); } if (otherSubscription != null) { otherSubscription.cancel(); } }); }); } /** * @inheritDoc */ public function skipWhile(predicate:Function):IObservable { var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var skipping : Boolean = true; var decoratorObserver : IObserver = new ClosureObserver( function (value : Object) : void { if (skipping) { try { skipping &= predicate(value); } catch(err : Error) { observer.onError(err); } } if (!skipping) { observer.onNext(value); } }, observer.onCompleted, observer.onError ); return source.subscribeWith(decoratorObserver); }); } /** * @inheritDoc */ public function startWith(value : *) : IObservable { return toObservable(value) .concat(this); } /** * @inheritDoc */ public function switchMany(selector : Function) : IObservable { var source : IObservable = this.map(selector); return new ClosureObservable(function(observer : IObserver) : ICancelable { var parentCancelable : MutableCancelable = new MutableCancelable(); var parentCompleted : Boolean = false; var childCancelable : MutableCancelable = new MutableCancelable(); var childCompleted : Boolean = false; parentCancelable.cancelable = source.subscribe( function(child : IObservable) : void { childCancelable.cancelable = child.subscribe( observer.onNext, function() : void { childCompleted = true; if (parentCompleted) { observer.onCompleted(); } }, observer.onError); }, function() : void { parentCompleted = true; if (childCompleted) { observer.onCompleted(); } }, observer.onError); return new CompositeCancelable([childCancelable, parentCancelable]); }); } /** * @inheritDoc */ public function sum():IObservable { return reduce(function(x:Number, y:Number):Number { return x+y; }, 0).catchError(Observable.value(0)); } /** * @inheritDoc */ public function take(count:uint):IObservable { var source : IObservable = this; if (count == 0) { return Observable.empty(); } return new ClosureObservable(function (observer : IObserver) : ICancelable { var countSoFar : uint = 0; var subscription : MutableCancelable = new MutableCancelable(); var decoratorObserver : IObserver = new ClosureObserver( function (value : Object) : void { observer.onNext(value); if (++countSoFar == count) { observer.onCompleted(); } }, observer.onCompleted, observer.onError ); subscription.cancelable = source.subscribeWith(decoratorObserver); return subscription; }); } /** * @inheritDoc */ public function takeLast(count : uint) : IObservable { if (count == 0) { throw new ArgumentError(""count cannot be 0""); } var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var buffer : Array = new Array(); var futureSubscription : MutableCancelable = new MutableCancelable(); futureSubscription.cancelable = source.subscribe( function(v:Object):void { buffer.push(v); if (buffer.length > count) { buffer.shift(); } }, function():void { while(buffer.length > 0) { observer.onNext(buffer.shift()); } observer.onCompleted(); }, observer.onError); return futureSubscription; }); } /** * @inheritDoc */ public function takeUntil(other:IObservable):IObservable { var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var subscription : ICancelable; var primarySubscription : MutableCancelable = new MutableCancelable(); var otherSubscription : MutableCancelable = new MutableCancelable(); var composite : ICancelable = new CompositeCancelable([ primarySubscription, otherSubscription ]); otherSubscription.cancelable = other.subscribe( function (value : Object) : void { observer.onCompleted(); }, observer.onCompleted, observer.onError ); primarySubscription.cancelable = source.subscribeWith(observer); return composite; }); } /** * @inheritDoc */ public function takeWhile(predicate:Function):IObservable { var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { return source.subscribe( function (value : Object) : void { var result : Boolean = false; try { result = predicate(value); } catch(err : Error) { observer.onError(err); return; } if (result) { observer.onNext(value); } else { observer.onCompleted(); } }, observer.onCompleted, observer.onError ); }); } /** * @inheritDoc */ public function then(thenFunction : Function) : Plan { return new Plan([this], thenFunction); } /** * @inheritDoc */ public function throttle(dueTimeMs:uint, scheduler:IScheduler=null):IObservable { var source : IObservable = this; scheduler = scheduler || Scheduler.asynchronous; return new ClosureObservable(function (observer : IObserver) : ICancelable { var hasValue : Boolean = false; var lastValue : Object = null; var sourceSubscription : MutableCancelable = new MutableCancelable(); var currentTimeout : MutableCancelable = new MutableCancelable(); var throttleTimeout : Function = function():void { hasValue = false; observer.onNext(lastValue); }; sourceSubscription.cancelable = source.subscribe( function (value : Object) : void { lastValue = value; hasValue = true; currentTimeout.cancelable = scheduler.schedule(throttleTimeout, dueTimeMs); }, function() : void { if (hasValue) { observer.onNext(lastValue); observer.onCompleted(); } }, observer.onError); return new CompositeCancelable( [sourceSubscription, currentTimeout]); }); } /** * @inheritDoc */ public function timeInterval(scheduler:IScheduler=null):IObservable { var source : IObservable = this; scheduler = scheduler || Scheduler.synchronous; return new ClosureObservable(function (observer : IObserver) : ICancelable { var lastTimeMs : Number = -1; return source.subscribe( function (value : Object) : void { var now : Number = (scheduler.now).time; var interval : Number = (lastTimeMs == -1) ? 0 : now - lastTimeMs; lastTimeMs = now; var intervalValue : TimeInterval = new TimeInterval(value, interval); scheduler.schedule( function():void { observer.onNext(intervalValue); }); }, observer.onCompleted, observer.onError ); }); } /** * @inheritDoc */ public function timeout(timeoutMs:uint, other:IObservable=null, scheduler:IScheduler=null):IObservable { var source : IObservable = this; other = other || Observable.error(new TimeoutError(""Sequence timed out"")); scheduler = scheduler || Scheduler.synchronous; return new ClosureObservable(function (observer : IObserver) : ICancelable { var timeout : MutableCancelable = new MutableCancelable(); var subscription : MutableCancelable = new MutableCancelable(); var composite : ICancelable = new CompositeCancelable([timeout, subscription]); timeout.cancelable = scheduler.schedule(function():void { subscription.cancel(); subscription = other.subscribeWith(observer); }, timeoutMs); subscription.cancelable = source.subscribe( function (value : Object) : void { timeout.cancel(); observer.onNext(value); }, function () : void { timeout.cancel(); observer.onCompleted(); }, observer.onError ); return composite; }); } /** * @inheritDoc */ public function timestamp(scheduler:IScheduler=null):IObservable { scheduler = scheduler || Scheduler.synchronous; return mapInternal(function(value : Object) : TimeStamped { return new TimeStamped(value, scheduler.now.time); }); } /** * @inheritDoc */ public function toArray():IObservable { var source : IObservable = this; return Observable.createWithCancelable(function(observer : IObserver):ICancelable { var buffer : Array = new Array(); return source.finallyAction(function():void { buffer = []; }) .subscribe( function(v:Object):void { buffer.push(v); }, function():void { observer.onNext(buffer); observer.onCompleted(); }, observer.onError); }); } /** * @inheritDoc */ public function filter(predicate:Function):IObservable { var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var decoratorObserver : IObserver = new ClosureObserver( function (value : Object) : void { var result : Boolean = false; try { result = predicate(value); } catch(err : Error) { observer.onError(err); } if (result) { observer.onNext(value); } }, observer.onCompleted, observer.onError ); return source.subscribeWith(decoratorObserver); }); } /** * @inheritDoc */ public function window(windowClosingSelector : Function) : IObservable { var source : IObservable = this; return Observable.createWithCancelable(function(observer : IObserver):ICancelable { var windowOpenings : Subject = new Subject(); var multiWindowSubscription : MutableCancelable = new MutableCancelable(); var activeWindowSubscription : MutableCancelable = new MutableCancelable(); multiWindowSubscription.cancelable = multiWindow(windowOpenings.startWith([null]), function(u:Unit):IObservable { var windowValues : AsyncSubject = new AsyncSubject(); var closing : IObservable = IObservable(windowClosingSelector()); activeWindowSubscription.cancelable = closing .take(1) .subscribe(null, function():void { windowValues.onCompleted(); windowOpenings.onNext(null); }, windowValues.onError); return windowValues; }) .subscribeWith(observer); return new CompositeCancelable([multiWindowSubscription, activeWindowSubscription]); }); } /** * @inheritDoc */ public function multiWindow(windowOpenings : IObservable, windowClosingSelector : Function) : IObservable { var source : IObservable = this; return windowOpenings.groupJoin(this, windowClosingSelector, function(x:Object) : IObservable { return Observable.empty(); }, function(w:Object, values : IObservable) : IObservable { return values; }); } /** * @inheritDoc */ public function zip(rightSource:IObservable, selector:Function):IObservable { // TODO: Could this be replaced with a single-plan join? var source : IObservable = this; return new ClosureObservable(function (observer : IObserver) : ICancelable { var canceled : Boolean = false; var leftComplete : Boolean = false; var leftValues : Array = new Array(); var rightComplete : Boolean = false; var rightValues : Array = new Array(); var leftSubscription : MutableCancelable = new MutableCancelable(), rightSubscription : MutableCancelable = new MutableCancelable(); var leftObserver : IObserver = new ClosureObserver( function (value : Object) : void { if (rightValues.length > 0) { value = selector(value, rightValues.shift()); observer.onNext(value); } else { if (rightComplete) { observer.onCompleted(); } else { leftValues.push(value); } } }, function():void { leftComplete = true; if (rightComplete || leftValues.length == 0) { observer.onCompleted(); } }, observer.onError ); var rightObserver : IObserver = new ClosureObserver( function (value : Object) : void { if (leftValues.length > 0) { value = selector(leftValues.shift(), value); observer.onNext(value); } else { if (leftComplete) { observer.onCompleted(); } else { rightValues.push(value); } } }, function():void { rightComplete = true; if (leftComplete || rightValues.length == 0) { observer.onCompleted(); } }, observer.onError ); leftSubscription.cancelable = source.subscribeWith(leftObserver); rightSubscription.cancelable = rightSource.subscribeWith(rightObserver); return new CompositeCancelable([leftSubscription, rightSubscription]); }); } private static function normalizeComparer(source : Function) : Function { return function(a:Object,b:Object) : Boolean { var result : Object = source(a, b); if (result is Boolean) { return (result == true); } if (result is int || result is Number || result is uint) { return (result == 0); } throw new ArgumentError(""comparer function must return Boolean or int""); }; } } }",16290,True,3810.865478457816,median "*&---------------------------------------------------------------------* *& Include Z_MONSTER_ADL_IO1 *&---------------------------------------------------------------------* * Local Class Implementations *--------------------------------------------------------------------* CLASS lcl_application IMPLEMENTATION. *--------------------------------------------------------------------* * Listing 10.01: Generic Template for Calling ALV Reports *--------------------------------------------------------------------* * Jeffrey is a PURPLE Monster *--------------------------------------------------------------------* METHOD main.""Of Monster Atrocity Due List * Local Variables DATA: ld_repid TYPE sy-repid. ""It is bad news to pass system variables as parameters ld_repid = sy-repid. mo_model = NEW #( ). ""Hard Coded here - would use configuration or similar in ""real life DATA(context_data_list) = VALUE wdr_simple_name_value_list( ( name = 'UI_TECHNOLOGY' value = 'CL_SALV_TABLE' ) ). zcl_ocp_factory=>return_object_given( EXPORTING it_context_data = context_data_list CHANGING co_object = mo_view ). mo_controller = NEW #( io_model = mo_model io_view = mo_view ). mo_model->data_retrieval( ). mo_model->prepare_data_for_ouput( ). IF sy-batch IS INITIAL. *--------------------------------------------------------------------* * Listing 10.35: - Calling a SALV report whilst creating a container * automatically *--------------------------------------------------------------------* * Program flow is as follows:- * ZCL_BC_VIEW_SALV_TABLE->CREATE_CONTAINER_PREPARE_DATA * Function ZSALV_CSQT_CREATE_CONTAINER * ZSALV_CSQT_CREATE_CONTAINER->FILL_CONTAINER_CONTENT * ZCL_BC_VIEW_SALV_TABLE->PREPARE_DISPLAY_DATA * --> INITIALISE (Generic) * --> Application Specific Changes (Generic) * --> Display (Generic) mo_view->create_container_prep_display( EXPORTING id_report_name = ld_repid if_start_in_edit_mode = go_selections->p_edit id_edit_control_field = mo_model->md_edit_control_field it_editable_fields = mo_model->mt_editable_fields it_technicals = mo_model->mt_technicals it_hidden = mo_model->mt_hidden it_hotspots = mo_model->mt_hotspots it_checkboxes = mo_model->mt_checkboxes it_subtotal_fields = mo_model->mt_subtotal_fields it_field_texts = mo_model->mt_field_texts it_sort_criteria = mo_model->mt_sort_criteria it_user_commands = mo_model->mt_user_commands CHANGING ct_data_table = mo_model->mt_output_data ). ELSE. * If this is running in the background there is no way * in the world we want/need a container, as there is no * chance for the user to press any user command buttons or * edit the data, as there is no user, and no screen for the * container to live on for that matter mo_view->prepare_display_data( EXPORTING id_report_name = ld_repid it_technicals = mo_model->mt_technicals it_hidden = mo_model->mt_hidden it_hotspots = mo_model->mt_hotspots it_checkboxes = mo_model->mt_checkboxes it_subtotal_fields = mo_model->mt_subtotal_fields it_field_texts = mo_model->mt_field_texts it_sort_criteria = mo_model->mt_sort_criteria it_user_commands = mo_model->mt_user_commands CHANGING ct_data_table = mo_model->mt_output_data ). ENDIF.""Are we running in the background? IF go_selections->p_email IS NOT INITIAL. mo_controller->send_email( ). ENDIF. ENDMETHOD. ""main ENDCLASS. ""lcl_application IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_selections IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_selections IMPLEMENTATION. METHOD constructor. s_date = is_date. s_cstl = is_cstl. p_vari = ip_vari. p_edit = ip_edit. p_send = ip_send. p_email = ip_email. ENDMETHOD. ""constructor ENDCLASS.""Local Selections *----------------------------------------------------------------------* * CLASS lcl_persistency_layer IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_persistency_layer IMPLEMENTATION. METHOD get_data. *--------------------------------------------------------------------* * EXPORTING et_output_data TYPE g_tt_output_data. *--------------------------------------------------------------------* SELECT * ##too_many_itab_fields ""in the world FROM z4c_monster_atrocity_due_list INTO CORRESPONDING FIELDS OF TABLE @rt_output_data. ENDMETHOD. ""get_data ENDCLASS. ""lcl_persistency_layer IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_model IMPLEMENTATION *----------------------------------------------------------------------* * When creating the model for real we do not fill the import parameter * and thus the data is read for real * When creating the model within a unit test, we pass in a reference to * the fake database access class *----------------------------------------------------------------------* CLASS lcl_model IMPLEMENTATION. METHOD constructor. super->constructor( ). IF io_access_class IS SUPPLIED. mo_persistency_layer = io_access_class. ELSE. mo_persistency_layer = NEW #( ). ENDIF. fill_user_commands( ). fill_technical_fields( ). fill_hidden_fields( ). fill_hotspot_fields( ). fill_subtotal_fields( ). fill_field_texts( ). fill_editable_fields( ). fill_checkbox_fields( ). set_edit_control_field( ). ENDMETHOD. ""constructor METHOD data_retrieval. mt_output_data[] = mo_persistency_layer->get_data( ). ENDMETHOD. ""data_retrieval *--------------------------------------------------------------------* * METHOD prepare_data_for_output *--------------------------------------------------------------------* * Get text names of objects, mapping, etc etc *--------------------------------------------------------------------* METHOD prepare_data_for_ouput ##NEEDED. ENDMETHOD. ""prepare_data_for_ouput METHOD fill_user_commands. *--------------------------------------------------------------------* * Listing 10.27 - Method in the Model Class to Define User Commands *--------------------------------------------------------------------* CLEAR mt_user_commands. INSERT VALUE #( function = 'ZALLOCATE' icon = icon_deceased_patient butn_type = 0 ""Normal Button text = 'Allocate Monster'(001) ) INTO TABLE mt_user_commands. ENDMETHOD. ""fill_user_commands METHOD fill_editable_fields. APPEND 'TASK_DESCRIPTION' TO mt_editable_fields.""Can be edited if job not yet in progress ENDMETHOD. ""fill_editable_fields METHOD fill_hidden_fields ##NEEDED. ""No Hidden Fields ENDMETHOD. ""fill_hidden_fields METHOD fill_technical_fields. APPEND 'MANDT' TO mt_technicals. ENDMETHOD. ""fill_technical_fields METHOD fill_hotspot_fields ##NEEDED. ""No Hotspots ENDMETHOD. ""fill_hotspot_fields METHOD fill_subtotal_fields ##NEEDED. ""No Subtotals ENDMETHOD. ""fill_subtotal_fields METHOD fill_field_texts ##NEEDED. * No Need to Rename Anything ENDMETHOD. ""fill_field_texts METHOD fill_checkbox_fields. APPEND 'CHECK' TO mt_checkboxes. ENDMETHOD. ""fill_checkbox_fields METHOD user_command. CASE id_user_command. WHEN '&IC1'. READ TABLE mt_output_data ASSIGNING FIELD-SYMBOL() INDEX id_row. IF sy-subrc NE 0. RETURN. ENDIF. CASE id_column. WHEN 'CHECK'. IF -check = abap_false. -check = abap_true. ELSE. -check = abap_false. ENDIF. RAISE EVENT data_changed. WHEN OTHERS. RETURN. ENDCASE.""What column was selected for drill down? WHEN 'ZALLOCATE'. LOOP AT mt_output_data ASSIGNING WHERE check = abap_true. allocate_monster( ). ENDLOOP. WHEN OTHERS. RETURN. ENDCASE.""What user command was chosen? ENDMETHOD.""User Command / Model METHOD allocate_monster. *--------------------------------------------------------------------* * IMPORTING is_output_data TYPE g_typ_alv_output_data *--------------------------------------------------------------------* * Local Variables DATA: lt_options TYPE STANDARD TABLE OF spopli, ls_options LIKE LINE OF lt_options, ls_titles TYPE spop5, ld_answer TYPE char01, ld_default_choice TYPE sy-lilli, ld_actual_choice TYPE sy-tabix. ""This user command should be in the CONTROLLER which would get the input dara from the model and then ""use the view to ask the user the question ls_options-varoption = 'Bolts-Through-Neck'(002). APPEND ls_options TO lt_options. ls_options-varoption = 'Creeping Terror'(003). APPEND ls_options TO lt_options. ls_options-varoption = 'Creature from the Black Lagoon'(004). APPEND ls_options TO lt_options. ls_options-varoption = 'Killer Klown'(005). APPEND ls_options TO lt_options. ls_options-varoption = 'Thing with Two Heads'(006). APPEND ls_options TO lt_options. ld_default_choice = 1. ls_titles-titel = 'Choose Monster'(007). ls_titles-textline1 = 'Which Monster shall do This Deed, This Deed so Vile?'(008). CALL FUNCTION 'POPUP_TO_DECIDE_LIST' EXPORTING cursorline = ld_default_choice textline1 = ls_titles-textline1 titel = ls_titles-titel IMPORTING answer = ld_answer TABLES t_spopli = lt_options[] EXCEPTIONS not_enough_answers = 1 too_much_answers = 2 too_much_marks = 3 OTHERS = 4. IF sy-subrc <> 0. RETURN. ENDIF. CASE ld_answer. WHEN '1' OR '2' OR '3' OR '4' OR '5'. ld_actual_choice = ld_answer. WHEN OTHERS. RETURN. ENDCASE. DATA: ls_monitor TYPE z4t_deliveries. ls_monitor = CORRESPONDING #( is_output_data ). READ TABLE lt_options INTO ls_options INDEX ld_actual_choice. ASSERT sy-subrc EQ 0. ls_monitor-monster_name = ls_options-varoption. ls_monitor-current_status = 'A'.""Atrocity Ready to be Committed DATA(lo_uuid_generator) = cl_uuid_factory=>create_system_uuid( ). TRY. ls_monitor-db_key = lo_uuid_generator->create_uuid_x16( ). CATCH cx_uuid_error INTO DATA(uuid_error). DATA(ld_message) = uuid_error->get_text( ). MESSAGE ld_message TYPE 'I'. RETURN. ENDTRY. ls_monitor-delivery_number = sy-datum+2(2) && sy-datum+4(2) && sy-datum+6(2) && sy-uzeit(2) && sy-uzeit+2(2). *-------------------------------------------------------------------------------------------------------------* * TO-DO * Need to create the new delivery using the delivery business object peristency layer - not a direct update *-------------------------------------------------------------------------------------------------------------* MODIFY z4t_deliveries FROM ls_monitor. IF sy-subrc <> 0. ROLLBACK WORK. ""#EC CI_ROLLBACK RETURN. ENDIF. *-------------------------------------------------------------------------------------------------------------* * TO-DO * Need to call persitency layer of order business object and set the order status to ""C"" (using a constant as * opposed to a hard coded value) *-------------------------------------------------------------------------------------------------------------* UPDATE z4t_order_items SET foul_deed_status = 'C' WHERE order_number = is_output_data-ordernumber AND order_item = is_output_data-orderitem. IF sy-subrc <> 0. ROLLBACK WORK. ""#EC CI_ROLLBACK RETURN. ELSE. COMMIT WORK. ""Horrible, Horrible, Deed has Been Scheduled MESSAGE i014(z4monsters). ENDIF. *-----------------------------------------------------------------------------------------* * Listing 14.02: - Checking ABAP Messaging Channel Application/Channel Combination Exists *-----------------------------------------------------------------------------------------* ""This next bit should be in it's own method of a dedicated local class ""Now, let us tell the push channel that the monster has been scheduled ""to do the atrocity ""Determine message type of the AMC channel TRY. DATA(amc_dt_manager) = cl_amc_dt_manager=>create( i_application_id = 'ZAMC_4_MONSTERS' i_channel_id = '/monsters' ). DATA(amc_message_type) = amc_dt_manager->get_message_type( ). CATCH cx_amc_dt_error INTO DATA(amc_dt_error). MESSAGE amc_dt_error TYPE 'E'. ENDTRY. IF amc_message_type NE 'PCP'. RETURN. ENDIF. *-----------------------------------------------------------------------* * Listing 14.01: - Defining Where AMC Message Will Be Published *-----------------------------------------------------------------------* * Listing 14.03: - Preparing and Sending ABAP Messaging Channels Message *-----------------------------------------------------------------------* ""Fill Payload TRY. ""Create Bottle to Send ""Set extension ID to be the Castle Number. Only monster ""monitors subscribed to that particular castle will then ""be notified of the new atrocity to be performed. Monitors ""for other castles do not care DATA(message_bottle) = CAST if_amc_message_producer_pcp( cl_amc_channel_manager=>create_message_producer( i_application_id = 'ZAMC_4_MONSTERS' i_channel_id = '/monsters' i_channel_extension_id = CONV #( ls_monitor-castle_number ) ) ). ""Create Message for Bottle DATA(pcp_message) = cl_ac_message_type_pcp=>create( ). pcp_message->set_text( |{ 'A New Atrocity needs to be Committed'(009) }| ). pcp_message->set_field( i_name = |{ 'Delivery Number'(010) }| i_value = CONV #( ls_monitor-delivery_number ) ). ""Put message in bottle, and throw bottle into the sea message_bottle->send( pcp_message ). CATCH cx_ac_message_type_pcp_error INTO DATA(pcp_error). MESSAGE pcp_error TYPE 'E'. CATCH cx_amc_error INTO DATA(amc_error). MESSAGE amc_error TYPE 'E'. ENDTRY. ENDMETHOD. ""allocate_monster ENDCLASS. ""lcl_model IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_view IMPLEMENTATION *----------------------------------------------------------------------* * During the INITIALISATION method this method is called so that * every row in the output table will be * changed such that nominated columns have been made editable. * Now we want to extend this logic to restrict the ability to change * the task description. If a monster has always been assigned to the task, * the nature of the task can no longer be changed. *----------------------------------------------------------------------* CLASS lcl_view IMPLEMENTATION. METHOD make_column_editable. *--------------------------------------------------------------------* * ID_EDIT_CONTROL_FIELD Importing Type LVC_FNAME * IT_EDITABLE_FIELDS Importing Type LVC_T_FNAM * CT_DATA_TABLE Changing Type ANY TABLE *--------------------------------------------------------------------* * Local Variables DATA: ldo_table_line TYPE REF TO data. FIELD-SYMBOLS: TYPE any, TYPE lvc_t_styl, TYPE z4de_monster_order_fd_status. super->make_column_editable( EXPORTING id_edit_control_field = id_edit_control_field it_editable_fields = it_editable_fields CHANGING ct_data_table = ct_data_table ). *----------------------------------------------------------------------------------------------------------* * When the status is ""in progress"" gray out the task description fields. This does not work but it SHOULD. * My working theory is developers at SAP have been instructed to stop this working at all costs. *----------------------------------------------------------------------------------------------------------* * Dynamically create work area for looping through the table that was passed in *----------------------------------------------------------------------------------------------------------* CREATE DATA ldo_table_line LIKE LINE OF ct_data_table. ASSIGN ldo_table_line->* TO . LOOP AT ct_data_table ASSIGNING . ""Determine the Order Status ASSIGN COMPONENT 'FOULDEEDSTATUS' OF STRUCTURE TO . IF sy-subrc NE 0. CONTINUE. ENDIF. ""Based upon this, alter the CELLTAB nested table, to make the ""cell read only if need be IF NE 'C'.""Foul Deed has been Requested CONTINUE. ENDIF. ""Orders in this status cannot have the task description changed ASSIGN COMPONENT 'CELLTAB' OF STRUCTURE TO . IF sy-subrc NE 0. CONTINUE. ENDIF. READ TABLE ASSIGNING FIELD-SYMBOL() WITH KEY fieldname = 'TASKDESCRIPTION'. IF sy-subrc <> 0. INSERT VALUE #( fieldname = 'TASKDESCRIPTION' ) INTO TABLE . READ TABLE ASSIGNING WITH KEY fieldname = 'TASKDESCRIPTION'. ASSERT sy-subrc EQ 0. ENDIF. -style = cl_gui_alv_grid=>mc_style_disabled.""Read Only ENDLOOP.""Data Table ENDMETHOD. ""application_specific_changes METHOD ida_demo ##CALLED.""It is not this is just an example *--------------------------------------------------------------------* * Listing 10.39: - Coding SALV with IDA with Selection Criteria *--------------------------------------------------------------------* TRY. ""Tell the ALV what database table we want DATA(alv_display_object) = cl_salv_gui_table_ida=>create( iv_table_name = 'Z4TMONSTER_HEAD' ). ""Prepare the select-options DATA(range_table_collector) = NEW cl_salv_range_tab_collector( ). range_table_collector->add_ranges_for_name( iv_name = 'MONSTER_NUMBER' it_ranges = go_selections->s_numbr[] ). range_table_collector->add_ranges_for_name( iv_name = 'NAME' it_ranges = go_selections->s_name[] ). range_table_collector->get_collected_ranges( IMPORTING et_named_ranges = DATA(selection_option_table) ). ""Prepare any parameters from the selection screen DATA(parameter_factory) = alv_display_object->condition_factory( ). IF go_selections->p_model IS NOT INITIAL. DATA(parameter_object) = parameter_factory->equals( name = 'MODEL' value = go_selections->p_model ). ELSE. parameter_object = parameter_factory->covers_pattern( name = 'MODEL' pattern = '*' ). ENDIF. ""Tell the ALV about these restrictions alv_display_object->set_select_options( it_ranges = selection_option_table io_condition = parameter_object ). ""Off we go! alv_display_object->fullscreen( )->display( ). CATCH cx_salv_db_connection INTO DATA(connection_error). DATA(error_message) = connection_error->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_db_table_not_supported INTO DATA(not_supported). error_message = not_supported->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_ida_contract_violation INTO DATA(contract_violation). error_message = contract_violation->get_text( ). MESSAGE error_message TYPE 'E'. ENDTRY. *--------------------------------------------------------------------* * Listing 10.40: Coding SALV with IDA without Selection Criteria *--------------------------------------------------------------------* cl_salv_gui_table_ida=>create( 'Z4TMONSTER_HEAD' )->fullscreen( )->display( ). *--------------------------------------------------------------------* * Listing 10.41: Creating IDA SALV for CDS View (Acronym Soup) *--------------------------------------------------------------------* cl_salv_gui_table_ida=>create_for_cds_view( 'Z4CDS_MONSTER_DELIVERIES' )->fullscreen( )->display( ). ENDMETHOD. METHOD ida_demo2 ##CALLED.""It is not this is just an example *-------------------------------------------------------------------------------------* * Listing 10.44: Passing an instance of the Field Calculator into the IDA SALV instance * The Monster who has the super-power of shape-shifting was one castle away from the 8 Foot Tall Monster *-------------------------------------------------------------------------------------* TRY. DATA(lo_calc_field_handler) = NEW lcl_ida_calculated_m_fields( ). ""Tell the ALV what database table we want PLUS calculated fields DATA(alv_display_object) = cl_salv_gui_table_ida=>create( iv_table_name = 'Z4TMONSTER_HEAD' io_calc_field_handler = lo_calc_field_handler ). ""Change a column heading, just for kicks TRY. alv_display_object->field_catalog( )->set_field_header_texts( iv_field_name = 'SANITY_DESCRIPTION' iv_header_text = 'Bonkers-Ness'(011) iv_tooltip_text = 'Tra La La'(012) iv_tooltip_text_long = 'Tra La La La La'(013) ). CATCH cx_salv_ida_unknown_name INTO DATA(unknown_name). DATA(error_message) = unknown_name->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_call_after_1st_display INTO DATA(multiple_calls). error_message = multiple_calls->get_text( ). MESSAGE error_message TYPE 'E'. ENDTRY. ""Prepare the select-options DATA(range_table_collector) = NEW cl_salv_range_tab_collector( ). range_table_collector->add_ranges_for_name( iv_name = 'MONSTER_NUMBER' it_ranges = go_selections->s_numbr[] ). range_table_collector->add_ranges_for_name( iv_name = 'NAME' it_ranges = go_selections->s_name[] ). range_table_collector->get_collected_ranges( IMPORTING et_named_ranges = DATA(selection_option_table) ). ""Prepare any parameters from the selection screen DATA(parameter_factory) = alv_display_object->condition_factory( ). IF go_selections->p_model IS NOT INITIAL. DATA(parameter_object) = parameter_factory->equals( name = 'MODEL' value = go_selections->p_model ). ELSE. parameter_object = parameter_factory->covers_pattern( name = 'MODEL' pattern = '*' ). ENDIF. ""Tell the ALV about the SELECTION-SCREEN restrictions alv_display_object->set_select_options( it_ranges = selection_option_table io_condition = parameter_object ). ""Off we go! alv_display_object->fullscreen( )->display( ). CATCH cx_salv_db_connection INTO DATA(connection_error). error_message = connection_error->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_db_table_not_supported INTO DATA(not_supported). error_message = not_supported->get_text( ). MESSAGE error_message TYPE 'E'. CATCH cx_salv_ida_contract_violation INTO DATA(contract_violation). error_message = contract_violation->get_text( ). MESSAGE error_message TYPE 'E'. ENDTRY. * One Haunted Castle can be found at 14.6 degrees Longtitude ENDMETHOD. ENDCLASS. ""lcl_view IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_controller IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_controller IMPLEMENTATION. METHOD constructor. super->constructor( ). mo_model = io_model. mo_view = io_view. ""Make the controller react to the views events SET HANDLER on_user_command FOR mo_view. ""If the model changes some data, then it needs to ""tell the controller, so it can tell the view ""to refresh the data SET HANDLER on_data_changed FOR mo_model. ENDMETHOD. ""constructor METHOD send_email. * Local Variables DATA: ld_program_name TYPE sy-repid, ld_short_title TYPE zexcel_sheet_title, ld_long_title TYPE char80, ld_tcode TYPE sy-tcode, lo_excel TYPE REF TO zcl_excel, lo_alv_grid TYPE REF TO cl_salv_table. ""Preconditions IF go_selections->p_send NE abap_true. RETURN. ENDIF. ld_short_title = sy-title. ld_long_title = sy-title. ld_program_name = sy-repid. ""bad news to pass this directly ld_tcode = 'ZMADL'. lo_alv_grid ?= mo_view->get_main_alv_object( ). ""Step 1 - convert internal table into an EXCEL object zcl_excel_emailer=>convert_salv_to_excel( EXPORTING id_title = ld_short_title io_salv = lo_alv_grid it_table = mo_model->mt_output_data[] CHANGING co_excel = lo_excel ). ""Step 2 - make any changes to the spreadsheet object that relate to ""this report TRY. adjust_spreadsheet( CHANGING co_excel = lo_excel ). CATCH zcx_excel. RETURN. ENDTRY. ""Step 3 - send the amended EXCEL object as an email zcl_excel_emailer=>send_excel_object( io_excel = lo_excel id_tcode = ld_tcode id_report_title = ld_long_title id_program_name = ld_program_name id_email = go_selections->p_email ). ENDMETHOD. METHOD adjust_spreadsheet. *--------------------------------------------------------------------* * Listing 11.06: Data Declarations *--------------------------------------------------------------------* DATA: column_number TYPE zexcel_cell_column, row_number TYPE zexcel_cell_row. *--------------------------------------------------------------------* * Listing 11.07: Looping Through All the Cells in a Spreadsheet *--------------------------------------------------------------------* DATA(active_worksheet) = co_excel->get_active_worksheet( ). DATA(number_of_rows) = active_worksheet->get_highest_row( ). DATA(number_of_columns) = active_worksheet->get_highest_column( ). DO number_of_columns TIMES. column_number = column_number + 1. DATA(column_as_letter) = zcl_excel_common=>convert_column2alpha( column_number ). row_number = 0. DO number_of_rows TIMES. ""#EC CI_NESTED. row_number = row_number + 1. *--------------------------------------------------------------------* * Listing 11.08: Finding the Style of a Spreadsheet Cell *--------------------------------------------------------------------* active_worksheet->get_cell( EXPORTING ip_column = column_as_letter ip_row = row_number IMPORTING ep_guid = DATA(cell_formatting_guid) ). TRY. DATA(style_information) = active_worksheet->excel->get_style_to_guid( cell_formatting_guid ). CATCH zcx_excel. CLEAR style_information. ENDTRY. *--------------------------------------------------------------------* * Listing 11.09: Setting a Cell to be Formatted Appropriately *--------------------------------------------------------------------* IF style_information-complete_style-number_format-format_code = '#,##0.00'. ""This is a currency amount, use the accounting conventions ""which are to have negative numbers as red in brackets, and show ""zero values as dashes, so as to focus the eye on the real numbers style_information-complete_style-number_format-format_code = '$#,##0.00;[Red]($#,##0.00);-' ##NO_TEXT. active_worksheet->change_cell_style( ip_column = column_as_letter ip_row = row_number ip_number_format_format_code = style_information-complete_style-number_format-format_code ). ENDIF.""Currency Amount ENDDO.""Rows ENDDO.""Columns *--------------------------------------------------------------------* * Listing 11.10: Programmatically Changing the Print Orientation to Landscape *--------------------------------------------------------------------* ""Page printing settings ""Margins are to be set to the values for ""narrow"". I just copy ""the values in the ""narrow"" option on the print preview active_worksheet->sheet_setup->set_page_margins( ip_top = '1.91' ip_bottom = '1.91' ip_left = '0.64' ip_right = '0.64' ip_header = '0.76' ip_footer = '0.76' ip_unit = 'cm' ) ##LITERAL. active_worksheet->sheet_setup->black_and_white = abap_true. ""Requirement is to fit all columns on one sheet ""You should turn ""fit to page"" on to activate fit_to_height and fit_to_width active_worksheet->sheet_setup->fit_to_page = abap_true. active_worksheet->sheet_setup->fit_to_width = 1. ""Used only if fit_to_page = TRUE active_worksheet->sheet_setup->orientation = zcl_excel_sheet_setup=>c_orientation_landscape. active_worksheet->sheet_setup->page_order = zcl_excel_sheet_setup=>c_ord_downthenover. active_worksheet->sheet_setup->paper_size = zcl_excel_sheet_setup=>c_papersize_a4. active_worksheet->sheet_setup->scale = 80. ""Used only if fit_to_page = FALSE active_worksheet->sheet_setup->horizontal_centered = abap_true. *--------------------------------------------------------------------* * Listing 11.11: Coding Header and Footer Print Settings *--------------------------------------------------------------------* ""Put Tab Name in Header Centre DATA(header_information) = VALUE zexcel_s_worksheet_head_foot( center_value = active_worksheet->get_title( ) center_font-size = 8 center_font-name = zcl_excel_style_font=>c_name_arial ). DATA(footer_information) = VALUE zexcel_s_worksheet_head_foot( ""Put last save date on footer left left_value = |{ sy-datum DATE = USER }| left_font = header_information-center_font ""Put Spreadsheet path and name in Footer Centre center_value = '&Z&F' ""Path / Filename center_font = header_information-center_font ""Put page X of Y on Footer Right right_value = 'page &P of &N' ""page x of y right_font = header_information-center_font ) ##no_text. active_worksheet->sheet_setup->set_header_footer( ip_odd_header = header_information ip_odd_footer = footer_information ). *--------------------------------------------------------------------* * Listing 11.12: Making the Header Row Repeat on Every Printed Sheet *--------------------------------------------------------------------* * Jonathon is a SKY BLUE PINK Monster *--------------------------------------------------------------------* active_worksheet->zif_excel_sheet_printsettings~set_print_repeat_rows( iv_rows_from = 1 iv_rows_to = 1 ). *--------------------------------------------------------------------* * Listing 11.14: Creating Colors to Use in a Spreadsheet *--------------------------------------------------------------------* DATA(green_style) = co_excel->add_new_style( ). green_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. green_style->fill->bgcolor-rgb = zcl_excel_style_color=>c_green. DATA(green_guid) = green_style->get_guid( ). DATA(red_style) = co_excel->add_new_style( ). red_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. red_style->fill->bgcolor-rgb = 'FFFF99FF'.""Soft Red (Pink Really) DATA(red_guid) = red_style->get_guid( ). DATA(yellow_style) = co_excel->add_new_style( ). yellow_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. yellow_style->fill->bgcolor-rgb = 'FFFF9900'. ""Orange - see ZDEMO_EXCEL21 DATA(yellow_guid) = yellow_style->get_guid( ). *--------------------------------------------------------------------* * Listing 11.15: Creating Conditional Formatting *--------------------------------------------------------------------* DATA: first_data_row TYPE sy-tabix, last_data_row TYPE sy-tabix. first_data_row = 2.""i.e. first row after header last_data_row = lines( mo_model->mt_output_data[] ) + 1. ""High Strength Monster - Green for 'Good' DATA(style_conditional) = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_rule_cellis. style_conditional->mode_cellis = VALUE #( formula = '""REALLY STRONG""' operator = zcl_excel_style_cond=>c_operator_equal cell_style = green_guid ). style_conditional->priority = 1. style_conditional->set_range( ip_start_column = strength_column_constant ip_start_row = first_data_row ip_stop_column = strength_column_constant ip_stop_row = last_data_row ). ""Low Strength Monster - Red for 'Bad' style_conditional = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_rule_cellis. style_conditional->mode_cellis = VALUE #( formula = '""LOW""' operator = zcl_excel_style_cond=>c_operator_equal cell_style = red_guid ). style_conditional->priority = 2. style_conditional->set_range( ip_start_column = strength_column_constant ip_start_row = first_data_row ip_stop_column = strength_column_constant ip_stop_row = last_data_row ). ""Medium Strength Monster - Yellow for 'nothing special' style_conditional = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_rule_cellis. style_conditional->mode_cellis = VALUE #( formula = '""MEDIUM""' operator = zcl_excel_style_cond=>c_operator_equal cell_style = yellow_guid ). style_conditional->priority = 3. style_conditional->set_range( ip_start_column = strength_column_constant ip_start_row = first_data_row ip_stop_column = strength_column_constant ip_stop_row = last_data_row ). *--------------------------------------------------------------------* * Listing 11.16: Conditional Formatting: Testing the Start of a String *--------------------------------------------------------------------* style_conditional = active_worksheet->add_new_style_cond( ). style_conditional->rule = zcl_excel_style_cond=>c_operator_beginswith. style_conditional->mode_cellis = VALUE #( formula = '1' operator = zcl_excel_style_cond=>c_operator_beginswith cell_style = red_guid ). *--------------------------------------------------------------------* * Listing 11.20: Conditional Formatting with Traffic Lights * The 7 Foot Tall Monster reads ""Anticipating Change"" by Hasso Platnner *--------------------------------------------------------------------* DATA: conditional_icon_settings TYPE zexcel_conditional_iconset, number_as_string TYPE string. ""Green if below 7 days conditional_icon_settings-cfvo1_type = zcl_excel_style_cond=>c_cfvo_type_number. conditional_icon_settings-cfvo1_value = '-9999'. ""Red if above 14 days conditional_icon_settings-cfvo2_type = zcl_excel_style_cond=>c_cfvo_type_number. number_as_string = 14. number_as_string = '-' && number_as_string. number_as_string = condense( number_as_string ). conditional_icon_settings-cfvo2_value = number_as_string. ""Yellow otherwise conditional_icon_settings-cfvo3_type = zcl_excel_style_cond=>c_cfvo_type_number. number_as_string = 7. number_as_string = '-' && number_as_string. number_as_string = condense( number_as_string ). conditional_icon_settings-cfvo3_value = number_as_string. ""Show the value as well as the ICON conditional_icon_settings-showvalue = zcl_excel_style_cond=>c_showvalue_true. ""We create a ""style"" to which we will add ""to the settings we just defined style_conditional = active_worksheet->add_new_style_cond( ). ""We are going to show ICONS style_conditional->rule = zcl_excel_style_cond=>c_rule_iconset. style_conditional->priority = 1. ""The ICONS are going to look like Traffic Lights conditional_icon_settings-iconset = zcl_excel_style_cond=>c_iconset_3trafficlights. style_conditional->mode_iconset = conditional_icon_settings. style_conditional->set_range( ip_start_column = age_column_constant ip_start_row = first_data_row ip_stop_column = age_column_constant ip_stop_row = last_data_row ). *--------------------------------------------------------------------* * Listing 11.21: Changing the Formatting to Make Negatives Look Positive *--------------------------------------------------------------------* ""We made all the monster ages negative earlier ""Now we have to show them as positive on the spreadsheet DATA: current_sheet_row TYPE zexcel_cell_row. current_sheet_row = 1. WHILE current_sheet_row LE last_data_row. current_sheet_row = current_sheet_row + 1. style_information-complete_style-number_format-format_code = '#,##0;#,##0'.""i.e. do not show minus sign active_worksheet->change_cell_style( ip_column = age_column_constant ip_row = current_sheet_row ip_number_format_format_code = style_information-complete_style-number_format-format_code ). ENDWHILE. *--------------------------------------------------------------------* * Listing 11.23: Setting Up the Pie Chart Data Worksheet *--------------------------------------------------------------------* active_worksheet = co_excel->add_new_worksheet( ). active_worksheet->set_title( 'Pie Chart Values'(014) ). ""In real life you would loop over an internal table to ""populate the data values for your monsters ""Pie Chart - Monster Types active_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Blue Monsters'(015) ). active_worksheet->set_cell( ip_column = 'A' ip_row = 2 ip_value = 'Red Monsters'(016) ). active_worksheet->set_cell( ip_column = 'A' ip_row = 3 ip_value = 'Green Monsters'(017) ). active_worksheet->set_cell( ip_column = 'A' ip_row = 4 ip_value = 'Sky Blue Pink Monsters'(018) ). ""Pie Chart - Number of each Monster Type active_worksheet->set_cell( ip_column = 'B' ip_row = 1 ip_value = 5 ). active_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 10 ). active_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 15 ). active_worksheet->set_cell( ip_column = 'B' ip_row = 4 ip_value = 20 ). *--------------------------------------------------------------------* * Listing 11.24: Setting Up the Pie Chart Worksheet *--------------------------------------------------------------------* ""Add the worksheet with the actual pie chart on it active_worksheet = co_excel->add_new_worksheet( ). active_worksheet->set_title( 'Monster Pie Chart'(019) ). DATA(monster_pie_chart) = NEW zcl_excel_graph_pie( ). ""Tell the Pie Chart where it gets it's data from monster_pie_chart->create_serie( ip_order = 0 ""The sheet the data comes from ip_sheet = 'Pie Chart Values'(014) ""Range where the labels live ip_lbl_from_col = 'A' ip_lbl_from_row = '1' ip_lbl_to_col = 'A' ip_lbl_to_row = '4' ""Range where the data values live ip_ref_from_col = 'B' ip_ref_from_row = '1' ip_ref_to_col = 'B' ip_ref_to_row = '4' ip_sername = |{ 'Monsters by Color'(020) }| ). monster_pie_chart->set_style( zcl_excel_graph=>c_style_15 ). ""Let us show the category names next to the pie chart monster_pie_chart->set_show_cat_name( zcl_excel_graph_pie=>c_show_true ). DATA(excel_drawing) = active_worksheet->excel->add_new_drawing( ip_type = zcl_excel_drawing=>type_chart ip_title = 'Monster Pie Chart'(019) ). excel_drawing->graph = monster_pie_chart. excel_drawing->graph_type = zcl_excel_drawing=>c_graph_pie. DATA: drawing_location_from_co_ords TYPE zexcel_drawing_location, drawing_location_to_co_ords TYPE zexcel_drawing_location. drawing_location_to_co_ords-row = 20. drawing_location_to_co_ords-col = 10. excel_drawing->set_position2( ip_from = drawing_location_from_co_ords ip_to = drawing_location_to_co_ords ). excel_drawing->set_media( ip_media_type = zcl_excel_drawing=>c_media_type_xml ). active_worksheet->add_drawing( excel_drawing ). ""The value sheet for the pie chart is hidden by default co_excel->set_active_sheet_index( 2 ). active_worksheet = co_excel->get_active_worksheet( ). active_worksheet->zif_excel_sheet_properties~hidden = zif_excel_sheet_properties=>c_hidden. ""We want the user to start on the first worksheet co_excel->set_active_sheet_index( 1 ). *--------------------------------------------------------------------* * Listing 11.32: Inserting Hyperlinks in a Spreadsheet *--------------------------------------------------------------------* DATA: hyperlink TYPE REF TO zcl_excel_hyperlink, hyperlink_url TYPE string, input_parameters TYPE string. active_worksheet = co_excel->get_active_worksheet( ). * Now we loop through the spreadsheet, adding hyperlinks so the user can drill * down into the original document in SAP current_sheet_row = first_data_row. LOOP AT mo_model->mt_output_data ASSIGNING FIELD-SYMBOL(). ""Drill down into the Monster Master Record IF -ordernumber IS NOT INITIAL. input_parameters = 'S_NUMBR-LOW=' && -ordernumber && ';'. hyperlink_url = zcl_excel_emailer=>build_hyperlink_url( id_transaction = 'ZMO3' id_parameters = input_parameters id_ok_code = '=ONLI' ). hyperlink = zcl_excel_hyperlink=>create_external_link( hyperlink_url ). active_worksheet->set_cell( ip_column = monster_column_constant ip_row = current_sheet_row ip_value = -ordernumber ip_hyperlink = hyperlink ). active_worksheet->change_cell_style( ip_column = monster_column_constant ip_row = current_sheet_row ip_font_color_rgb = zcl_excel_style_color=>c_blue ip_font_underline = abap_true ). ENDIF.""Do we have a Monster Number? current_sheet_row = current_sheet_row + 1. ENDLOOP.""Monster Table ENDMETHOD. METHOD change_edit_mode. *--------------------------------------------------------------------* * Listing 10.36: - User Command to Make a SALV Grid Editable *--------------------------------------------------------------------* DATA(underlying_alv_grid) = mo_view->get_alv_grid_object( ). IF underlying_alv_grid IS NOT BOUND. RETURN. ENDIF. underlying_alv_grid->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = DATA(field_catalog_table) ). make_column_editable( : EXPORTING id_column_name = 'MONSTER_HATS' CHANGING ct_fcat = field_catalog_table ), EXPORTING id_column_name = 'MONSTER_HEADS' CHANGING ct_fcat = field_catalog_table ). underlying_alv_grid->set_frontend_fieldcatalog( field_catalog_table ). underlying_alv_grid->set_frontend_layout( VALUE #( stylefname = 'CELLTAB' ) ). underlying_alv_grid->refresh_table_display( ). cl_gui_cfw=>flush( ). ENDMETHOD. METHOD download_spreadseet. *--------------------------------------------------------------------* * Listing 11.28: - Uploading an Excel Template *--------------------------------------------------------------------* * Local Variables DATA: lo_alv_grid TYPE REF TO cl_salv_table, ls_template TYPE ztexcel_template, lo_excel_reader TYPE REF TO zif_excel_reader. TRY. IF go_selections->p_macro = abap_true. lo_excel_reader = NEW zcl_excel_reader_xlsm( ). ""Retrieve template from the database SELECT SINGLE * FROM ztexcel_template INTO CORRESPONDING FIELDS OF ls_template WHERE template_name = 'MONSTER_EXAMPLE'. DATA(lo_excel) = lo_excel_reader->load( ls_template-raw_data ). DATA(lo_worksheet) = lo_excel->get_active_worksheet( ). ENDIF.""Do we want to use a macro? *-------------------------------------------------------------------------------------------------------------------* * In one Haunted Castle there is the ghost who loves to join parties. Her ghost has been seen at functions in the * ballroom, clothed in a ballgown of that era *-------------------------------------------------------------------------------------------------------------------* * Listing 11.05: - Transforming a Report Object into an Excel Object * AND * Listing 11.29: - Filling the Macro-Enabled Worksheet with Data *--------------------------------------------------------------------* * Convert SALV object into EXCEL object *--------------------------------------------------------------------* lo_alv_grid ?= mo_view->get_main_alv_object( ). DATA(lo_converter) = NEW zcl_excel_converter( ). lo_converter->convert( EXPORTING io_alv = lo_alv_grid it_table = mo_model->mt_output_data[] i_table = abap_true i_style_table = zcl_excel_table=>builtinstyle_medium2 io_worksheet = lo_worksheet CHANGING co_excel = lo_excel ). ""Make any changes to the spreadsheet object that relate to this report adjust_spreadsheet( CHANGING co_excel = lo_excel ). CATCH zcx_excel. RETURN. ENDTRY. *--------------------------------------------------------------------* * Listing 11.04: - Downloading an EXCEL Spreadsheet *--------------------------------------------------------------------* * Choose where to download EXCEL spreadsheet to front end *--------------------------------------------------------------------* DATA: lt_rawdata TYPE solix_tab, ld_bytecount TYPE i, ld_filename TYPE string, ld_path TYPE string, ld_fullpath TYPE string. ""From now on this is all bog standard SAP cl_gui_frontend_services=>file_save_dialog( EXPORTING window_title = |{ 'Choose where to save file'(021) }| default_extension = 'XLSX' "" Default Extension CHANGING filename = ld_filename "" File Name to Save path = ld_path "" Path to File fullpath = ld_fullpath "" Path + File Name EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 OTHERS = 4 ). IF sy-subrc <> 0. RETURN. ENDIF. *--------------------------------------------------------------------* * Listing 11.30: - Making sure the Spreadsheet File is Saved Correctly *--------------------------------------------------------------------* * Convert to XML *--------------------------------------------------------------------* DATA: ld_xml_file TYPE xstring, lo_excel_writer TYPE REF TO zif_excel_writer, lf_macro_enabled TYPE abap_bool. TRY. IF lo_excel->zif_excel_book_vba_project~codename_pr IS NOT INITIAL. lf_macro_enabled = abap_true. ELSE. lf_macro_enabled = abap_false. ENDIF. IF ld_fullpath CS 'XLSM' AND lf_macro_enabled = abap_false. REPLACE 'XLSM' WITH 'XLSX' INTO ld_fullpath. ELSEIF ld_fullpath CS 'XLSX' AND lf_macro_enabled = abap_true. REPLACE 'XLSX' WITH 'XLSM' INTO ld_fullpath. ELSEIF ld_fullpath CS 'XLSX' OR ld_fullpath CS 'XLSM'. ""Do nothing - everything is fine ELSEIF ld_fullpath CS 'XLS' AND lf_macro_enabled = abap_false. REPLACE 'XLS' WITH 'XLSX' INTO ld_fullpath. ELSEIF ld_fullpath CS 'XLS' AND lf_macro_enabled = abap_true. REPLACE 'XLS' WITH 'XLSM' INTO ld_fullpath. ENDIF. IF ld_fullpath CS 'XLSM'. lo_excel_writer = NEW zcl_excel_writer_xlsm( ). ELSE. lo_excel_writer = NEW zcl_excel_writer_2007( ). ENDIF. ld_xml_file = lo_excel_writer->write_file( lo_excel ). *--------------------------------------------------------------------* * Download to Front End *--------------------------------------------------------------------* lt_rawdata = cl_bcs_convert=>xstring_to_solix( ld_xml_file ). ld_bytecount = xstrlen( ld_xml_file ). cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = ld_bytecount filename = ld_fullpath filetype = 'BIN' CHANGING data_tab = lt_rawdata ). CATCH zcx_excel INTO DATA(lo_exception). DATA(ld_error) = lo_exception->get_text( ). MESSAGE ld_error TYPE 'E'. ENDTRY. ENDMETHOD. METHOD on_user_command. *--------------------------------------------------------------------* * FOR EVENT added_function OF cl_salv_events * IMPORTING ed_user_command * ed_row * ed_column. *--------------------------------------------------------------------* CASE ed_user_command. WHEN 'ZEDIT'. ""A command to change the edit mode change_edit_mode( ). WHEN 'ZEXCEL'. ""Command to download the spreadsheet to the local machine download_spreadseet( ). ENDCASE.""User Command mo_model->user_command( id_user_command = ed_user_command id_column = ed_column id_row = ed_row ). mo_view->refresh_display( ). *----------------------------------------------------------------------------------------------------------* * At the time of the murder the Green Monster was in the castle directly to the west of the castle that the * Sky-Blue Pink Monster was in *----------------------------------------------------------------------------------------------------------* ENDMETHOD.""User Command / Controller METHOD on_data_changed. mo_view->refresh_display( ). ENDMETHOD. ""on_data_changed METHOD make_column_editable. *--------------------------------------------------------------------* * Listng 10.38: - MAKE_COLUMN_EDITABLE Method *--------------------------------------------------------------------* * IMPORTING id_column_name TYPE dd03l-fieldname * CHANGING ct_fcat TYPE lvc_t_fcat. *--------------------------------------------------------------------* LOOP AT mo_model->mt_output_data ASSIGNING FIELD-SYMBOL(). READ TABLE -celltab ASSIGNING FIELD-SYMBOL() WITH KEY fieldname = id_column_name. IF sy-subrc <> 0. INSERT VALUE #( fieldname = id_column_name ) INTO TABLE -celltab. READ TABLE -celltab ASSIGNING WITH KEY fieldname = id_column_name. ASSERT sy-subrc EQ 0. ENDIF. IF -style EQ cl_gui_alv_grid=>mc_style_enabled. -style = cl_gui_alv_grid=>mc_style_disabled. ELSE. -style = cl_gui_alv_grid=>mc_style_enabled. ENDIF. ENDLOOP. LOOP AT ct_fcat ASSIGNING FIELD-SYMBOL() WHERE fieldname = id_column_name. -edit = abap_true. ENDLOOP. ENDMETHOD.""make column editable ENDCLASS. ""lcl_controller IMPLEMENTATION *----------------------------------------------------------------------------* * Listing 10.43: - IDA Class to Calculate Extra Field Values – Implementation *----------------------------------------------------------------------------* CLASS lcl_ida_calculated_m_fields IMPLEMENTATION. METHOD constructor. mo_monster_model = NEW #( ). ENDMETHOD. METHOD if_salv_ida_calc_field_handler~get_calc_field_structure. ""Define additional fields by returning the structure description DATA transient_fields TYPE z4st_monster_header_dt. ro_calc_field_structure ?= cl_abap_structdescr=>describe_by_data( transient_fields ). ENDMETHOD. METHOD if_salv_ida_calc_field_handler~get_requested_fields. ""Define which fields are required for the calculation of the additional fields DATA field_name TYPE fieldname. ""To find the sanity description, you need the sanity percentage IF line_exists( its_calc_field_name[ table_line = 'SANITY_DESCRIPTION' ] ). field_name = 'SANITY_PERCENTAGE'. INSERT field_name INTO TABLE rts_db_field_name. ENDIF. ENDMETHOD. METHOD if_salv_ida_calc_field_handler~start_page. CLEAR ev_cancel_calculation. ""Buffer which of the calculated fields are displayed ""--> later calculate values only for these fields to save performance mt_calc_field_names[] = its_calc_field_name[]. ENDMETHOD. METHOD if_salv_ida_calc_field_handler~calculate_line. DATA: all_fields TYPE z4sc_monster_header_ex, persistent_fields TYPE z4t_monster_head, transient_fields TYPE z4st_monster_header_dt. CLEAR es_calculated_fields. persistent_fields = is_data_base_line. all_fields = CORRESPONDING #( persistent_fields ) ##ENH_OK. IF line_exists( mt_calc_field_names[ table_line = 'SANITY_DESCRIPTION' ] ). TRY. mo_monster_model->derive_header_fields( CHANGING cs_monster_header = all_fields ). transient_fields = CORRESPONDING #( all_fields ). CATCH zcx_4_monster_exceptions. RETURN. ENDTRY. ENDIF. es_calculated_fields = transient_fields. ENDMETHOD. METHOD if_salv_ida_calc_field_handler~end_page ##NEEDED. ""Do Nothing. The Monster who collects Rare Coins is 6 Feet Tall ENDMETHOD. ENDCLASS. ",12286,False,2315.097826908542,median "CLASS zcl_abapgit_objects DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. TYPES: ty_types_tt TYPE STANDARD TABLE OF tadir-object WITH DEFAULT KEY . TYPES: BEGIN OF ty_deserialization, obj TYPE REF TO zif_abapgit_object, xml TYPE REF TO zcl_abapgit_xml_input, package TYPE devclass, item TYPE zif_abapgit_definitions=>ty_item, END OF ty_deserialization . TYPES: ty_deserialization_tt TYPE STANDARD TABLE OF ty_deserialization WITH DEFAULT KEY . 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 io_log TYPE REF TO zcl_abapgit_log OPTIONAL RETURNING VALUE(rs_files_and_item) TYPE zcl_abapgit_objects=>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 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 RAISING zcx_abapgit_exception . CLASS-METHODS jump IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !i_line_number TYPE i 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 has_changed_since IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_timestamp TYPE timestamp RETURNING VALUE(rv_changed) TYPE abap_bool 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_map, item TYPE zif_abapgit_definitions=>ty_item, metadata TYPE zif_abapgit_definitions=>ty_metadata, END OF ty_obj_serializer_map, tty_obj_serializer_map TYPE SORTED TABLE OF ty_obj_serializer_map WITH UNIQUE KEY item. CLASS-DATA gt_obj_serializer_map TYPE tty_obj_serializer_map. CLASS-METHODS files_to_deserialize IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RETURNING VALUE(rt_results) TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS check_duplicates IMPORTING !it_files TYPE zif_abapgit_definitions=>ty_files_tt RAISING zcx_abapgit_exception . CLASS-METHODS prioritize_deser IMPORTING !it_results TYPE zif_abapgit_definitions=>ty_results_tt RETURNING VALUE(rt_results) TYPE zif_abapgit_definitions=>ty_results_tt . CLASS-METHODS class_name IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item RETURNING VALUE(rv_class_name) TYPE string . CLASS-METHODS warning_overwrite_adjust IMPORTING !it_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt CHANGING !ct_results TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS checks_adjust IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo !is_checks TYPE zif_abapgit_definitions=>ty_deserialize_checks CHANGING !ct_results TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS warning_overwrite_find IMPORTING !it_results TYPE zif_abapgit_definitions=>ty_results_tt RETURNING VALUE(rt_overwrite) TYPE zif_abapgit_definitions=>ty_overwrite_tt RAISING zcx_abapgit_exception . CLASS-METHODS warning_package_adjust IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo !it_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt CHANGING !ct_results TYPE zif_abapgit_definitions=>ty_results_tt RAISING zcx_abapgit_exception . CLASS-METHODS warning_package_find IMPORTING !it_results TYPE zif_abapgit_definitions=>ty_results_tt !io_repo TYPE REF TO zcl_abapgit_repo RETURNING VALUE(rt_overwrite) TYPE zif_abapgit_definitions=>ty_overwrite_tt RAISING zcx_abapgit_exception . CLASS-METHODS update_package_tree IMPORTING !iv_package TYPE devclass . CLASS-METHODS delete_obj IMPORTING !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 RAISING zcx_abapgit_exception . CLASS-METHODS deserialize_objects IMPORTING it_objects TYPE ty_deserialization_tt iv_ddic TYPE abap_bool DEFAULT abap_false iv_descr TYPE string 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. 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. * todo, fallback to looking at transports if rv_user = 'UNKNOWN'? ENDMETHOD. METHOD checks_adjust. warning_overwrite_adjust( EXPORTING it_overwrite = is_checks-overwrite CHANGING ct_results = ct_results ). warning_package_adjust( EXPORTING io_repo = io_repo it_overwrite = is_checks-warning_package CHANGING ct_results = ct_results ). ENDMETHOD. METHOD check_duplicates. DATA: lt_files TYPE zif_abapgit_definitions=>ty_files_tt. lt_files = it_files. SORT lt_files BY path ASCENDING filename ASCENDING. DELETE ADJACENT DUPLICATES FROM lt_files COMPARING path filename. IF lines( lt_files ) <> lines( it_files ). zcx_abapgit_exception=>raise( 'Duplicates' ). ENDIF. 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 . 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. ""#EC NOTEXT 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, lo_remote_version TYPE REF TO zcl_abapgit_xml_input, lv_count TYPE i, li_comparison_result TYPE REF TO zif_abapgit_comparison_result. 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 file does not exist in remote, we don't need to validate IF sy-subrc = 0. CREATE OBJECT lo_remote_version EXPORTING iv_xml = zcl_abapgit_convert=>xstring_to_string_utf8( ls_remote_file-data ). li_comparison_result = ii_object->compare_to_remote_version( lo_remote_version ). li_comparison_result->show_confirmation_dialog( ). IF li_comparison_result->is_result_complete_halt( ) = abap_true. zcx_abapgit_exception=>raise( 'Deserialization aborted by user' ). ENDIF. 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. * IF zcl_abapgit_persist_settings=>get_instance( )->read( )->get_experimental_features( ) = abap_true * AND is_item-obj_type = 'CLAS'. * lv_class_name = 'LCL_OBJECT_CLAS_NEW'. * 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 } not supported, serialize|. ""#EC NOTEXT 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, lo_progress TYPE REF TO zcl_abapgit_progress, lt_tadir LIKE it_tadir, lt_items TYPE zif_abapgit_definitions=>ty_items_tt, lx_error TYPE REF TO zcx_abapgit_exception, lv_text TYPE string. 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 ). CREATE OBJECT lo_progress EXPORTING iv_total = 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 ). LOOP AT lt_tadir ASSIGNING . lo_progress->show( iv_current = sy-tabix iv_text = |Delete { -obj_name }| ) ##NO_TEXT. CLEAR ls_item. ls_item-obj_type = -object. ls_item-obj_name = -obj_name. delete_obj( ls_item ). * make sure to save object deletions COMMIT WORK. ENDLOOP. CATCH zcx_abapgit_exception INTO lx_error. zcl_abapgit_default_transport=>get_instance( )->reset( ). lv_text = lx_error->get_text( ). zcx_abapgit_exception=>raise( lv_text ). ENDTRY. zcl_abapgit_default_transport=>get_instance( )->reset( ). ENDMETHOD. METHOD delete_obj. 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( ). 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. 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 zcl_abapgit_xml_input, lt_results TYPE zif_abapgit_definitions=>ty_results_tt, lt_ddic TYPE TABLE OF ty_deserialization, lt_rest TYPE TABLE OF ty_deserialization, lt_late TYPE TABLE OF ty_deserialization, lo_progress TYPE REF TO zcl_abapgit_progress, lv_path TYPE string, lt_items TYPE zif_abapgit_definitions=>ty_items_tt. DATA: lo_folder_logic TYPE REF TO zcl_abapgit_folder_logic. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_result, LIKE LINE OF lt_late. 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 = files_to_deserialize( io_repo ). checks_adjust( EXPORTING io_repo = io_repo is_checks = is_checks CHANGING ct_results = lt_results ). CREATE OBJECT lo_progress EXPORTING iv_total = lines( lt_results ). lt_items = map_results_to_items( lt_results ). check_objects_locked( iv_language = io_repo->get_dot_abapgit( )->get_master_language( ) it_items = lt_items ). lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ). LOOP AT lt_results ASSIGNING . lo_progress->show( iv_current = sy-tabix iv_text = |Deserialize { -obj_name }| ) ##NO_TEXT. CLEAR ls_item. ls_item-obj_type = -obj_type. ls_item-obj_name = -obj_name. lv_package = lo_folder_logic->path_to_package( iv_top = io_repo->get_package( ) io_dot = io_repo->get_dot_abapgit( ) iv_path = -path ). 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_master_language( ) is_metadata = lo_xml->get_metadata( ) ). compare_remote_to_local( ii_object = li_obj it_remote = lt_remote is_result = ). li_obj->mo_files = lo_files. IF li_obj->get_metadata( )-late_deser = abap_true. APPEND INITIAL LINE TO lt_late ASSIGNING . ELSEIF li_obj->get_metadata( )-ddic = abap_true. APPEND INITIAL LINE TO lt_ddic ASSIGNING . ELSE. APPEND INITIAL LINE TO lt_rest ASSIGNING . ENDIF. -item = ls_item. -obj = li_obj. -xml = lo_xml. -package = lv_package. CLEAR: lv_path, lv_package. ENDLOOP. deserialize_objects( EXPORTING it_objects = lt_ddic iv_ddic = abap_true iv_descr = 'DDIC' CHANGING ct_files = rt_accessed_files ). deserialize_objects( EXPORTING it_objects = lt_rest iv_descr = 'Objects' CHANGING ct_files = rt_accessed_files ). deserialize_objects( EXPORTING it_objects = lt_late iv_descr = 'Late' CHANGING ct_files = rt_accessed_files ). 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( ). ENDMETHOD. METHOD deserialize_checks. DATA: lt_results TYPE zif_abapgit_definitions=>ty_results_tt, li_package TYPE REF TO zif_abapgit_sap_package. lt_results = files_to_deserialize( io_repo ). rs_checks-overwrite = warning_overwrite_find( lt_results ). rs_checks-warning_package = warning_package_find( io_repo = io_repo it_results = lt_results ). IF lines( lt_results ) > 0. li_package = zcl_abapgit_factory=>get_sap_package( io_repo->get_package( ) ). rs_checks-transport-required = li_package->are_changes_recorded_in_tr_req( ). IF NOT rs_checks-transport-required IS INITIAL. rs_checks-transport-type = li_package->get_transport_type( ). ENDIF. ENDIF. ENDMETHOD. METHOD deserialize_objects. DATA: lo_progress TYPE REF TO zcl_abapgit_progress. FIELD-SYMBOLS: LIKE LINE OF it_objects. zcl_abapgit_objects_activation=>clear( ). CREATE OBJECT lo_progress EXPORTING iv_total = lines( it_objects ). LOOP AT it_objects ASSIGNING . lo_progress->show( iv_current = sy-tabix iv_text = |Deserialize { iv_descr } - { -item-obj_name }| ) ##NO_TEXT. -obj->deserialize( iv_package = -package io_xml = -xml ). APPEND LINES OF -obj->mo_files->get_accessed_files( ) TO ct_files. ENDLOOP. zcl_abapgit_objects_activation=>activate( iv_ddic ). 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 files_to_deserialize. FIELD-SYMBOLS: LIKE LINE OF rt_results. rt_results = zcl_abapgit_file_status=>status( io_repo ). DELETE rt_results WHERE match = abap_true. "" Full match SORT rt_results BY obj_type ASCENDING obj_name ASCENDING filename ASCENDING. DELETE ADJACENT DUPLICATES FROM rt_results COMPARING obj_type obj_name filename. DELETE rt_results WHERE obj_type IS INITIAL. DELETE rt_results WHERE lstate = zif_abapgit_definitions=>c_state-added AND rstate IS INITIAL. rt_results = prioritize_deser( rt_results ). LOOP AT rt_results ASSIGNING . * handle namespaces REPLACE ALL OCCURRENCES OF '#' IN -obj_name WITH '/'. ENDLOOP. ENDMETHOD. METHOD has_changed_since. rv_changed = abap_true. "" Assume changed IF is_supported( is_item ) = abap_false. RETURN. "" Will requre serialize which will log the error ENDIF. rv_changed = create_object( is_item = is_item iv_language = zif_abapgit_definitions=>c_english )->has_changed_since( iv_timestamp ). 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_settings=>get_instance( )->read( )->get_adt_jump_enabled( ). IF lv_adt_jump_enabled = abap_true. TRY. zcl_abapgit_objects_super=>jump_adt( i_obj_name = is_item-obj_name i_obj_type = is_item-obj_type i_line_number = i_line_number ). CATCH zcx_abapgit_exception. li_obj->jump( ). ENDTRY. 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 prioritize_deser. FIELD-SYMBOLS: LIKE LINE OF it_results. * XSLT has to be handled before CLAS/PROG LOOP AT it_results ASSIGNING WHERE obj_type = 'XSLT'. APPEND TO rt_results. ENDLOOP. * PROG before internet services, as the services might use the screens LOOP AT it_results ASSIGNING WHERE obj_type = 'PROG'. APPEND TO rt_results. ENDLOOP. * ISAP has to be handled before ISRP LOOP AT it_results ASSIGNING WHERE obj_type = 'IASP'. APPEND TO rt_results. ENDLOOP. * PINF has to be handled before DEVC for package interface usage LOOP AT it_results ASSIGNING WHERE obj_type = 'PINF'. APPEND TO rt_results. ENDLOOP. * ENHS has to be handled before ENHO LOOP AT it_results ASSIGNING WHERE obj_type = 'ENHS'. APPEND TO rt_results. ENDLOOP. LOOP AT it_results ASSIGNING WHERE obj_type <> 'IASP' AND obj_type <> 'PROG' AND obj_type <> 'XSLT' AND obj_type <> 'PINF' AND obj_type <> 'ENHS'. APPEND TO rt_results. ENDLOOP. ENDMETHOD. METHOD serialize. DATA: li_obj TYPE REF TO zif_abapgit_object, lo_xml TYPE REF TO zcl_abapgit_xml_output, lo_files TYPE REF TO zcl_abapgit_objects_files. 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. IF NOT io_log IS INITIAL. io_log->add( iv_msg = |Object type ignored, not supported: { rs_files_and_item-item-obj_type }-{ rs_files_and_item-item-obj_name }| iv_type = 'E' ). ENDIF. RETURN. 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 lo_xml. li_obj->serialize( lo_xml ). lo_files->add_xml( io_xml = lo_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( iv_type = zif_abapgit_definitions=>c_type-blob iv_data = -data ). ENDLOOP. ENDMETHOD. METHOD supported_list. DATA: lt_objects TYPE STANDARD TABLE OF ko100, lv_supported TYPE abap_bool, ls_item TYPE zif_abapgit_definitions=>ty_item. FIELD-SYMBOLS LIKE LINE OF lt_objects. 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. lv_supported = zcl_abapgit_objects=>is_supported( is_item = ls_item iv_native_only = abap_true ). IF lv_supported = abap_true. APPEND -object TO rt_types. ENDIF. ENDLOOP. 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. METHOD warning_overwrite_adjust. DATA: lt_overwrite LIKE it_overwrite, ls_overwrite LIKE LINE OF lt_overwrite. FIELD-SYMBOLS: LIKE LINE OF lt_overwrite. * make sure to get the current status, as something might have changed in the meanwhile lt_overwrite = warning_overwrite_find( ct_results ). LOOP AT lt_overwrite ASSIGNING . READ TABLE it_overwrite INTO ls_overwrite WITH KEY obj_type = -obj_type obj_name = -obj_name. IF sy-subrc <> 0 OR ls_overwrite-decision IS INITIAL. zcx_abapgit_exception=>raise( |Overwrite { -obj_type } { -obj_name } undecided| ). ENDIF. IF ls_overwrite-decision = 'N'. DELETE ct_results WHERE obj_type = -obj_type AND obj_name = -obj_name. ASSERT sy-subrc = 0. ENDIF. ENDLOOP. ENDMETHOD. METHOD warning_overwrite_find. DATA: ls_overwrite LIKE LINE OF rt_overwrite. FIELD-SYMBOLS: LIKE LINE OF it_results. LOOP AT it_results ASSIGNING WHERE NOT obj_type IS INITIAL. IF -lstate IS NOT INITIAL AND -lstate <> zif_abapgit_definitions=>c_state-deleted AND NOT ( -lstate = zif_abapgit_definitions=>c_state-added AND -rstate IS INITIAL ). * current object has been modified locally, add to table CLEAR ls_overwrite. MOVE-CORRESPONDING TO ls_overwrite. APPEND ls_overwrite TO rt_overwrite. ENDIF. ENDLOOP. SORT rt_overwrite. DELETE ADJACENT DUPLICATES FROM rt_overwrite. ENDMETHOD. METHOD warning_package_adjust. DATA: lt_overwrite LIKE it_overwrite, ls_overwrite LIKE LINE OF lt_overwrite. FIELD-SYMBOLS: LIKE LINE OF lt_overwrite. * make sure to get the current status, as something might have changed in the meanwhile lt_overwrite = warning_package_find( it_results = ct_results io_repo = io_repo ). LOOP AT lt_overwrite ASSIGNING . READ TABLE it_overwrite INTO ls_overwrite WITH KEY obj_type = -obj_type obj_name = -obj_name. IF sy-subrc <> 0 OR ls_overwrite-decision IS INITIAL. zcx_abapgit_exception=>raise( |Overwrite odd package { -obj_type } { -obj_name } undecided| ). ENDIF. IF ls_overwrite-decision = 'N'. DELETE ct_results WHERE obj_type = -obj_type AND obj_name = -obj_name. ASSERT sy-subrc = 0. ENDIF. ENDLOOP. ENDMETHOD. METHOD warning_package_find. DATA: lv_package TYPE devclass, lt_overwrite_uniqe TYPE HASHED TABLE OF zif_abapgit_definitions=>ty_overwrite WITH UNIQUE KEY obj_type obj_name devclass, ls_overwrite LIKE LINE OF rt_overwrite, ls_tadir TYPE zif_abapgit_definitions=>ty_tadir. DATA: lo_folder_logic TYPE REF TO zcl_abapgit_folder_logic. FIELD-SYMBOLS: LIKE LINE OF it_results. lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ). LOOP AT it_results ASSIGNING . lv_package = lo_folder_logic->path_to_package( iv_top = io_repo->get_package( ) io_dot = io_repo->get_dot_abapgit( ) iv_path = -path ). ls_tadir = zcl_abapgit_factory=>get_tadir( )->read_single( iv_object = -obj_type iv_obj_name = -obj_name ). IF NOT ls_tadir IS INITIAL AND ls_tadir-devclass <> lv_package. * overwriting object from different package than expected CLEAR ls_overwrite. ls_overwrite-obj_type = -obj_type. ls_overwrite-obj_name = -obj_name. ls_overwrite-devclass = ls_tadir-devclass. INSERT ls_overwrite INTO TABLE lt_overwrite_uniqe. ENDIF. ENDLOOP. rt_overwrite = lt_overwrite_uniqe. ENDMETHOD. METHOD is_active. DATA: object TYPE REF TO zif_abapgit_object. object = create_object( is_item = is_item iv_language = sy-langu ). TRY. rv_active = object->is_active( ). CATCH cx_sy_dyn_call_illegal_method cx_sy_ref_is_initial. rv_active = abap_true. ENDTRY. ENDMETHOD. ENDCLASS. ",8305,False,1830.4618916914237,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 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; } } }",16205,True,3291.381963167814,median "CLASS zcl_excel_style_changer DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_excel_style_changer. CLASS-METHODS create IMPORTING excel TYPE REF TO zcl_excel RETURNING VALUE(result) TYPE REF TO zif_excel_style_changer RAISING zcx_excel. PROTECTED SECTION. PRIVATE SECTION. METHODS clear_initial_colorxfields IMPORTING is_color TYPE zexcel_s_style_color CHANGING cs_xcolor TYPE zexcel_s_cstylex_color. METHODS move_supplied_borders IMPORTING iv_border_supplied TYPE abap_bool is_border TYPE zexcel_s_cstyle_border iv_xborder_supplied TYPE abap_bool is_xborder TYPE zexcel_s_cstylex_border CHANGING cs_complete_style_border TYPE zexcel_s_cstyle_border cs_complete_stylex_border TYPE zexcel_s_cstylex_border. DATA: excel TYPE REF TO zcl_excel, lv_xborder_supplied TYPE abap_bool, single_change_requested TYPE zexcel_s_cstylex_complete, BEGIN OF multiple_change_requested, complete TYPE abap_bool, font TYPE abap_bool, fill TYPE abap_bool, BEGIN OF borders, complete TYPE abap_bool, allborders TYPE abap_bool, diagonal TYPE abap_bool, down TYPE abap_bool, left TYPE abap_bool, right TYPE abap_bool, top TYPE abap_bool, END OF borders, alignment TYPE abap_bool, protection TYPE abap_bool, END OF multiple_change_requested. CONSTANTS: lv_border_supplied TYPE abap_bool VALUE abap_true. ALIASES: complete_style FOR zif_excel_style_changer~complete_style, complete_stylex FOR zif_excel_style_changer~complete_stylex. ENDCLASS. CLASS zcl_excel_style_changer IMPLEMENTATION. METHOD clear_initial_colorxfields. IF is_color-rgb IS INITIAL. CLEAR cs_xcolor-rgb. ENDIF. IF is_color-indexed IS INITIAL. CLEAR cs_xcolor-indexed. ENDIF. IF is_color-theme IS INITIAL. CLEAR cs_xcolor-theme. ENDIF. IF is_color-tint IS INITIAL. CLEAR cs_xcolor-tint. ENDIF. ENDMETHOD. METHOD create. DATA: style TYPE REF TO zcl_excel_style_changer. CREATE OBJECT style. style->excel = excel. result = style. ENDMETHOD. METHOD move_supplied_borders. DATA: cs_borderx TYPE zexcel_s_cstylex_border. IF iv_border_supplied = abap_true. "" only act if parameter was supplied IF iv_xborder_supplied = abap_true. "" cs_borderx = is_xborder. "" use supplied x-parameter ELSE. CLEAR cs_borderx WITH 'X'. "" <============================== DDIC structure enh. category to set? "" clear in a way that would be expected to work easily IF is_border-border_style IS INITIAL. CLEAR cs_borderx-border_style. ENDIF. clear_initial_colorxfields( EXPORTING is_color = is_border-border_color CHANGING cs_xcolor = cs_borderx-border_color ). ENDIF. cs_complete_style_border = is_border. cs_complete_stylex_border = cs_borderx. ENDIF. ENDMETHOD. METHOD zif_excel_style_changer~apply. DATA: stylemapping TYPE zexcel_s_stylemapping, lo_worksheet TYPE REF TO zcl_excel_worksheet, l_guid TYPE zexcel_cell_style. lo_worksheet = excel->get_worksheet_by_name( ip_sheet_name = ip_worksheet->get_title( ) ). IF lo_worksheet <> ip_worksheet. zcx_excel=>raise_text( 'Worksheet doesn''t correspond to workbook of style changer'(001) ). ENDIF. TRY. ip_worksheet->get_cell( EXPORTING ip_column = ip_column ip_row = ip_row IMPORTING ep_guid = l_guid ). stylemapping = excel->get_style_to_guid( l_guid ). CATCH zcx_excel. * Error --> use submitted style ENDTRY. IF multiple_change_requested-complete = abap_true. stylemapping-complete_style = complete_style. stylemapping-complete_stylex = complete_stylex. ENDIF. IF multiple_change_requested-font = abap_true. stylemapping-complete_style-font = complete_style-font. stylemapping-complete_stylex-font = complete_stylex-font. ENDIF. IF multiple_change_requested-fill = abap_true. stylemapping-complete_style-fill = complete_style-fill. stylemapping-complete_stylex-fill = complete_stylex-fill. ENDIF. IF multiple_change_requested-borders-complete = abap_true. stylemapping-complete_style-borders = complete_style-borders. stylemapping-complete_stylex-borders = complete_stylex-borders. ENDIF. IF multiple_change_requested-borders-allborders = abap_true. stylemapping-complete_style-borders-allborders = complete_style-borders-allborders. stylemapping-complete_stylex-borders-allborders = complete_stylex-borders-allborders. ENDIF. IF multiple_change_requested-borders-diagonal = abap_true. stylemapping-complete_style-borders-diagonal = complete_style-borders-diagonal. stylemapping-complete_stylex-borders-diagonal = complete_stylex-borders-diagonal. ENDIF. IF multiple_change_requested-borders-down = abap_true. stylemapping-complete_style-borders-down = complete_style-borders-down. stylemapping-complete_stylex-borders-down = complete_stylex-borders-down. ENDIF. IF multiple_change_requested-borders-left = abap_true. stylemapping-complete_style-borders-left = complete_style-borders-left. stylemapping-complete_stylex-borders-left = complete_stylex-borders-left. ENDIF. IF multiple_change_requested-borders-right = abap_true. stylemapping-complete_style-borders-right = complete_style-borders-right. stylemapping-complete_stylex-borders-right = complete_stylex-borders-right. ENDIF. IF multiple_change_requested-borders-TOP = abap_true. stylemapping-complete_style-borders-TOP = complete_style-borders-TOP. stylemapping-complete_stylex-borders-TOP = complete_stylex-borders-TOP. ENDIF. IF multiple_change_requested-alignment = abap_true. stylemapping-complete_style-alignment = complete_style-alignment. stylemapping-complete_stylex-alignment = complete_stylex-alignment. ENDIF. IF multiple_change_requested-protection = abap_true. stylemapping-complete_style-protection = complete_style-protection. stylemapping-complete_stylex-protection = complete_stylex-protection. ENDIF. IF complete_stylex-number_format = abap_true. stylemapping-complete_style-number_format-format_code = complete_style-number_format-format_code. stylemapping-complete_stylex-number_format-format_code = abap_true. ENDIF. IF complete_stylex-font-bold = abap_true. stylemapping-complete_style-font-bold = complete_style-font-bold. stylemapping-complete_stylex-font-bold = complete_stylex-font-bold. ENDIF. IF complete_stylex-font-color = abap_true. stylemapping-complete_style-font-color = complete_style-font-color. stylemapping-complete_stylex-font-color = complete_stylex-font-color. ENDIF. IF complete_stylex-font-color-rgb = abap_true. stylemapping-complete_style-font-color-rgb = complete_style-font-color-rgb. stylemapping-complete_stylex-font-color-rgb = complete_stylex-font-color-rgb. ENDIF. IF complete_stylex-font-color-indexed = abap_true. stylemapping-complete_style-font-color-indexed = complete_style-font-color-indexed. stylemapping-complete_stylex-font-color-indexed = complete_stylex-font-color-indexed. ENDIF. IF complete_stylex-font-color-theme = abap_true. stylemapping-complete_style-font-color-theme = complete_style-font-color-theme. stylemapping-complete_stylex-font-color-theme = complete_stylex-font-color-theme. ENDIF. IF complete_stylex-font-color-tint = abap_true. stylemapping-complete_style-font-color-tint = complete_style-font-color-tint. stylemapping-complete_stylex-font-color-tint = complete_stylex-font-color-tint. ENDIF. IF complete_stylex-font-family = abap_true. stylemapping-complete_style-font-family = complete_style-font-family. stylemapping-complete_stylex-font-family = complete_stylex-font-family. ENDIF. IF complete_stylex-font-italic = abap_true. stylemapping-complete_style-font-italic = complete_style-font-italic. stylemapping-complete_stylex-font-italic = complete_stylex-font-italic. ENDIF. IF complete_stylex-font-name = abap_true. stylemapping-complete_style-font-name = complete_style-font-name. stylemapping-complete_stylex-font-name = complete_stylex-font-name. ENDIF. IF complete_stylex-font-scheme = abap_true. stylemapping-complete_style-font-scheme = complete_style-font-scheme. stylemapping-complete_stylex-font-scheme = complete_stylex-font-scheme. ENDIF. IF complete_stylex-font-size = abap_true. stylemapping-complete_style-font-size = complete_style-font-size. stylemapping-complete_stylex-font-size = complete_stylex-font-size. ENDIF. IF complete_stylex-font-strikethrough = abap_true. stylemapping-complete_style-font-strikethrough = complete_style-font-strikethrough. stylemapping-complete_stylex-font-strikethrough = complete_stylex-font-strikethrough. ENDIF. IF complete_stylex-font-underline = abap_true. stylemapping-complete_style-font-underline = complete_style-font-underline. stylemapping-complete_stylex-font-underline = complete_stylex-font-underline. ENDIF. IF complete_stylex-font-underline_mode = abap_true. stylemapping-complete_style-font-underline_mode = complete_style-font-underline_mode. stylemapping-complete_stylex-font-underline_mode = complete_stylex-font-underline_mode. ENDIF. IF complete_stylex-fill-filltype = abap_true. stylemapping-complete_style-fill-filltype = complete_style-fill-filltype. stylemapping-complete_stylex-fill-filltype = complete_stylex-fill-filltype. ENDIF. IF complete_stylex-fill-rotation = abap_true. stylemapping-complete_style-fill-rotation = complete_style-fill-rotation. stylemapping-complete_stylex-fill-rotation = complete_stylex-fill-rotation. ENDIF. IF complete_stylex-fill-fgcolor = abap_true. stylemapping-complete_style-fill-fgcolor = complete_style-fill-fgcolor. stylemapping-complete_stylex-fill-fgcolor = complete_stylex-fill-fgcolor. ENDIF. IF complete_stylex-fill-fgcolor-rgb = abap_true. stylemapping-complete_style-fill-fgcolor-rgb = complete_style-fill-fgcolor-rgb. stylemapping-complete_stylex-fill-fgcolor-rgb = complete_stylex-fill-fgcolor-rgb. ENDIF. IF complete_stylex-fill-fgcolor-indexed = abap_true. stylemapping-complete_style-fill-fgcolor-indexed = complete_style-fill-fgcolor-indexed. stylemapping-complete_stylex-fill-fgcolor-indexed = complete_stylex-fill-fgcolor-indexed. ENDIF. IF complete_stylex-fill-fgcolor-theme = abap_true. stylemapping-complete_style-fill-fgcolor-theme = complete_style-fill-fgcolor-theme. stylemapping-complete_stylex-fill-fgcolor-theme = complete_stylex-fill-fgcolor-theme. ENDIF. IF complete_stylex-fill-fgcolor-tint = abap_true. stylemapping-complete_style-fill-fgcolor-tint = complete_style-fill-fgcolor-tint. stylemapping-complete_stylex-fill-fgcolor-tint = complete_stylex-fill-fgcolor-tint. ENDIF. IF complete_stylex-fill-bgcolor = abap_true. stylemapping-complete_style-fill-bgcolor = complete_style-fill-bgcolor. stylemapping-complete_stylex-fill-bgcolor = complete_stylex-fill-bgcolor. ENDIF. IF complete_stylex-fill-bgcolor-rgb = abap_true. stylemapping-complete_style-fill-bgcolor-rgb = complete_style-fill-bgcolor-rgb. stylemapping-complete_stylex-fill-bgcolor-rgb = complete_stylex-fill-bgcolor-rgb. ENDIF. IF complete_stylex-fill-bgcolor-indexed = abap_true. stylemapping-complete_style-fill-bgcolor-indexed = complete_style-fill-bgcolor-indexed. stylemapping-complete_stylex-fill-bgcolor-indexed = complete_stylex-fill-bgcolor-indexed. ENDIF. IF complete_stylex-fill-bgcolor-theme = abap_true. stylemapping-complete_style-fill-bgcolor-theme = complete_style-fill-bgcolor-theme. stylemapping-complete_stylex-fill-bgcolor-theme = complete_stylex-fill-bgcolor-theme. ENDIF. IF complete_stylex-fill-bgcolor-tint = abap_true. stylemapping-complete_style-fill-bgcolor-tint = complete_style-fill-bgcolor-tint. stylemapping-complete_stylex-fill-bgcolor-tint = complete_stylex-fill-bgcolor-tint. ENDIF. IF complete_stylex-fill-gradtype-type = abap_true. stylemapping-complete_style-fill-gradtype-type = complete_style-fill-gradtype-type. stylemapping-complete_stylex-fill-gradtype-type = complete_stylex-fill-gradtype-type. ENDIF. IF complete_stylex-fill-gradtype-degree = abap_true. stylemapping-complete_style-fill-gradtype-degree = complete_style-fill-gradtype-degree. stylemapping-complete_stylex-fill-gradtype-degree = complete_stylex-fill-gradtype-degree. ENDIF. IF complete_stylex-fill-gradtype-bottom = abap_true. stylemapping-complete_style-fill-gradtype-bottom = complete_style-fill-gradtype-bottom. stylemapping-complete_stylex-fill-gradtype-bottom = complete_stylex-fill-gradtype-bottom. ENDIF. IF complete_stylex-fill-gradtype-left = abap_true. stylemapping-complete_style-fill-gradtype-left = complete_style-fill-gradtype-left. stylemapping-complete_stylex-fill-gradtype-left = complete_stylex-fill-gradtype-left. ENDIF. IF complete_stylex-fill-gradtype-top = abap_true. stylemapping-complete_style-fill-gradtype-top = complete_style-fill-gradtype-top. stylemapping-complete_stylex-fill-gradtype-top = complete_stylex-fill-gradtype-top. ENDIF. IF complete_stylex-fill-gradtype-right = abap_true. stylemapping-complete_style-fill-gradtype-right = complete_style-fill-gradtype-right. stylemapping-complete_stylex-fill-gradtype-right = complete_stylex-fill-gradtype-right. ENDIF. IF complete_stylex-fill-gradtype-position1 = abap_true. stylemapping-complete_style-fill-gradtype-position1 = complete_style-fill-gradtype-position1. stylemapping-complete_stylex-fill-gradtype-position1 = complete_stylex-fill-gradtype-position1. ENDIF. IF complete_stylex-fill-gradtype-position2 = abap_true. stylemapping-complete_style-fill-gradtype-position2 = complete_style-fill-gradtype-position2. stylemapping-complete_stylex-fill-gradtype-position2 = complete_stylex-fill-gradtype-position2. ENDIF. IF complete_stylex-fill-gradtype-position3 = abap_true. stylemapping-complete_style-fill-gradtype-position3 = complete_style-fill-gradtype-position3. stylemapping-complete_stylex-fill-gradtype-position3 = complete_stylex-fill-gradtype-position3. ENDIF. IF complete_stylex-borders-diagonal_mode = abap_true. stylemapping-complete_style-borders-diagonal_mode = complete_style-borders-diagonal_mode. stylemapping-complete_stylex-borders-diagonal_mode = complete_stylex-borders-diagonal_mode. ENDIF. IF complete_stylex-alignment-horizontal = abap_true. stylemapping-complete_style-alignment-horizontal = complete_style-alignment-horizontal. stylemapping-complete_stylex-alignment-horizontal = complete_stylex-alignment-horizontal. ENDIF. IF complete_stylex-alignment-vertical = abap_true. stylemapping-complete_style-alignment-vertical = complete_style-alignment-vertical. stylemapping-complete_stylex-alignment-vertical = complete_stylex-alignment-vertical. ENDIF. IF complete_stylex-alignment-textrotation = abap_true. stylemapping-complete_style-alignment-textrotation = complete_style-alignment-textrotation. stylemapping-complete_stylex-alignment-textrotation = complete_stylex-alignment-textrotation. ENDIF. IF complete_stylex-alignment-wraptext = abap_true. stylemapping-complete_style-alignment-wraptext = complete_style-alignment-wraptext. stylemapping-complete_stylex-alignment-wraptext = complete_stylex-alignment-wraptext. ENDIF. IF complete_stylex-alignment-shrinktofit = abap_true. stylemapping-complete_style-alignment-shrinktofit = complete_style-alignment-shrinktofit. stylemapping-complete_stylex-alignment-shrinktofit = complete_stylex-alignment-shrinktofit. ENDIF. IF complete_stylex-alignment-indent = abap_true. stylemapping-complete_style-alignment-indent = complete_style-alignment-indent. stylemapping-complete_stylex-alignment-indent = complete_stylex-alignment-indent. ENDIF. IF complete_stylex-protection-hidden = abap_true. stylemapping-complete_style-protection-hidden = complete_style-protection-hidden. stylemapping-complete_stylex-protection-hidden = complete_stylex-protection-hidden. ENDIF. IF complete_stylex-protection-locked = abap_true. stylemapping-complete_style-protection-locked = complete_style-protection-locked. stylemapping-complete_stylex-protection-locked = complete_stylex-protection-locked. ENDIF. IF complete_stylex-borders-allborders-border_style = abap_true. stylemapping-complete_style-borders-allborders-border_style = complete_style-borders-allborders-border_style. stylemapping-complete_stylex-borders-allborders-border_style = complete_stylex-borders-allborders-border_style. ENDIF. IF complete_stylex-borders-allborders-border_color-rgb = abap_true. stylemapping-complete_style-borders-allborders-border_color-rgb = complete_style-borders-allborders-border_color-rgb. stylemapping-complete_stylex-borders-allborders-border_color-rgb = complete_stylex-borders-allborders-border_color-rgb. ENDIF. IF complete_stylex-borders-allborders-border_color-indexed = abap_true. stylemapping-complete_style-borders-allborders-border_color-indexed = complete_style-borders-allborders-border_color-indexed. stylemapping-complete_stylex-borders-allborders-border_color-indexed = complete_stylex-borders-allborders-border_color-indexed. ENDIF. IF complete_stylex-borders-allborders-border_color-theme = abap_true. stylemapping-complete_style-borders-allborders-border_color-theme = complete_style-borders-allborders-border_color-theme. stylemapping-complete_stylex-borders-allborders-border_color-theme = complete_stylex-borders-allborders-border_color-theme. ENDIF. IF complete_stylex-borders-allborders-border_color-tint = abap_true. stylemapping-complete_style-borders-allborders-border_color-tint = complete_style-borders-allborders-border_color-tint. stylemapping-complete_stylex-borders-allborders-border_color-tint = complete_stylex-borders-allborders-border_color-tint. ENDIF. IF complete_stylex-borders-diagonal-border_style = abap_true. stylemapping-complete_style-borders-diagonal-border_style = complete_style-borders-diagonal-border_style. stylemapping-complete_stylex-borders-diagonal-border_style = complete_stylex-borders-diagonal-border_style. ENDIF. IF complete_stylex-borders-diagonal-border_color-rgb = abap_true. stylemapping-complete_style-borders-diagonal-border_color-rgb = complete_style-borders-diagonal-border_color-rgb. stylemapping-complete_stylex-borders-diagonal-border_color-rgb = complete_stylex-borders-diagonal-border_color-rgb. ENDIF. IF complete_stylex-borders-diagonal-border_color-indexed = abap_true. stylemapping-complete_style-borders-diagonal-border_color-indexed = complete_style-borders-diagonal-border_color-indexed. stylemapping-complete_stylex-borders-diagonal-border_color-indexed = complete_stylex-borders-diagonal-border_color-indexed. ENDIF. IF complete_stylex-borders-diagonal-border_color-theme = abap_true. stylemapping-complete_style-borders-diagonal-border_color-theme = complete_style-borders-diagonal-border_color-theme. stylemapping-complete_stylex-borders-diagonal-border_color-theme = complete_stylex-borders-diagonal-border_color-theme. ENDIF. IF complete_stylex-borders-diagonal-border_color-tint = abap_true. stylemapping-complete_style-borders-diagonal-border_color-tint = complete_style-borders-diagonal-border_color-tint. stylemapping-complete_stylex-borders-diagonal-border_color-tint = complete_stylex-borders-diagonal-border_color-tint. ENDIF. IF complete_stylex-borders-down-border_style = abap_true. stylemapping-complete_style-borders-down-border_style = complete_style-borders-down-border_style. stylemapping-complete_stylex-borders-down-border_style = complete_stylex-borders-down-border_style. ENDIF. IF complete_stylex-borders-down-border_color-rgb = abap_true. stylemapping-complete_style-borders-down-border_color-rgb = complete_style-borders-down-border_color-rgb. stylemapping-complete_stylex-borders-down-border_color-rgb = complete_stylex-borders-down-border_color-rgb. ENDIF. IF complete_stylex-borders-down-border_color-indexed = abap_true. stylemapping-complete_style-borders-down-border_color-indexed = complete_style-borders-down-border_color-indexed. stylemapping-complete_stylex-borders-down-border_color-indexed = complete_stylex-borders-down-border_color-indexed. ENDIF. IF complete_stylex-borders-down-border_color-theme = abap_true. stylemapping-complete_style-borders-down-border_color-theme = complete_style-borders-down-border_color-theme. stylemapping-complete_stylex-borders-down-border_color-theme = complete_stylex-borders-down-border_color-theme. ENDIF. IF complete_stylex-borders-down-border_color-tint = abap_true. stylemapping-complete_style-borders-down-border_color-tint = complete_style-borders-down-border_color-tint. stylemapping-complete_stylex-borders-down-border_color-tint = complete_stylex-borders-down-border_color-tint. ENDIF. IF complete_stylex-borders-left-border_style = abap_true. stylemapping-complete_style-borders-left-border_style = complete_style-borders-left-border_style. stylemapping-complete_stylex-borders-left-border_style = complete_stylex-borders-left-border_style. ENDIF. IF complete_stylex-borders-left-border_color-rgb = abap_true. stylemapping-complete_style-borders-left-border_color-rgb = complete_style-borders-left-border_color-rgb. stylemapping-complete_stylex-borders-left-border_color-rgb = complete_stylex-borders-left-border_color-rgb. ENDIF. IF complete_stylex-borders-left-border_color-indexed = abap_true. stylemapping-complete_style-borders-left-border_color-indexed = complete_style-borders-left-border_color-indexed. stylemapping-complete_stylex-borders-left-border_color-indexed = complete_stylex-borders-left-border_color-indexed. ENDIF. IF complete_stylex-borders-left-border_color-theme = abap_true. stylemapping-complete_style-borders-left-border_color-theme = complete_style-borders-left-border_color-theme. stylemapping-complete_stylex-borders-left-border_color-theme = complete_stylex-borders-left-border_color-theme. ENDIF. IF complete_stylex-borders-left-border_color-tint = abap_true. stylemapping-complete_style-borders-left-border_color-tint = complete_style-borders-left-border_color-tint. stylemapping-complete_stylex-borders-left-border_color-tint = complete_stylex-borders-left-border_color-tint. ENDIF. IF complete_stylex-borders-right-border_style = abap_true. stylemapping-complete_style-borders-right-border_style = complete_style-borders-right-border_style. stylemapping-complete_stylex-borders-right-border_style = complete_stylex-borders-right-border_style. ENDIF. IF complete_stylex-borders-right-border_color-rgb = abap_true. stylemapping-complete_style-borders-right-border_color-rgb = complete_style-borders-right-border_color-rgb. stylemapping-complete_stylex-borders-right-border_color-rgb = complete_stylex-borders-right-border_color-rgb. ENDIF. IF complete_stylex-borders-right-border_color-indexed = abap_true. stylemapping-complete_style-borders-right-border_color-indexed = complete_style-borders-right-border_color-indexed. stylemapping-complete_stylex-borders-right-border_color-indexed = complete_stylex-borders-right-border_color-indexed. ENDIF. IF complete_stylex-borders-right-border_color-theme = abap_true. stylemapping-complete_style-borders-right-border_color-theme = complete_style-borders-right-border_color-theme. stylemapping-complete_stylex-borders-right-border_color-theme = complete_stylex-borders-right-border_color-theme. ENDIF. IF complete_stylex-borders-right-border_color-tint = abap_true. stylemapping-complete_style-borders-right-border_color-tint = complete_style-borders-right-border_color-tint. stylemapping-complete_stylex-borders-right-border_color-tint = complete_stylex-borders-right-border_color-tint. ENDIF. IF complete_stylex-borders-top-border_style = abap_true. stylemapping-complete_style-borders-top-border_style = complete_style-borders-top-border_style. stylemapping-complete_stylex-borders-top-border_style = complete_stylex-borders-top-border_style. ENDIF. IF complete_stylex-borders-top-border_color-rgb = abap_true. stylemapping-complete_style-borders-top-border_color-rgb = complete_style-borders-top-border_color-rgb. stylemapping-complete_stylex-borders-top-border_color-rgb = complete_stylex-borders-top-border_color-rgb. ENDIF. IF complete_stylex-borders-top-border_color-indexed = abap_true. stylemapping-complete_style-borders-top-border_color-indexed = complete_style-borders-top-border_color-indexed. stylemapping-complete_stylex-borders-top-border_color-indexed = complete_stylex-borders-top-border_color-indexed. ENDIF. IF complete_stylex-borders-top-border_color-theme = abap_true. stylemapping-complete_style-borders-top-border_color-theme = complete_style-borders-top-border_color-theme. stylemapping-complete_stylex-borders-top-border_color-theme = complete_stylex-borders-top-border_color-theme. ENDIF. IF complete_stylex-borders-top-border_color-tint = abap_true. stylemapping-complete_style-borders-top-border_color-tint = complete_style-borders-top-border_color-tint. stylemapping-complete_stylex-borders-top-border_color-tint = complete_stylex-borders-top-border_color-tint. ENDIF. * Now we have a completly filled styles. * This can be used to get the guid * Return guid if requested. Might be used if copy&paste of styles is requested ep_guid = me->excel->get_static_cellstyle_guid( ip_cstyle_complete = stylemapping-complete_style ip_cstylex_complete = stylemapping-complete_stylex ). lo_worksheet->set_cell_style( ip_column = ip_column ip_row = ip_row ip_style = ep_guid ). ENDMETHOD. METHOD zif_excel_style_changer~get_guid. result = excel->get_static_cellstyle_guid( ip_cstyle_complete = complete_style ip_cstylex_complete = complete_stylex ). ENDMETHOD. METHOD zif_excel_style_changer~set_font_size. complete_style-font-size = value. complete_stylex-font-size = abap_true. single_change_requested-font-size = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_number_format. complete_style-number_format-format_code = value. complete_stylex-number_format-format_code = abap_true. single_change_requested-number_format-format_code = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete. complete_style = ip_complete. complete_stylex = ip_xcomplete. multiple_change_requested-complete = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_font. DATA: fontx TYPE zexcel_s_cstylex_font. IF ip_xfont IS SUPPLIED. fontx = ip_xfont. ELSE. * Only supplied values should be used - exception: Flags bold and italic strikethrough underline MOVE 'X' TO: fontx-bold, fontx-italic, fontx-strikethrough, fontx-underline_mode. CLEAR fontx-color WITH 'X'. clear_initial_colorxfields( EXPORTING is_color = ip_font-color CHANGING cs_xcolor = fontx-color ). IF ip_font-family IS NOT INITIAL. fontx-family = 'X'. ENDIF. IF ip_font-name IS NOT INITIAL. fontx-name = 'X'. ENDIF. IF ip_font-scheme IS NOT INITIAL. fontx-scheme = 'X'. ENDIF. IF ip_font-size IS NOT INITIAL. fontx-size = 'X'. ENDIF. IF ip_font-underline_mode IS NOT INITIAL. fontx-underline_mode = 'X'. ENDIF. ENDIF. complete_style-font = ip_font. complete_stylex-font = fontx. multiple_change_requested-font = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_fill. DATA: fillx LIKE ip_xfill. IF ip_xfill IS SUPPLIED. fillx = ip_xfill. ELSE. CLEAR fillx WITH 'X'. IF ip_fill-filltype IS INITIAL. CLEAR fillx-filltype. ENDIF. clear_initial_colorxfields( EXPORTING is_color = ip_fill-fgcolor CHANGING cs_xcolor = fillx-fgcolor ). clear_initial_colorxfields( EXPORTING is_color = ip_fill-bgcolor CHANGING cs_xcolor = fillx-bgcolor ). ENDIF. complete_style-fill = ip_fill. complete_stylex-fill = fillx. multiple_change_requested-fill = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders. DATA: bordersx LIKE ip_xborders. IF ip_xborders IS SUPPLIED. bordersx = ip_xborders. ELSE. CLEAR bordersx WITH 'X'. IF ip_borders-allborders-border_style IS INITIAL. CLEAR bordersx-allborders-border_style. ENDIF. IF ip_borders-diagonal-border_style IS INITIAL. CLEAR bordersx-diagonal-border_style. ENDIF. IF ip_borders-down-border_style IS INITIAL. CLEAR bordersx-down-border_style. ENDIF. IF ip_borders-left-border_style IS INITIAL. CLEAR bordersx-left-border_style. ENDIF. IF ip_borders-right-border_style IS INITIAL. CLEAR bordersx-right-border_style. ENDIF. IF ip_borders-top-border_style IS INITIAL. CLEAR bordersx-top-border_style. ENDIF. clear_initial_colorxfields( EXPORTING is_color = ip_borders-allborders-border_color CHANGING cs_xcolor = bordersx-allborders-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-diagonal-border_color CHANGING cs_xcolor = bordersx-diagonal-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-down-border_color CHANGING cs_xcolor = bordersx-down-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-left-border_color CHANGING cs_xcolor = bordersx-left-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-right-border_color CHANGING cs_xcolor = bordersx-right-border_color ). clear_initial_colorxfields( EXPORTING is_color = ip_borders-top-border_color CHANGING cs_xcolor = bordersx-top-border_color ). ENDIF. complete_style-borders = ip_borders. complete_stylex-borders = bordersx. multiple_change_requested-borders-complete = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_alignment. DATA: alignmentx LIKE ip_xalignment. IF ip_xalignment IS SUPPLIED. alignmentx = ip_xalignment. ELSE. CLEAR alignmentx WITH 'X'. IF ip_alignment-horizontal IS INITIAL. CLEAR alignmentx-horizontal. ENDIF. IF ip_alignment-vertical IS INITIAL. CLEAR alignmentx-vertical. ENDIF. ENDIF. complete_style-alignment = ip_alignment . complete_stylex-alignment = alignmentx . multiple_change_requested-alignment = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_protection. MOVE-CORRESPONDING ip_protection TO complete_style-protection. IF ip_xprotection IS SUPPLIED. MOVE-CORRESPONDING ip_xprotection TO complete_stylex-protection. ELSE. IF ip_protection-hidden IS NOT INITIAL. complete_stylex-protection-hidden = 'X'. ENDIF. IF ip_protection-locked IS NOT INITIAL. complete_stylex-protection-locked = 'X'. ENDIF. ENDIF. multiple_change_requested-protection = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_all. * lv_border_supplied = boolc( ip_borders_allborders IS SUPPLIED ). lv_xborder_supplied = boolc( ip_xborders_allborders IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_allborders iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_allborders CHANGING cs_complete_style_border = complete_style-borders-allborders cs_complete_stylex_border = complete_stylex-borders-allborders ). multiple_change_requested-borders-allborders = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_diagonal. lv_xborder_supplied = boolc( ip_xborders_diagonal IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_diagonal iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_diagonal CHANGING cs_complete_style_border = complete_style-borders-diagonal cs_complete_stylex_border = complete_stylex-borders-diagonal ). multiple_change_requested-borders-diagonal = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_down. lv_xborder_supplied = boolc( ip_xborders_down IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_down iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_down CHANGING cs_complete_style_border = complete_style-borders-down cs_complete_stylex_border = complete_stylex-borders-down ). multiple_change_requested-borders-down = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_left. lv_xborder_supplied = boolc( ip_xborders_left IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_left iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_left CHANGING cs_complete_style_border = complete_style-borders-left cs_complete_stylex_border = complete_stylex-borders-left ). multiple_change_requested-borders-left = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_right. lv_xborder_supplied = boolc( ip_xborders_right IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_right iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_right CHANGING cs_complete_style_border = complete_style-borders-right cs_complete_stylex_border = complete_stylex-borders-right ). multiple_change_requested-borders-right = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_complete_borders_top. lv_xborder_supplied = boolc( ip_xborders_top IS SUPPLIED ). move_supplied_borders( EXPORTING iv_border_supplied = lv_border_supplied is_border = ip_borders_top iv_xborder_supplied = lv_xborder_supplied is_xborder = ip_xborders_top CHANGING cs_complete_style_border = complete_style-borders-top cs_complete_stylex_border = complete_stylex-borders-top ). multiple_change_requested-borders-top = abap_true. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_bold. complete_style-font-bold = value. complete_stylex-font-bold = 'X'. single_change_requested-font-bold = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color. complete_style-font-color = value. complete_stylex-font-color-rgb = 'X'. single_change_requested-font-color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_rgb. complete_style-font-color-rgb = value. complete_stylex-font-color-rgb = 'X'. single_change_requested-font-color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_indexed. complete_style-font-color-indexed = value. complete_stylex-font-color-indexed = 'X'. single_change_requested-font-color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_theme. complete_style-font-color-theme = value. complete_stylex-font-color-theme = 'X'. single_change_requested-font-color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_color_tint. complete_style-font-color-tint = value. complete_stylex-font-color-tint = 'X'. single_change_requested-font-color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_family. complete_style-font-family = value. complete_stylex-font-family = 'X'. single_change_requested-font-family = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_italic. complete_style-font-italic = value. complete_stylex-font-italic = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_name. complete_style-font-name = value. complete_stylex-font-name = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_scheme. complete_style-font-scheme = value. complete_stylex-font-scheme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_strikethrough. complete_style-font-strikethrough = value. complete_stylex-font-strikethrough = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_underline. complete_style-font-underline = value. complete_stylex-font-underline = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_font_underline_mode. complete_style-font-underline_mode = value. complete_stylex-font-underline_mode = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_filltype. complete_style-fill-filltype = value. complete_stylex-fill-filltype = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_rotation. complete_style-fill-rotation = value. complete_stylex-fill-rotation = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor. complete_style-fill-fgcolor = value. complete_stylex-fill-fgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_rgb. complete_style-fill-fgcolor-rgb = value. complete_stylex-fill-fgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_indexed. complete_style-fill-fgcolor-indexed = value. complete_stylex-fill-fgcolor-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_theme. complete_style-fill-fgcolor-theme = value. complete_stylex-fill-fgcolor-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_fgcolor_tint. complete_style-fill-fgcolor-tint = value. complete_stylex-fill-fgcolor-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor. complete_style-fill-bgcolor = value. complete_stylex-fill-bgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_rgb. complete_style-fill-bgcolor-rgb = value. complete_stylex-fill-bgcolor-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_indexed. complete_style-fill-bgcolor-indexed = value. complete_stylex-fill-bgcolor-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_theme. complete_style-fill-bgcolor-theme = value. complete_stylex-fill-bgcolor-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_bgcolor_tint. complete_style-fill-bgcolor-tint = value. complete_stylex-fill-bgcolor-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_type. complete_style-fill-gradtype-type = value. complete_stylex-fill-gradtype-type = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_degree. complete_style-fill-gradtype-degree = value. complete_stylex-fill-gradtype-degree = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_bottom. complete_style-fill-gradtype-bottom = value. complete_stylex-fill-gradtype-bottom = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_left. complete_style-fill-gradtype-left = value. complete_stylex-fill-gradtype-left = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_top. complete_style-fill-gradtype-top = value. complete_stylex-fill-gradtype-top = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_right. complete_style-fill-gradtype-right = value. complete_stylex-fill-gradtype-right = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_position1. complete_style-fill-gradtype-position1 = value. complete_stylex-fill-gradtype-position1 = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_position2. complete_style-fill-gradtype-position2 = value. complete_stylex-fill-gradtype-position2 = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_fill_gradtype_position3. complete_style-fill-gradtype-position3 = value. complete_stylex-fill-gradtype-position3 = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_mode. complete_style-borders-diagonal_mode = value. complete_stylex-borders-diagonal_mode = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_horizontal. complete_style-alignment-horizontal = value. complete_stylex-alignment-horizontal = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_vertical. complete_style-alignment-vertical = value. complete_stylex-alignment-vertical = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_textrotation. complete_style-alignment-textrotation = value. complete_stylex-alignment-textrotation = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_wraptext. complete_style-alignment-wraptext = value. complete_stylex-alignment-wraptext = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_shrinktofit. complete_style-alignment-shrinktofit = value. complete_stylex-alignment-shrinktofit = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_alignment_indent. complete_style-alignment-indent = value. complete_stylex-alignment-indent = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_protection_hidden. complete_style-protection-hidden = value. complete_stylex-protection-hidden = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_protection_locked. complete_style-protection-locked = value. complete_stylex-protection-locked = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allborders_style. complete_style-borders-allborders-border_style = value. complete_stylex-borders-allborders-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allborders_color. complete_style-borders-allborders-border_color = value. complete_stylex-borders-allborders-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_rgb. complete_style-borders-allborders-border_color-rgb = value. complete_stylex-borders-allborders-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_indexe. complete_style-borders-allborders-border_color-indexed = value. complete_stylex-borders-allborders-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_theme. complete_style-borders-allborders-border_color-theme = value. complete_stylex-borders-allborders-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_allbo_color_tint. complete_style-borders-allborders-border_color-tint = value. complete_stylex-borders-allborders-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_style. complete_style-borders-diagonal-border_style = value. complete_stylex-borders-diagonal-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color. complete_style-borders-diagonal-border_color = value. complete_stylex-borders-diagonal-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_rgb. complete_style-borders-diagonal-border_color-rgb = value. complete_stylex-borders-diagonal-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_ind. complete_style-borders-diagonal-border_color-indexed = value. complete_stylex-borders-diagonal-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_the. complete_style-borders-diagonal-border_color-theme = value. complete_stylex-borders-diagonal-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_diagonal_color_tin. complete_style-borders-diagonal-border_color-tint = value. complete_stylex-borders-diagonal-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_style. complete_style-borders-down-border_style = value. complete_stylex-borders-down-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color. complete_style-borders-down-border_color = value. complete_stylex-borders-down-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_rgb. complete_style-borders-down-border_color-rgb = value. complete_stylex-borders-down-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_indexed. complete_style-borders-down-border_color-indexed = value. complete_stylex-borders-down-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_theme. complete_style-borders-down-border_color-theme = value. complete_stylex-borders-down-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_down_color_tint. complete_style-borders-down-border_color-tint = value. complete_stylex-borders-down-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_style. complete_style-borders-left-border_style = value. complete_stylex-borders-left-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color. complete_style-borders-left-border_color = value. complete_stylex-borders-left-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_rgb. complete_style-borders-left-border_color-rgb = value. complete_stylex-borders-left-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_indexed. complete_style-borders-left-border_color-indexed = value. complete_stylex-borders-left-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_theme. complete_style-borders-left-border_color-theme = value. complete_stylex-borders-left-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_left_color_tint. complete_style-borders-left-border_color-tint = value. complete_stylex-borders-left-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_style. complete_style-borders-right-border_style = value. complete_stylex-borders-right-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color. complete_style-borders-right-border_color = value. complete_stylex-borders-right-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_rgb. complete_style-borders-right-border_color-rgb = value. complete_stylex-borders-right-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_indexe. complete_style-borders-right-border_color-indexed = value. complete_stylex-borders-right-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_theme. complete_style-borders-right-border_color-theme = value. complete_stylex-borders-right-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_right_color_tint. complete_style-borders-right-border_color-tint = value. complete_stylex-borders-right-border_color-tint = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_style. complete_style-borders-top-border_style = value. complete_stylex-borders-top-border_style = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color. complete_style-borders-top-border_color = value. complete_stylex-borders-top-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_rgb. complete_style-borders-top-border_color-rgb = value. complete_stylex-borders-top-border_color-rgb = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_indexed. complete_style-borders-top-border_color-indexed = value. complete_stylex-borders-top-border_color-indexed = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_theme. complete_style-borders-top-border_color-theme = value. complete_stylex-borders-top-border_color-theme = 'X'. result = me. ENDMETHOD. METHOD zif_excel_style_changer~set_borders_top_color_tint. complete_style-borders-top-border_color-tint = value. complete_stylex-borders-top-border_color-tint = 'X'. result = me. ENDMETHOD. ENDCLASS. ",12468,True,3344.407744417892,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 = '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 }| ). 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 = '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 ). 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_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_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_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 iv_only_favorites = abap_true ) ). 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. ",12475,True,2624.557364491662,median "******************************************************************************** *&---------------------------------------------------------------------* *&--> Author : ZONBAS--(ZAFER ONBAŞ / Itelligence TR)----------------* *&--> Date : 09.11.2015 10:14:38-----------------------------------* *&--> Title : OLE2_OBJECT Utility Class-----------------------------* *&---------------------------------------------------------------------* ******************************************************************************** * The MIT License (MIT) * * Copyright (c) 2017 Zafer Onbaş * * 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. ******************************************************************************** CLASS zcl_ole2_object DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. TYPES: BEGIN OF gty_st_string, val TYPE string, END OF gty_st_string . TYPES: BEGIN OF gty_st_char255, val TYPE char255, END OF gty_st_char255 . TYPES: gty_tt_char255 TYPE STANDARD TABLE OF gty_st_char255 . TYPES: gty_tt_string TYPE STANDARD TABLE OF gty_st_string . TYPES: gty_tt_char1500 TYPE STANDARD TABLE OF char1500 . CONSTANTS c_col_black TYPE i VALUE 0 ##NO_TEXT. CONSTANTS c_col_white TYPE i VALUE 16777215 ##NO_TEXT. CONSTANTS c_col_red TYPE i VALUE 255 ##NO_TEXT. CONSTANTS c_col_green TYPE i VALUE 5287936 ##NO_TEXT. CONSTANTS c_col_blue TYPE i VALUE 12611584 ##NO_TEXT. CONSTANTS c_col_yellow TYPE i VALUE 65535 ##NO_TEXT. CONSTANTS c_col_orange TYPE i VALUE 49407 ##NO_TEXT. CONSTANTS c_ha_left TYPE i VALUE -4131 ##NO_TEXT. CONSTANTS c_a_center TYPE i VALUE -4108 ##NO_TEXT. CONSTANTS c_ha_right TYPE i VALUE -4152 ##NO_TEXT. CONSTANTS c_va_top TYPE i VALUE -4160 ##NO_TEXT. CONSTANTS c_va_bottom TYPE i VALUE -4107 ##NO_TEXT. CONSTANTS c_ori_portrait TYPE i VALUE 1 ##NO_TEXT. CONSTANTS c_ori_landscape TYPE i VALUE 2 ##NO_TEXT. CONSTANTS c_ul_none TYPE i VALUE -4142 ##NO_TEXT. CONSTANTS c_ul_single TYPE i VALUE 2 ##NO_TEXT. CONSTANTS c_ul_double TYPE i VALUE -4119 ##NO_TEXT. METHODS constructor IMPORTING !i_visible TYPE i DEFAULT 1 !i_wsname TYPE char30 DEFAULT 'Sheet1' !i_wbname TYPE char30 DEFAULT 'Book1' !i_path TYPE string OPTIONAL !i_mode TYPE char1 DEFAULT 'C' EXCEPTIONS empty_path missing_filename . METHODS add_header_via_fcat IMPORTING !it_fcat TYPE lvc_t_fcat . METHODS add_line IMPORTING !is_line TYPE any !i_fcat TYPE char1 OPTIONAL . METHODS add_line_via_tab IMPORTING !it_table TYPE gty_tt_string . METHODS add_lines_via_tab IMPORTING !it_table TYPE ANY TABLE !i_fcat TYPE char1 OPTIONAL . METHODS set_format IMPORTING !i_bgnrow TYPE i !i_bgncol TYPE i !i_endrow TYPE i !i_endcol TYPE i !i_fname TYPE string OPTIONAL !i_fcolor TYPE i OPTIONAL !i_fbold TYPE i OPTIONAL !i_fsize TYPE dec5_2 OPTIONAL !i_fitlc TYPE i OPTIONAL !i_fuline TYPE i OPTIONAL !i_bcolor TYPE i OPTIONAL !i_merge TYPE char1 OPTIONAL !i_nfdec TYPE char255 OPTIONAL . METHODS set_border IMPORTING !i_bgnrow TYPE i !i_bgncol TYPE i !i_endrow TYPE i !i_endcol TYPE i !i_trbli TYPE char5 . METHODS set_alignment IMPORTING !i_bgnrow TYPE i !i_bgncol TYPE i !i_endrow TYPE i !i_endcol TYPE i !i_halign TYPE i OPTIONAL !i_valign TYPE i OPTIONAL !i_wraptx TYPE char1 OPTIONAL !i_orient TYPE i OPTIONAL . METHODS set_autofill IMPORTING !i_src_bgnrow TYPE i !i_src_bgncol TYPE i !i_src_endrow TYPE i !i_src_endcol TYPE i !i_des_bgnrow TYPE i !i_des_bgncol TYPE i !i_des_endrow TYPE i !i_des_endcol TYPE i . METHODS set_autofit IMPORTING !i_col TYPE char10 OPTIONAL !i_row TYPE char10 OPTIONAL . METHODS set_col_width IMPORTING !i_col TYPE char10 OPTIONAL !i_width TYPE dec5_2 . METHODS set_row_height IMPORTING !i_row TYPE char10 OPTIONAL !i_height TYPE dec5_2 . METHODS set_pagesetup IMPORTING !i_fittopageswide TYPE i DEFAULT 1 !i_fittopagestall TYPE i DEFAULT 1 !i_topmargin TYPE dec5_2 OPTIONAL !i_rightmargin TYPE dec5_2 OPTIONAL !i_bottommargin TYPE dec5_2 OPTIONAL !i_leftmargin TYPE dec5_2 OPTIONAL !i_headermargin TYPE dec5_2 OPTIONAL !i_footermargin TYPE dec5_2 OPTIONAL !i_orientation TYPE i DEFAULT c_ori_portrait . METHODS set_image IMPORTING !i_path TYPE string !i_left TYPE i !i_top TYPE i !i_width TYPE i !i_height TYPE i . METHODS set_value IMPORTING !i_row TYPE i !i_col TYPE i !i_value TYPE simple . METHODS get_value IMPORTING !i_row TYPE i !i_col TYPE i RETURNING VALUE(r_value) TYPE char1500 . METHODS get_row_count RETURNING VALUE(e_count) TYPE i . METHODS get_app_object RETURNING VALUE(r_application) TYPE ole2_object . METHODS clipboard_export IMPORTING !i_row TYPE i !i_col TYPE i . METHODS save_document IMPORTING !i_visible TYPE i DEFAULT 1 !i_compcheck TYPE i DEFAULT 0 !i_replacefile TYPE i DEFAULT 1 . METHODS clear_clipboard . METHODS free IMPORTING !i_force TYPE char1 DEFAULT 'X' . METHODS print . PROTECTED SECTION. PRIVATE SECTION. TYPES: gty_dec_16_13 TYPE p LENGTH 16 DECIMALS 13 . CONSTANTS c_rs_r1c1 TYPE i VALUE -4150 ##NO_TEXT. CONSTANTS c_rs_a1 TYPE i VALUE 1 ##NO_TEXT. CONSTANTS c_ws_minimized TYPE i VALUE -4140 ##NO_TEXT. CONSTANTS c_ws_normal TYPE i VALUE -4143 ##NO_TEXT. CONSTANTS c_ws_maximized TYPE i VALUE -4137 ##NO_TEXT. DATA application TYPE ole2_object . DATA workbook TYPE ole2_object . DATA workbooks TYPE ole2_object . DATA worksheet TYPE ole2_object . DATA worksheets TYPE ole2_object . DATA path TYPE string . DATA gt_data TYPE gty_tt_char1500 . DATA gs_data TYPE char1500 . DATA t_fcat TYPE lvc_t_fcat . METHODS create_object IMPORTING !i_visible TYPE i !i_wsname TYPE char30 !i_mode TYPE char1 DEFAULT 'C' . METHODS conv_cm2inch IMPORTING !i_input TYPE dec5_2 RETURNING VALUE(r_output) TYPE gty_dec_16_13 . METHODS writeline IMPORTING !io_abap_typedescr TYPE REF TO cl_abap_typedescr !iv_val TYPE any . ENDCLASS. CLASS ZCL_OLE2_OBJECT IMPLEMENTATION. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->ADD_HEADER_VIA_FCAT * +-------------------------------------------------------------------------------------------------+ * | [--->] IT_FCAT TYPE LVC_T_FCAT * +-------------------------------------------------------------------------------------- METHOD add_header_via_fcat. ************************************************************************ * @Importing@ IT_FCAT -> Field Catalog for List Viewer Control ************************************************************************ DATA: ls_fcat TYPE lvc_s_fcat, lt_lines TYPE gty_tt_string, ls_lines TYPE gty_st_string. "" fcat t_fcat = it_fcat. ""*- LOOP AT it_fcat INTO ls_fcat. IF ls_fcat-reptext IS NOT INITIAL. ls_lines-val = ls_fcat-reptext. APPEND ls_lines TO lt_lines. ELSE. ls_lines-val = ls_fcat-coltext. APPEND ls_lines TO lt_lines. ENDIF. CLEAR: ls_lines. ENDLOOP. "" Add line me->add_line_via_tab( it_table = lt_lines ). ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->ADD_LINE * +-------------------------------------------------------------------------------------------------+ * | [--->] IS_LINE TYPE ANY * | [--->] I_FCAT TYPE CHAR1(optional) * +-------------------------------------------------------------------------------------- METHOD add_line. ************************************************************************ * @Importing@ IS_LINE -> Line * @Importing@ I_FCAT -> Using field catalog match? ************************************************************************ DATA: lo_abap_typedescr TYPE REF TO cl_abap_typedescr, lv_counter TYPE i, ls_fcat TYPE lvc_s_fcat. FIELD-SYMBOLS: TYPE any. CLEAR gs_data. "" fcat IF i_fcat EQ 'X'. LOOP AT t_fcat INTO ls_fcat. ASSIGN COMPONENT ls_fcat-fieldname OF STRUCTURE is_line TO . IF sy-subrc IS NOT INITIAL. CONTINUE. ENDIF. "" getType lo_abap_typedescr = cl_abap_typedescr=>describe_by_data( p_data = ). "" Write line me->writeline( io_abap_typedescr = lo_abap_typedescr "" Runtime Type Services iv_val = "" Value ). ENDLOOP. ELSE. DO. "" check? ADD 1 TO lv_counter. ASSIGN COMPONENT lv_counter OF STRUCTURE is_line TO . IF sy-subrc NE 0. EXIT. ENDIF. "" getType lo_abap_typedescr = cl_abap_typedescr=>describe_by_data( p_data = ). "" Write line me->writeline( io_abap_typedescr = lo_abap_typedescr "" Runtime Type Services iv_val = "" Value ). ENDDO. ENDIF. ""*- SHIFT gs_data BY 1 PLACES LEFT. APPEND gs_data TO gt_data. CLEAR gs_data. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->ADD_LINES_VIA_TAB * +-------------------------------------------------------------------------------------------------+ * | [--->] IT_TABLE TYPE ANY TABLE * | [--->] I_FCAT TYPE CHAR1(optional) * +-------------------------------------------------------------------------------------- METHOD add_lines_via_tab. ************************************************************************ * @Importing@ IT_TABLE -> Table * @Importing@ I_FCAT -> Using field catalog match? ************************************************************************ FIELD-SYMBOLS: TYPE any. ""*- LOOP AT it_table ASSIGNING . me->add_line( is_line = i_fcat = i_fcat "" Using field catalog match? ). ENDLOOP. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->ADD_LINE_VIA_TAB * +-------------------------------------------------------------------------------------------------+ * | [--->] IT_TABLE TYPE GTY_TT_STRING * +-------------------------------------------------------------------------------------- METHOD add_line_via_tab. ************************************************************************ * @Importing@ IT_TABLE -> Table with Strings ************************************************************************ DATA: ls_string TYPE gty_st_string. ""*- CLEAR gs_data. LOOP AT it_table INTO ls_string. gs_data = gs_data && cl_abap_char_utilities=>horizontal_tab && ls_string-val. ENDLOOP. ""*- SHIFT gs_data BY 1 PLACES LEFT. APPEND gs_data TO gt_data. CLEAR gs_data. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->CLEAR_CLIPBOARD * +-------------------------------------------------------------------------------------------------+ * +-------------------------------------------------------------------------------------- METHOD clear_clipboard. CLEAR gt_data. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->CLIPBOARD_EXPORT * +-------------------------------------------------------------------------------------------------+ * | [--->] I_ROW TYPE I * | [--->] I_COL TYPE I * +-------------------------------------------------------------------------------------- METHOD clipboard_export. ************************************************************************ * @Importing@ I_ROW -> Row * @Importing@ I_COL -> Column ************************************************************************ DATA: lv_rc TYPE i, ls_cells TYPE ole2_object. "" Flush cl_gui_cfw=>flush( EXCEPTIONS cntl_system_error = 1 cntl_error = 2 OTHERS = 3 ). IF sy-subrc IS NOT INITIAL. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. "" Export cl_gui_frontend_services=>clipboard_export( IMPORTING data = gt_data CHANGING rc = lv_rc EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 no_authority = 4 OTHERS = 5 ). IF sy-subrc IS NOT INITIAL. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. "" Paste CALL METHOD OF worksheet 'Cells' = ls_cells EXPORTING #1 = i_row #2 = i_col. CALL METHOD OF ls_cells 'Select'. CALL METHOD OF worksheet 'Paste'. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->CONSTRUCTOR * +-------------------------------------------------------------------------------------------------+ * | [--->] I_VISIBLE TYPE I (default =1) * | [--->] I_WSNAME TYPE CHAR30 (default ='Sheet1') * | [--->] I_WBNAME TYPE CHAR30 (default ='Book1') * | [--->] I_PATH TYPE STRING(optional) * | [--->] I_MODE TYPE CHAR1 (default ='C') * | [EXC!] EMPTY_PATH * | [EXC!] MISSING_FILENAME * +-------------------------------------------------------------------------------------- METHOD constructor. ************************************************************************ * @Importing@ I_VISIBLE -> Visible? (1/0) * @Importing@ I_WSNAME -> Worksheet name * @Importing@ I_WBNAME -> Workbook name (Filename) * @Importing@ I_PATH -> Path for Open/Create file * @Importing@ I_MODE -> O:Open / C:Create * @Exception@ EMPTY_PATH -> File/Folder path is not selected * @Exception@ MISSING_FILENAME -> Filename is missing in path ************************************************************************ DATA: lv_visible TYPE i, lv_wsname TYPE text30, lv_wbname TYPE text30, lv_title TYPE string, lt_filetab TYPE filetable, lv_rc TYPE i. "" Path IF i_path IS INITIAL. CASE i_mode. WHEN 'O'. "" Open cl_gui_frontend_services=>file_open_dialog( EXPORTING default_extension = 'xlsx' "" Default Extension file_filter = 'Excel Workbook (*.xlsx)|*.xlsx|' && 'Excel 97-2003 Workbook (*.xls)|*.xls|' "" File Extension Filter String initial_directory = 'C:\\' "" Initial Directory multiselection = '' "" Multiple selections poss. CHANGING file_table = lt_filetab "" Table Holding Selected Files rc = lv_rc "" Return Code, Number of Files or -1 If Error Occurred EXCEPTIONS file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 not_supported_by_gui = 4 OTHERS = 5 ). IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ELSEIF lv_rc EQ 1. path = lt_filetab[ 1 ]-filename. ENDIF. WHEN 'C'. "" Create cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = 'C:\\' "" Start Browsing Here CHANGING selected_folder = path "" Folder Path Selected By User EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 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. ENDCASE. ELSE. path = i_path. ENDIF. "" check path? IF path IS INITIAL. MESSAGE 'File/Folder path is not selected'(001) TYPE 'E' RAISING empty_path. ENDIF. "" check if there is a filename in path or not? FIND ALL OCCURRENCES OF REGEX '[\\w,\\s-]+\\.[A-Za-z]{3,4}$' IN path MATCH COUNT sy-tabix. IF sy-subrc IS NOT INITIAL. IF i_mode EQ 'O'. MESSAGE 'Filename is missing in path'(002) TYPE 'E' RAISING missing_filename. ENDIF. "" Workbook name IF i_wbname IS INITIAL. lv_wbname = 'Book1'. ELSE. lv_wbname = i_wbname. ENDIF. path = path && '\\' && lv_wbname && '.xlsx'. REPLACE ALL OCCURRENCES OF '\\\\' IN path WITH '\\'. ENDIF. "" visible? IF i_visible NE 0 AND i_visible NE 1. lv_visible = 0. ELSE. lv_visible = i_visible. ENDIF. "" Worksheet name IF i_wsname IS INITIAL. lv_wsname = 'Sheet1'. ELSE. lv_wsname = i_wsname. ENDIF. "" Create object me->create_object( i_visible = lv_visible "" Visible? i_wsname = lv_wsname "" Worksheet Name i_mode = i_mode "" O:Open / C:Create ). ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Private Method ZCL_OLE2_OBJECT->CONV_CM2INCH * +-------------------------------------------------------------------------------------------------+ * | [--->] I_INPUT TYPE DEC5_2 * | [<-()] R_OUTPUT TYPE GTY_DEC_16_13 * +-------------------------------------------------------------------------------------- METHOD conv_cm2inch. ************************************************************************ * @Importing@ I_INPUT -> Input value (cm) * @Returning@ value( R_OUTPUT ) -> Output value (inch) ************************************************************************ "" Measurement unit conversion CALL FUNCTION 'UNIT_CONVERSION_SIMPLE' EXPORTING input = i_input "" Input Value unit_in = 'CM' "" Unit of input value unit_out = 'IN' "" Unit of output value IMPORTING output = r_output "" Output value EXCEPTIONS conversion_not_found = 1 division_by_zero = 2 input_invalid = 3 output_invalid = 4 overflow = 5 type_invalid = 6 units_missing = 7 unit_in_not_found = 8 unit_out_not_found = 9 OTHERS = 10. IF sy-subrc IS NOT INITIAL. r_output = 0. ENDIF. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Private Method ZCL_OLE2_OBJECT->CREATE_OBJECT * +-------------------------------------------------------------------------------------------------+ * | [--->] I_VISIBLE TYPE I * | [--->] I_WSNAME TYPE CHAR30 * | [--->] I_MODE TYPE CHAR1 (default ='C') * +-------------------------------------------------------------------------------------- METHOD create_object. ************************************************************************ * @Importing@ I_VISIBLE -> Visible? * @Importing@ I_WSNAME -> Worksheet name * @Importing@ I_MODE -> O:Open / C:Create ************************************************************************ "" Application CREATE OBJECT application 'Excel.Application'. "" Reference Style SET PROPERTY OF application 'ReferenceStyle' = c_rs_r1c1. "" Window State SET PROPERTY OF application 'WindowState' = c_ws_maximized. "" Workbooks CALL METHOD OF application 'Workbooks' = workbooks. IF i_mode EQ 'O'. "" Open workbook CALL METHOD OF workbooks 'Open' = workbook EXPORTING #1 = path. "" Save me->save_document( i_visible = i_visible i_compcheck = 0 i_replacefile = 1 ). ELSE. "" Create workbook CALL METHOD OF workbooks 'Add' = workbook. ENDIF. "" Visible? SET PROPERTY OF application 'Visible' = i_visible. "" Worksheet GET PROPERTY OF application 'ActiveSheet' = worksheet. SET PROPERTY OF worksheet 'Name' = i_wsname. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->FREE * +-------------------------------------------------------------------------------------------------+ * | [--->] I_FORCE TYPE CHAR1 (default ='X') * +-------------------------------------------------------------------------------------- METHOD free. ************************************************************************ * @Importing@ I_FORCE -> Force close ************************************************************************ "" Release & Free object IF i_force EQ 'X'. SET PROPERTY OF application 'DisplayAlerts ' = 0. ENDIF. ""*- CALL METHOD OF application 'Quit'. FREE OBJECT application. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->GET_APP_OBJECT * +-------------------------------------------------------------------------------------------------+ * | [<-()] R_APPLICATION TYPE OLE2_OBJECT * +-------------------------------------------------------------------------------------- METHOD get_app_object. ************************************************************************ * @Returning@ value( R_APPLICATION ) -> Application object ************************************************************************ r_application = application. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->GET_ROW_COUNT * +-------------------------------------------------------------------------------------------------+ * | [<-()] E_COUNT TYPE I * +-------------------------------------------------------------------------------------- METHOD get_row_count. ************************************************************************ * @Returning@ value( E_COUNT ) -> Row Count ************************************************************************ "" Clipboard table row count e_count = lines( gt_data ). ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->GET_VALUE * +-------------------------------------------------------------------------------------------------+ * | [--->] I_ROW TYPE I * | [--->] I_COL TYPE I * | [<-()] R_VALUE TYPE CHAR1500 * +-------------------------------------------------------------------------------------- METHOD get_value. ************************************************************************ * @Importing@ I_ROW -> Row * @Importing@ I_COL -> Column * @Returning@ R_VALUE -> Value ************************************************************************ DATA: ls_cells TYPE ole2_object. ""*- CALL METHOD OF worksheet 'Cells' = ls_cells EXPORTING #1 = i_row #2 = i_col. ""*- GET PROPERTY OF ls_cells 'Value' = r_value. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->PRINT * +-------------------------------------------------------------------------------------------------+ * +-------------------------------------------------------------------------------------- METHOD print. "" Print CALL METHOD OF worksheet 'PrintOut'. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SAVE_DOCUMENT * +-------------------------------------------------------------------------------------------------+ * | [--->] I_VISIBLE TYPE I (default =1) * | [--->] I_COMPCHECK TYPE I (default =0) * | [--->] I_REPLACEFILE TYPE I (default =1) * +-------------------------------------------------------------------------------------- METHOD save_document. ************************************************************************ * @Importing@ I_VISIBLE -> Show document after save (if created invisible) * @Importing@ I_COMPCHECK -> Compability check? * @Importing@ I_REPLACEFILE -> Replace file directly if found (no popup) ************************************************************************ DATA: ls_cells TYPE ole2_object, ls_activewb TYPE ole2_object. "" Force window state to get maximized ( min->max ) SET PROPERTY OF application 'WindowState' = c_ws_minimized. SET PROPERTY OF application 'WindowState' = c_ws_maximized. "" Alert Display IF i_replacefile EQ 0. SET PROPERTY OF application 'DisplayAlerts ' = 1. ELSE. SET PROPERTY OF application 'DisplayAlerts ' = 0. ENDIF. "" Compability check? CALL METHOD OF application 'ActiveWorkbook' = ls_activewb. SET PROPERTY OF ls_activewb 'CheckCompatibility' = i_compcheck. "" Set cursor to top CALL METHOD OF worksheet 'Cells' = ls_cells EXPORTING #1 = 1 #2 = 1. CALL METHOD OF ls_cells 'Select'. "" Visible? SET PROPERTY OF application 'Visible' = i_visible. "" SaveAs CALL METHOD OF workbook 'SaveAs' EXPORTING #1 = path. "" Alert Display (back to default setting) IF i_replacefile NE 0. SET PROPERTY OF application 'DisplayAlerts ' = 1. ENDIF. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_ALIGNMENT * +-------------------------------------------------------------------------------------------------+ * | [--->] I_BGNROW TYPE I * | [--->] I_BGNCOL TYPE I * | [--->] I_ENDROW TYPE I * | [--->] I_ENDCOL TYPE I * | [--->] I_HALIGN TYPE I(optional) * | [--->] I_VALIGN TYPE I(optional) * | [--->] I_WRAPTX TYPE CHAR1(optional) * | [--->] I_ORIENT TYPE I(optional) * +-------------------------------------------------------------------------------------- METHOD set_alignment. ************************************************************************ * @Importing@ I_BGNROW -> Begin row * @Importing@ I_BGNCOL -> Begin column * @Importing@ I_ENDROW -> End row * @Importing@ I_ENDCOL -> End column * @Importing@ I_HALIGN -> Horizontal align * @Importing@ I_VALIGN -> Vertical align * @Importing@ I_WRAPTX -> Wrap-text * @Importing@ I_ORIENT -> Text-Orientation (-90<=..<=90) ************************************************************************ DATA: ls_cellbgn TYPE ole2_object, ls_cellend TYPE ole2_object, ls_range TYPE ole2_object. "" Select All IF i_bgnrow EQ 0 AND i_bgncol EQ 0 AND i_endrow EQ 0 AND i_endcol EQ 0. CALL METHOD OF worksheet 'Cells' = ls_range. ELSE. "" Select Range CALL METHOD OF worksheet 'Cells' = ls_cellbgn EXPORTING #1 = i_bgnrow #2 = i_bgncol. CALL METHOD OF worksheet 'Cells' = ls_cellend EXPORTING #1 = i_endrow #2 = i_endcol. CALL METHOD OF worksheet 'Range' = ls_range EXPORTING #1 = ls_cellbgn #2 = ls_cellend. ENDIF. CALL METHOD OF ls_range 'Select'. "" Horizontal IF i_halign IS SUPPLIED. SET PROPERTY OF ls_range 'HorizontalAlignment' = i_halign. ENDIF. "" Vertical IF i_valign IS SUPPLIED. SET PROPERTY OF ls_range 'VerticalAlignment' = i_valign. ENDIF. "" Wrap text IF i_wraptx EQ 'X'. SET PROPERTY OF ls_range 'WrapText' = 1. ENDIF. "" Text-Orientation IF i_orient IS SUPPLIED AND i_orient GE -90 AND i_orient LE 90. SET PROPERTY OF ls_range 'Orientation' = i_orient. ENDIF. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_AUTOFILL * +-------------------------------------------------------------------------------------------------+ * | [--->] I_SRC_BGNROW TYPE I * | [--->] I_SRC_BGNCOL TYPE I * | [--->] I_SRC_ENDROW TYPE I * | [--->] I_SRC_ENDCOL TYPE I * | [--->] I_DES_BGNROW TYPE I * | [--->] I_DES_BGNCOL TYPE I * | [--->] I_DES_ENDROW TYPE I * | [--->] I_DES_ENDCOL TYPE I * +-------------------------------------------------------------------------------------- METHOD set_autofill. ************************************************************************ * @Importing@ I_SRC_BGNROW -> Source Begin row * @Importing@ I_SRC_BGNCOL -> Source Begin column * @Importing@ I_SRC_ENDROW -> Source End row * @Importing@ I_SRC_ENDCOL -> Source End column * @Importing@ I_DES_BGNROW -> Destination Begin row * @Importing@ I_DES_BGNCOL -> Destination Begin column * @Importing@ I_DES_ENDROW -> Destination End row * @Importing@ I_DES_ENDCOL -> Destination End column ************************************************************************ DATA: ls_cellbgn TYPE ole2_object, ls_cellend TYPE ole2_object, ls_src_range TYPE ole2_object, ls_des_range TYPE ole2_object. "" Select Source Range CALL METHOD OF worksheet 'Cells' = ls_cellbgn EXPORTING #1 = i_src_bgnrow #2 = i_src_bgncol. CALL METHOD OF worksheet 'Cells' = ls_cellend EXPORTING #1 = i_src_endrow #2 = i_src_endcol. CALL METHOD OF worksheet 'Range' = ls_src_range EXPORTING #1 = ls_cellbgn #2 = ls_cellend. "" Select Destination Range CALL METHOD OF worksheet 'Cells' = ls_cellbgn EXPORTING #1 = i_des_bgnrow #2 = i_des_bgncol. CALL METHOD OF worksheet 'Cells' = ls_cellend EXPORTING #1 = i_des_endrow #2 = i_des_endcol. CALL METHOD OF worksheet 'Range' = ls_des_range EXPORTING #1 = ls_cellbgn #2 = ls_cellend. "" AutoFill CALL METHOD OF ls_src_range 'AutoFill' EXPORTING #1 = ls_des_range #2 = 0. "" xlFillDefault ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_AUTOFIT * +-------------------------------------------------------------------------------------------------+ * | [--->] I_COL TYPE CHAR10(optional) * | [--->] I_ROW TYPE CHAR10(optional) * +-------------------------------------------------------------------------------------- METHOD set_autofit. ************************************************************************ * @Importing@ I_COL -> Column (ex:'2','B','A:DZ',''=All) * @Importing@ I_ROW -> Row (ex:'2','1:5',''=All) ************************************************************************ DATA: ls_columns TYPE ole2_object, ls_rows TYPE ole2_object. "" Column IF i_col IS NOT INITIAL. CALL METHOD OF worksheet 'Columns' = ls_columns EXPORTING #1 = i_col. ELSE. CALL METHOD OF worksheet 'Columns' = ls_columns. ENDIF. IF ls_columns IS NOT INITIAL. CALL METHOD OF ls_columns 'Autofit'. ENDIF. "" Row IF i_row IS NOT INITIAL. CALL METHOD OF worksheet 'Rows' = ls_rows EXPORTING #1 = i_row. ELSE. CALL METHOD OF worksheet 'Rows' = ls_rows. ENDIF. IF ls_rows IS NOT INITIAL. CALL METHOD OF ls_rows 'Autofit'. ENDIF. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_BORDER * +-------------------------------------------------------------------------------------------------+ * | [--->] I_BGNROW TYPE I * | [--->] I_BGNCOL TYPE I * | [--->] I_ENDROW TYPE I * | [--->] I_ENDCOL TYPE I * | [--->] I_TRBLI TYPE CHAR5 * +-------------------------------------------------------------------------------------- METHOD set_border. ************************************************************************ * @Importing@ I_BGNROW -> Begin row * @Importing@ I_BGNCOL -> Begin column * @Importing@ I_ENDROW -> End row * @Importing@ I_ENDCOL -> End column * @Importing@ I_TRBLI -> Top-Right-Bottom-Left-Inside (ex:01010) ************************************************************************ DATA: ls_cellbgn TYPE ole2_object, ls_cellend TYPE ole2_object, ls_range TYPE ole2_object, ls_borders TYPE ole2_object. "" Select All IF i_bgnrow EQ 0 AND i_bgncol EQ 0 AND i_endrow EQ 0 AND i_endcol EQ 0. CALL METHOD OF worksheet 'Cells' = ls_range. ELSE. "" Select Range CALL METHOD OF worksheet 'Cells' = ls_cellbgn EXPORTING #1 = i_bgnrow #2 = i_bgncol. CALL METHOD OF worksheet 'Cells' = ls_cellend EXPORTING #1 = i_endrow #2 = i_endcol. CALL METHOD OF worksheet 'Range' = ls_range EXPORTING #1 = ls_cellbgn #2 = ls_cellend. ENDIF. CALL METHOD OF ls_range 'Select'. "" Top IF i_trbli(1) NE ''. CALL METHOD OF ls_range 'Borders' = ls_borders EXPORTING #1 = '8'. "" xlEdgeTop SET PROPERTY OF ls_borders 'LineStyle' = i_trbli(1). ENDIF. "" Right IF i_trbli+1(1) NE ''. CALL METHOD OF ls_range 'Borders' = ls_borders EXPORTING #1 = '10'. ""xlEdgeRight SET PROPERTY OF ls_borders 'LineStyle' = i_trbli+1(1). ENDIF. "" Bottom IF i_trbli+2(1) NE ''. CALL METHOD OF ls_range 'Borders' = ls_borders EXPORTING #1 = '9'. ""xlEdgeBottom SET PROPERTY OF ls_borders 'LineStyle' = i_trbli+2(1). ENDIF. "" Left IF i_trbli+3(1) NE ''. CALL METHOD OF ls_range 'Borders' = ls_borders EXPORTING #1 = '7'. ""xlEdgeLeft SET PROPERTY OF ls_borders 'LineStyle' = i_trbli+3(1). ENDIF. "" Inside IF i_trbli+4(1) NE ''. "" Vertical CALL METHOD OF ls_range 'Borders' = ls_borders EXPORTING #1 = '11'. ""xlInsideVertical SET PROPERTY OF ls_borders 'LineStyle' = i_trbli+4(1). "" Horizontal CALL METHOD OF ls_range 'Borders' = ls_borders EXPORTING #1 = '12'. ""xlInsideHorizontal SET PROPERTY OF ls_borders 'LineStyle' = i_trbli+4(1). ENDIF. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_COL_WIDTH * +-------------------------------------------------------------------------------------------------+ * | [--->] I_COL TYPE CHAR10(optional) * | [--->] I_WIDTH TYPE DEC5_2 * +-------------------------------------------------------------------------------------- METHOD set_col_width. ************************************************************************ * @Importing@ I_COL -> Column (ex:'2','B','A:DZ',''=All) * @Importing@ I_WIDTH -> Width ************************************************************************ DATA: ls_columns TYPE ole2_object, lv_i TYPE i. FIELD-SYMBOLS TYPE any. ""*- IF i_col IS NOT INITIAL. TRY. "" Numeric conv. for single column lv_i = i_col. ASSIGN lv_i TO . CATCH cx_sy_conversion_no_number. ASSIGN i_col TO . ENDTRY. CALL METHOD OF worksheet 'Columns' = ls_columns EXPORTING #1 = . ELSE. CALL METHOD OF worksheet 'Columns' = ls_columns. ENDIF. ""*- SET PROPERTY OF ls_columns 'ColumnWidth' = i_width. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_FORMAT * +-------------------------------------------------------------------------------------------------+ * | [--->] I_BGNROW TYPE I * | [--->] I_BGNCOL TYPE I * | [--->] I_ENDROW TYPE I * | [--->] I_ENDCOL TYPE I * | [--->] I_FNAME TYPE STRING(optional) * | [--->] I_FCOLOR TYPE I(optional) * | [--->] I_FBOLD TYPE I(optional) * | [--->] I_FSIZE TYPE DEC5_2(optional) * | [--->] I_FITLC TYPE I(optional) * | [--->] I_FULINE TYPE I(optional) * | [--->] I_BCOLOR TYPE I(optional) * | [--->] I_MERGE TYPE CHAR1(optional) * | [--->] I_NFDEC TYPE CHAR255(optional) * +-------------------------------------------------------------------------------------- METHOD set_format. ************************************************************************ * @Importing@ I_BGNROW -> Begin row * @Importing@ I_BGNCOL -> Begin column * @Importing@ I_ENDROW -> End row * @Importing@ I_ENDCOL -> End column * @Importing@ I_FNAME -> Font name (family) * @Importing@ I_FCOLOR -> Font color * @Importing@ I_FBOLD -> Font bold * @Importing@ I_FSIZE -> Font size * @Importing@ I_FITLC -> Font italic * @Importing@ I_FULINE -> Font underline * @Importing@ I_BCOLOR -> Background color * @Importing@ I_MERGE -> Merge Cells * @Importing@ I_NFDEC -> Number format (ex:'0.00') ************************************************************************ DATA: ls_cellbgn TYPE ole2_object, ls_cellend TYPE ole2_object, ls_range TYPE ole2_object, ls_font TYPE ole2_object, ls_interior TYPE ole2_object. "" Select All IF i_bgnrow EQ 0 AND i_bgncol EQ 0 AND i_endrow EQ 0 AND i_endcol EQ 0. CALL METHOD OF worksheet 'Cells' = ls_range. ELSE. "" Select Range CALL METHOD OF worksheet 'Cells' = ls_cellbgn EXPORTING #1 = i_bgnrow #2 = i_bgncol. CALL METHOD OF worksheet 'Cells' = ls_cellend EXPORTING #1 = i_endrow #2 = i_endcol. CALL METHOD OF worksheet 'Range' = ls_range EXPORTING #1 = ls_cellbgn #2 = ls_cellend. ENDIF. CALL METHOD OF ls_range 'Select'. GET PROPERTY OF ls_range 'Font' = ls_font. "" Font Name IF i_fname IS SUPPLIED. SET PROPERTY OF ls_font 'Name' = i_fname. ENDIF. "" Font Color IF i_fcolor IS SUPPLIED. SET PROPERTY OF ls_font 'Color' = i_fcolor. ENDIF. "" Font Bold IF i_fbold IS SUPPLIED. SET PROPERTY OF ls_font 'Bold' = i_fbold. ENDIF. "" Font Size IF i_fsize IS SUPPLIED. SET PROPERTY OF ls_font 'Size' = i_fsize. ENDIF. "" Font Italic IF i_fitlc IS SUPPLIED. SET PROPERTY OF ls_font 'Italic' = i_fitlc. ENDIF. "" Font Underline IF i_fuline IS SUPPLIED. SET PROPERTY OF ls_font 'Underline' = i_fuline. ENDIF. "" Background Color IF i_bcolor IS SUPPLIED. GET PROPERTY OF ls_range 'Interior' = ls_interior. SET PROPERTY OF ls_interior 'Color' = i_bcolor. ENDIF. "" Merge IF i_merge IS SUPPLIED. CALL METHOD OF ls_range 'Merge'. ENDIF. "" Number Format IF i_nfdec IS SUPPLIED. * "" e.g. "" NumberFormat = ""General"" "" NumberFormat = ""0.00"",""0.000"",""0"" (Decimal) "" NumberFormat = ""#,##0.00 $"",""#,##0 $"" (Currency) "" NumberFormat = ""dd/mm/yyyy;@"",""dd/mm/yy;@"",""[$-41F]d mmmm yyyy;@"" (Date) "" NumberFormat = ""hh:mm;@"",""hh:mm:ss;@"" (Time) "" NumberFormat = ""0.00%"" (Percentage) SET PROPERTY OF ls_range 'NumberFormat' = i_nfdec. ENDIF. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_IMAGE * +-------------------------------------------------------------------------------------------------+ * | [--->] I_PATH TYPE STRING * | [--->] I_LEFT TYPE I * | [--->] I_TOP TYPE I * | [--->] I_WIDTH TYPE I * | [--->] I_HEIGHT TYPE I * +-------------------------------------------------------------------------------------- METHOD set_image. ************************************************************************ * @Importing@ I_PATH -> Path * @Importing@ I_LEFT -> Left * @Importing@ I_TOP -> Top * @Importing@ I_WIDTH -> Width * @Importing@ I_HEIGHT -> Height ************************************************************************ DATA: ls_shapes TYPE ole2_object. ""*- GET PROPERTY OF worksheet 'Shapes' = ls_shapes. CALL METHOD OF ls_shapes 'AddPicture' EXPORTING #1 = i_path "" Filename #2 = '1' "" LinkToFile #3 = '1' "" SaveWithDocument #4 = i_left "" Left #5 = i_top "" Top #6 = i_width "" Width #7 = i_height. "" Height ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_PAGESETUP * +-------------------------------------------------------------------------------------------------+ * | [--->] I_FITTOPAGESWIDE TYPE I (default =1) * | [--->] I_FITTOPAGESTALL TYPE I (default =1) * | [--->] I_TOPMARGIN TYPE DEC5_2(optional) * | [--->] I_RIGHTMARGIN TYPE DEC5_2(optional) * | [--->] I_BOTTOMMARGIN TYPE DEC5_2(optional) * | [--->] I_LEFTMARGIN TYPE DEC5_2(optional) * | [--->] I_HEADERMARGIN TYPE DEC5_2(optional) * | [--->] I_FOOTERMARGIN TYPE DEC5_2(optional) * | [--->] I_ORIENTATION TYPE I (default =C_ORI_PORTRAIT) * +-------------------------------------------------------------------------------------- METHOD set_pagesetup. ************************************************************************ * @Importing@ I_FITTOPAGESWIDE -> Fit to pages wide * @Importing@ I_FITTOPAGESTALL -> Fit to pages tall * @Importing@ I_TOPMARGIN -> Top margin (cm) * @Importing@ I_RIGHTMARGIN -> Right margin (cm) * @Importing@ I_BOTTOMMARGIN -> Bottom margin (cm) * @Importing@ I_LEFTMARGIN -> Left margin (cm) * @Importing@ I_HEADERMARGIN -> Header margin (cm) * @Importing@ I_FOOTERMARGIN -> Footer margin (cm) * @Importing@ I_ORIENTATION -> Orientation ************************************************************************ DATA: lv_p_16_13 TYPE gty_dec_16_13, ls_inchestopoints TYPE ole2_object, ls_pagesetup TYPE ole2_object. ""*- SET PROPERTY OF application 'PrintCommunication' = 1. GET PROPERTY OF worksheet 'PageSetup' = ls_pagesetup. SET PROPERTY OF ls_pagesetup 'PrintArea' = ''. SET PROPERTY OF application 'PrintCommunication' = 0. "" fitToWide SET PROPERTY OF ls_pagesetup 'FitToPagesWide' = i_fittopageswide. "" fitToTall SET PROPERTY OF ls_pagesetup 'FitToPagesTall' = i_fittopagestall. "" Orientation SET PROPERTY OF ls_pagesetup 'Orientation' = i_orientation. "" topMargin IF i_topmargin IS SUPPLIED. lv_p_16_13 = conv_cm2inch( i_input = i_topmargin ). CALL METHOD OF application 'InchesToPoints' = ls_inchestopoints EXPORTING #1 = lv_p_16_13. SET PROPERTY OF ls_pagesetup 'TopMargin' = ls_inchestopoints. ENDIF. "" rightMargin IF i_rightmargin IS SUPPLIED. lv_p_16_13 = conv_cm2inch( i_input = i_rightmargin ). CALL METHOD OF application 'InchesToPoints' = ls_inchestopoints EXPORTING #1 = lv_p_16_13. SET PROPERTY OF ls_pagesetup 'RightMargin' = ls_inchestopoints. ENDIF. "" bottomMargin IF i_bottommargin IS SUPPLIED. lv_p_16_13 = conv_cm2inch( i_input = i_bottommargin ). CALL METHOD OF application 'InchesToPoints' = ls_inchestopoints EXPORTING #1 = lv_p_16_13. SET PROPERTY OF ls_pagesetup 'BottomMargin' = ls_inchestopoints. ENDIF. "" leftMargin IF i_leftmargin IS SUPPLIED. lv_p_16_13 = conv_cm2inch( i_input = i_leftmargin ). CALL METHOD OF application 'InchesToPoints' = ls_inchestopoints EXPORTING #1 = lv_p_16_13. SET PROPERTY OF ls_pagesetup 'LeftMargin' = ls_inchestopoints. ENDIF. "" headerMargin IF i_headermargin IS SUPPLIED. lv_p_16_13 = conv_cm2inch( i_input = i_headermargin ). CALL METHOD OF application 'InchesToPoints' = ls_inchestopoints EXPORTING #1 = lv_p_16_13. SET PROPERTY OF ls_pagesetup 'HeaderMargin' = ls_inchestopoints. ENDIF. "" footerMargin IF i_footermargin IS SUPPLIED. lv_p_16_13 = conv_cm2inch( i_input = i_footermargin ). CALL METHOD OF application 'InchesToPoints' = ls_inchestopoints EXPORTING #1 = lv_p_16_13. SET PROPERTY OF ls_pagesetup 'FooterMargin' = ls_inchestopoints. ENDIF. ""*- SET PROPERTY OF application 'PrintCommunication' = 1. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_ROW_HEIGHT * +-------------------------------------------------------------------------------------------------+ * | [--->] I_ROW TYPE CHAR10(optional) * | [--->] I_HEIGHT TYPE DEC5_2 * +-------------------------------------------------------------------------------------- METHOD set_row_height. ************************************************************************ * @Importing@ I_ROW -> Row (ex:'2','1:5',''=All) * @Importing@ I_HEIGHT -> Height ************************************************************************ DATA: ls_rows TYPE ole2_object. ""*- IF i_row IS NOT INITIAL. CALL METHOD OF worksheet 'Rows' = ls_rows EXPORTING #1 = i_row. ELSE. CALL METHOD OF worksheet 'Rows' = ls_rows. ENDIF. ""*- SET PROPERTY OF ls_rows 'RowHeight' = i_height. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_OLE2_OBJECT->SET_VALUE * +-------------------------------------------------------------------------------------------------+ * | [--->] I_ROW TYPE I * | [--->] I_COL TYPE I * | [--->] I_VALUE TYPE SIMPLE * +-------------------------------------------------------------------------------------- METHOD set_value. ************************************************************************ * @Importing@ I_ROW -> Row * @Importing@ I_COL -> Column * @Importing@ I_VALUE -> Value ************************************************************************ DATA: ls_cells TYPE ole2_object. ""*- CALL METHOD OF worksheet 'Cells' = ls_cells EXPORTING #1 = i_row #2 = i_col. ""*- SET PROPERTY OF ls_cells 'Value' = i_value. ENDMETHOD. * ---------------------------------------------------------------------------------------+ * | Instance Private Method ZCL_OLE2_OBJECT->WRITELINE * +-------------------------------------------------------------------------------------------------+ * | [--->] IO_ABAP_TYPEDESCR TYPE REF TO CL_ABAP_TYPEDESCR * | [--->] IV_VAL TYPE ANY * +-------------------------------------------------------------------------------------- METHOD writeline. ************************************************************************ * @Importing@ IO_ABAP_TYPEDESCR -> Runtime Type Services * @Importing@ IV_VAL -> Value ************************************************************************ DATA: lv_char TYPE char1500. "" Write CASE io_abap_typedescr->type_kind. WHEN io_abap_typedescr->typekind_char. "" C WRITE iv_val TO lv_char. WHEN io_abap_typedescr->typekind_num OR "" N io_abap_typedescr->typekind_int OR "" I io_abap_typedescr->typekind_packed. "" P. IF iv_val IS NOT INITIAL. lv_char = CONV char1500( iv_val ). ENDIF. WHEN io_abap_typedescr->typekind_date. "" D IF iv_val IS NOT INITIAL. IF iv_val NA sy-abcde. WRITE iv_val TO lv_char DD/MM/YYYY. ELSE. lv_char = CONV char1500( iv_val ). ENDIF. ENDIF. WHEN io_abap_typedescr->typekind_time. "" T IF iv_val IS NOT INITIAL. IF iv_val NA sy-abcde. WRITE iv_val TO lv_char ENVIRONMENT TIME FORMAT. ELSE. lv_char = CONV char1500( iv_val ). ENDIF. ENDIF. WHEN OTHERS. "" Others WRITE iv_val TO lv_char. ENDCASE. gs_data = gs_data && cl_abap_char_utilities=>horizontal_tab && lv_char. ENDMETHOD. ENDCLASS. ",12353,True,2620.349196173569,median