Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | CLASS zcl_abapgit_gui_hotkey_ctl DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_component FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES zif_abapgit_gui_hotkeys. INTERFACES zif_abapgit_gui_hotkey_ctl. INTERFACES zif_abapgit_gui_renderable. CONSTANTS c_showhotkeys_action TYPE string VALUE `showHotkeys` ##NO_TEXT. CLASS-METHODS should_show_hint RETURNING VALUE(rv_yes) TYPE abap_bool. METHODS constructor RAISING zcx_abapgit_exception. PROTECTED SECTION. PRIVATE SECTION. DATA: mt_hotkeys TYPE zif_abapgit_gui_hotkeys=>ty_hotkeys_with_descr, ms_user_settings TYPE zif_abapgit_definitions=>ty_s_user_settings, mv_visible TYPE abap_bool. CLASS-DATA gv_hint_was_shown TYPE abap_bool . METHODS render_scripts IMPORTING !it_hotkeys TYPE zif_abapgit_gui_hotkeys=>ty_hotkeys_with_descr RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html . ENDCLASS. CLASS ZCL_ABAPGIT_GUI_HOTKEY_CTL IMPLEMENTATION. METHOD constructor. super->constructor( ). ms_user_settings = zcl_abapgit_persistence_user=>get_instance( )->get_settings( ). ENDMETHOD. METHOD render_scripts. DATA lv_json TYPE string. FIELD-SYMBOLS: <ls_hotkey> LIKE LINE OF it_hotkeys. lv_json = `{`. LOOP AT it_hotkeys ASSIGNING <ls_hotkey>. IF sy-tabix > 1. lv_json = lv_json && |,|. ENDIF. lv_json = lv_json && | "{ <ls_hotkey>-hotkey }" : "{ <ls_hotkey>-action }" |. ENDLOOP. lv_json = lv_json && `}`. 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( |setKeyBindings({ lv_json });| ). ENDMETHOD. METHOD should_show_hint. IF gv_hint_was_shown = abap_false. rv_yes = abap_true. gv_hint_was_shown = abap_true. ENDIF. ENDMETHOD. METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions. DATA ls_hotkey LIKE LINE OF rt_hotkey_actions. ls_hotkey-ui_component = 'Hotkeys'. ls_hotkey-action = c_showhotkeys_action. ls_hotkey-description = 'Show Hotkeys Help'. ls_hotkey-hotkey = '?'. INSERT ls_hotkey INTO TABLE rt_hotkey_actions. ENDMETHOD. METHOD zif_abapgit_gui_hotkey_ctl~get_registered_hotkeys. rt_registered_hotkeys = mt_hotkeys. ENDMETHOD. METHOD zif_abapgit_gui_hotkey_ctl~register_hotkeys. FIELD-SYMBOLS <ls_hotkey> LIKE LINE OF it_hotkeys. " Compress duplicates LOOP AT it_hotkeys ASSIGNING <ls_hotkey>. READ TABLE mt_hotkeys WITH KEY hotkey = <ls_hotkey>-hotkey TRANSPORTING NO FIELDS. IF sy-subrc = 0. " If found command with same hotkey DELETE mt_hotkeys INDEX sy-tabix. " Later registered commands enjoys the priority ENDIF. IF ms_user_settings-link_hints_enabled = abap_true AND ms_user_settings-link_hint_key = <ls_hotkey>-hotkey. " Link hint activation key is more important CONTINUE. ENDIF. APPEND <ls_hotkey> TO mt_hotkeys. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_gui_hotkey_ctl~reset. CLEAR mt_hotkeys. ENDMETHOD. METHOD zif_abapgit_gui_hotkey_ctl~set_visible. mv_visible = iv_visible. ENDMETHOD. METHOD zif_abapgit_gui_renderable~render. DATA: lv_hint TYPE string, lt_registered_hotkeys TYPE zif_abapgit_gui_hotkeys=>ty_hotkeys_with_descr, lv_hotkey TYPE string, ls_user_settings TYPE zif_abapgit_definitions=>ty_s_user_settings. FIELD-SYMBOLS <ls_hotkey> LIKE LINE OF lt_registered_hotkeys. register_handlers( ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. lt_registered_hotkeys = zif_abapgit_gui_hotkey_ctl~get_registered_hotkeys( ). SORT lt_registered_hotkeys BY ui_component description. register_deferred_script( render_scripts( lt_registered_hotkeys ) ). " Render hotkeys ri_html->add( '<ul class="hotkeys">' ). LOOP AT lt_registered_hotkeys ASSIGNING <ls_hotkey>. ri_html->add( |<li>| && |<span class="key-id">{ <ls_hotkey>-hotkey }</span>| && |<span class="key-descr">{ <ls_hotkey>-description }</span>| && |</li>| ). ENDLOOP. " render link hints activation key ls_user_settings = zcl_abapgit_persistence_user=>get_instance( )->get_settings( ). IF ls_user_settings-link_hints_enabled = abap_true. ri_html->add( |<li>| && |<span class="key-id">{ ls_user_settings-link_hint_key }</span>| && |<span class="key-descr">Link Hints</span>| && |</li>| ). ri_html->add( |<li>| && |<span class="key-id">y{ ls_user_settings-link_hint_key }</span>| && |<span class="key-descr">Copy Link Text</span>| && |</li>| ). ENDIF. ri_html->add( '</ul>' ). CLEAR lv_hotkey. READ TABLE lt_registered_hotkeys ASSIGNING <ls_hotkey> WITH KEY action = c_showhotkeys_action. IF sy-subrc = 0. lv_hotkey = <ls_hotkey>-hotkey. ENDIF. lv_hint = |Close window with upper right corner 'X'|. IF lv_hotkey IS NOT INITIAL. lv_hint = lv_hint && | or press '{ <ls_hotkey>-hotkey }'|. ENDIF. ri_html = zcl_abapgit_gui_chunk_lib=>render_infopanel( iv_div_id = 'hotkeys' iv_title = 'Hotkeys' iv_hint = lv_hint iv_hide = boolc( mv_visible = abap_false ) iv_scrollable = abap_false io_content = ri_html ). IF lv_hotkey IS NOT INITIAL AND should_show_hint( ) = abap_true. ri_html->add( |<div id="hotkeys-hint" class="corner-hint">| && |Press '{ <ls_hotkey>-hotkey }' to get keyboard shortcuts list| && |</div>| ). ENDIF. " Always reset visibility here. Closing of the popup has to be done by the " user and is handled in JS. mv_visible = abap_false. ENDMETHOD. ENDCLASS. |