All files / src/env zcl_abapgit_settings.clas.abap

83.46% Statements 439/526
100% Branches 2/2
8% Functions 2/25
83.46% Lines 439/526

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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 5271x 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 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 18x 18x 1x 1x 1x           1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x 12x 12x 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_settings DEFINITION
  PUBLIC
  CREATE PUBLIC .
 
  PUBLIC SECTION.
 
    CONSTANTS c_commitmsg_comment_length_dft TYPE i VALUE 50 ##NO_TEXT.
    CONSTANTS c_commitmsg_body_size_dft TYPE i VALUE 72 ##NO_TEXT.
    CONSTANTS:
      BEGIN OF c_icon_scaling,
        large TYPE c VALUE 'L',
        small TYPE c VALUE 'S',
      END OF c_icon_scaling .
    CONSTANTS:
      BEGIN OF c_ui_theme,
        default         TYPE string VALUE 'default',
        dark            TYPE string VALUE 'dark',
        belize          TYPE string VALUE 'belize',
        synced_with_gui TYPE string VALUE 'synced_with_gui',
      END OF c_ui_theme .
 
    METHODS set_proxy_url
      IMPORTING
        !iv_url TYPE string .
    METHODS set_proxy_port
      IMPORTING
        !iv_port TYPE string .
    METHODS set_proxy_authentication
      IMPORTING
        !iv_auth TYPE abap_bool .
    METHODS set_proxy_bypass
      IMPORTING
        !it_bypass TYPE zif_abapgit_definitions=>ty_range_proxy_bypass_url OPTIONAL .
    METHODS get_proxy_url
      RETURNING
        VALUE(rv_proxy_url) TYPE string .
    METHODS get_proxy_port
      RETURNING
        VALUE(rv_port) TYPE string .
    METHODS get_proxy_authentication
      RETURNING
        VALUE(rv_auth) TYPE abap_bool .
    METHODS get_proxy_bypass
      RETURNING
        VALUE(rt_bypass) TYPE zif_abapgit_definitions=>ty_range_proxy_bypass_url .
    METHODS set_run_critical_tests
      IMPORTING
        !iv_run TYPE abap_bool .
    METHODS get_run_critical_tests
      RETURNING
        VALUE(rv_run) TYPE abap_bool .
    METHODS set_experimental_features
      IMPORTING
        !iv_features TYPE string.
    METHODS get_experimental_features
      RETURNING
        VALUE(rv_features) TYPE string.
    METHODS set_max_lines
      IMPORTING
        !iv_lines TYPE i .
    METHODS get_max_lines
      RETURNING
        VALUE(rv_lines) TYPE i .
    METHODS set_adt_jump_enanbled
      IMPORTING
        !iv_adt_jump_enabled TYPE abap_bool .
    METHODS get_adt_jump_enabled
      RETURNING
        VALUE(rv_adt_jump_enabled) TYPE abap_bool .
    METHODS set_commitmsg_comment_length
      IMPORTING
        !iv_length TYPE i .
    METHODS get_commitmsg_comment_length
      RETURNING
        VALUE(rv_length) TYPE i .
    METHODS set_commitmsg_comment_default
      IMPORTING
        !iv_default TYPE string .
    METHODS get_commitmsg_comment_default
      RETURNING
        VALUE(rv_default) TYPE string .
    METHODS set_commitmsg_body_size
      IMPORTING
        !iv_length TYPE i .
    METHODS get_commitmsg_body_size
      RETURNING
        VALUE(rv_length) TYPE i .
    METHODS set_commitmsg_hide_author
      IMPORTING
        !iv_hide_author TYPE abap_bool.
    METHODS get_commitmsg_hide_author
      RETURNING
        VALUE(rv_hide_author) TYPE abap_bool.
    METHODS get_settings_xml
      RETURNING
        VALUE(rv_settings_xml) TYPE string
      RAISING
        zcx_abapgit_exception .
    METHODS get_user_settings
      RETURNING
        VALUE(rs_settings) TYPE zif_abapgit_definitions=>ty_s_user_settings
      RAISING
        zcx_abapgit_exception .
    METHODS set_xml_settings
      IMPORTING
        !iv_settings_xml TYPE string
      RAISING
        zcx_abapgit_exception .
    METHODS set_defaults .
    METHODS set_user_settings
      IMPORTING
        !is_user_settings TYPE zif_abapgit_definitions=>ty_s_user_settings .
    METHODS get_show_default_repo
      RETURNING
        VALUE(rv_show_default_repo) TYPE abap_bool .
    METHODS set_show_default_repo
      IMPORTING
        !iv_show_default_repo TYPE abap_bool .
    METHODS set_link_hints_enabled
      IMPORTING
        !iv_link_hints_enabled TYPE abap_bool .
    METHODS get_link_hints_enabled
      RETURNING
        VALUE(rv_link_hints_enabled) TYPE abap_bool
      RAISING
        zcx_abapgit_exception .
    METHODS set_link_hint_key
      IMPORTING
        !iv_link_hint_key TYPE string .
    METHODS get_link_hint_key
      RETURNING
        VALUE(rv_link_hint_key) TYPE string .
    METHODS set_parallel_proc_disabled
      IMPORTING
        !iv_disable_parallel_proc TYPE abap_bool .
    METHODS get_parallel_proc_disabled
      RETURNING
        VALUE(rv_disable_parallel_proc) TYPE abap_bool .
    METHODS get_icon_scaling
      RETURNING
        VALUE(rv_scaling) TYPE zif_abapgit_definitions=>ty_s_user_settings-icon_scaling .
    METHODS set_icon_scaling
      IMPORTING
        !iv_scaling TYPE zif_abapgit_definitions=>ty_s_user_settings-icon_scaling .
    METHODS get_ui_theme
      IMPORTING
        !iv_resolve_synced TYPE abap_bool DEFAULT abap_true
      RETURNING
        VALUE(rv_ui_theme) TYPE zif_abapgit_definitions=>ty_s_user_settings-ui_theme .
    METHODS set_ui_theme
      IMPORTING
        !iv_ui_theme TYPE zif_abapgit_definitions=>ty_s_user_settings-ui_theme .
    METHODS get_activate_wo_popup
      RETURNING
        VALUE(rv_act_wo_popup) TYPE zif_abapgit_definitions=>ty_s_user_settings-activate_wo_popup .
    METHODS set_activate_wo_popup
      IMPORTING
        !iv_act_wo_popup TYPE zif_abapgit_definitions=>ty_s_user_settings-activate_wo_popup .
    METHODS set_default_git_uname
      IMPORTING
        !iv_default_git_uname TYPE string.
    METHODS get_default_git_uname
      RETURNING
        VALUE(rv_default_git_uname) TYPE string.
    METHODS set_default_git_email
      IMPORTING
        !iv_default_git_email TYPE string.
    METHODS get_default_git_email
      RETURNING
        VALUE(rv_default_git_email) TYPE string.
  PROTECTED SECTION.
  PRIVATE SECTION.
    TYPES: BEGIN OF ty_s_settings,
             proxy_url                TYPE string,
             proxy_port               TYPE string,
             proxy_auth               TYPE string,
             proxy_bypass             TYPE zif_abapgit_definitions=>ty_range_proxy_bypass_url,
             run_critical_tests       TYPE abap_bool,
             experimental_features    TYPE string,
             commitmsg_comment_length TYPE i,
             commitmsg_comment_deflt  TYPE string,
             commitmsg_body_size      TYPE i,
             commitmsg_hide_author    TYPE abap_bool,
           END OF ty_s_settings.
 
    DATA: ms_settings      TYPE ty_s_settings,
          ms_user_settings TYPE zif_abapgit_definitions=>ty_s_user_settings.
 
    METHODS:
      set_default_link_hint_key.
 
ENDCLASS.
 
 
 
CLASS zcl_abapgit_settings IMPLEMENTATION.
 
 
  METHOD get_activate_wo_popup.
    rv_act_wo_popup = ms_user_settings-activate_wo_popup.
  ENDMETHOD.
 
 
  METHOD get_adt_jump_enabled.
    rv_adt_jump_enabled = ms_user_settings-adt_jump_enabled.
  ENDMETHOD.
 
 
  METHOD get_commitmsg_body_size.
    rv_length = ms_settings-commitmsg_body_size.
  ENDMETHOD.
 
 
  METHOD get_commitmsg_comment_default.
    rv_default = ms_settings-commitmsg_comment_deflt.
  ENDMETHOD.
 
 
  METHOD get_commitmsg_comment_length.
    rv_length = ms_settings-commitmsg_comment_length.
  ENDMETHOD.
 
 
  METHOD get_commitmsg_hide_author.
    rv_hide_author = ms_settings-commitmsg_hide_author.
  ENDMETHOD.
 
 
  METHOD get_experimental_features.
    IF zcl_abapgit_factory=>get_environment( )->is_merged( ) = abap_false.
      rv_features = ms_settings-experimental_features.
    ENDIF.
  ENDMETHOD.
 
 
  METHOD get_icon_scaling.
    rv_scaling = ms_user_settings-icon_scaling.
  ENDMETHOD.
 
 
  METHOD get_link_hints_enabled.
    rv_link_hints_enabled = ms_user_settings-link_hints_enabled.
  ENDMETHOD.
 
 
  METHOD get_link_hint_key.
    rv_link_hint_key = ms_user_settings-link_hint_key.
  ENDMETHOD.
 
 
  METHOD get_max_lines.
    rv_lines = ms_user_settings-max_lines.
  ENDMETHOD.
 
 
  METHOD get_parallel_proc_disabled.
    rv_disable_parallel_proc = ms_user_settings-parallel_proc_disabled.
  ENDMETHOD.
 
 
  METHOD get_proxy_authentication.
    rv_auth = ms_settings-proxy_auth.
  ENDMETHOD.
 
 
  METHOD get_proxy_bypass.
    rt_bypass = ms_settings-proxy_bypass.
  ENDMETHOD.
 
 
  METHOD get_proxy_port.
    rv_port = ms_settings-proxy_port.
  ENDMETHOD.
 
 
  METHOD get_proxy_url.
    rv_proxy_url = ms_settings-proxy_url.
  ENDMETHOD.
 
 
  METHOD get_run_critical_tests.
    IF zcl_abapgit_factory=>get_environment( )->is_merged( ) = abap_false.
      rv_run = ms_settings-run_critical_tests.
    ENDIF.
  ENDMETHOD.
 
 
  METHOD get_settings_xml.
 
    DATA: li_output TYPE REF TO zif_abapgit_xml_output.
 
 
    CREATE OBJECT li_output TYPE zcl_abapgit_xml_output.
 
    li_output->add( iv_name = zcl_abapgit_persistence_db=>c_type_settings
                    ig_data = ms_settings ).
 
    rv_settings_xml = li_output->render( ).
 
  ENDMETHOD.
 
 
  METHOD get_show_default_repo.
    rv_show_default_repo = ms_user_settings-show_default_repo.
  ENDMETHOD.
 
 
  METHOD get_ui_theme.
    DATA lv_frontend_theme TYPE string.
    DATA lv_cl_gui TYPE string.
 
    lv_cl_gui = 'CL_GUI_RESOURCES'.
 
    rv_ui_theme = ms_user_settings-ui_theme.
 
    IF rv_ui_theme = c_ui_theme-synced_with_gui AND iv_resolve_synced = abap_true.
      TRY.
          CALL METHOD (lv_cl_gui)=>get_themename
            IMPORTING
              themename              = lv_frontend_theme
            EXCEPTIONS
              get_std_resource_error = 1
              OTHERS                 = 2.
          IF sy-subrc <> 0.
            rv_ui_theme = c_ui_theme-default.
            RETURN.
          ENDIF.
        CATCH cx_sy_dyn_call_error.
          rv_ui_theme = c_ui_theme-default.
          RETURN.
      ENDTRY.
 
      CASE lv_frontend_theme.
        WHEN 'Belize'.
          rv_ui_theme = c_ui_theme-belize.
        WHEN OTHERS.
          IF lv_frontend_theme CS 'dark'.
            rv_ui_theme = c_ui_theme-dark.
          ELSE.
            rv_ui_theme = c_ui_theme-default.
          ENDIF.
      ENDCASE.
    ENDIF.
  ENDMETHOD.
 
 
  METHOD get_user_settings.
    rs_settings = ms_user_settings.
  ENDMETHOD.
 
 
  METHOD set_activate_wo_popup.
    ms_user_settings-activate_wo_popup = iv_act_wo_popup.
  ENDMETHOD.
 
 
  METHOD set_adt_jump_enanbled.
    ms_user_settings-adt_jump_enabled = iv_adt_jump_enabled.
  ENDMETHOD.
 
 
  METHOD set_commitmsg_body_size.
    ms_settings-commitmsg_body_size = iv_length.
  ENDMETHOD.
 
 
  METHOD set_commitmsg_comment_default.
    ms_settings-commitmsg_comment_deflt = iv_default.
  ENDMETHOD.
 
 
  METHOD set_commitmsg_comment_length.
    ms_settings-commitmsg_comment_length = iv_length.
  ENDMETHOD.
 
 
  METHOD set_commitmsg_hide_author.
    ms_settings-commitmsg_hide_author = iv_hide_author.
  ENDMETHOD.
 
 
  METHOD set_defaults.

    CLEAR ms_settings.

    set_proxy_authentication( abap_false ).
    set_run_critical_tests( abap_false ).
    set_experimental_features( '' ).
    set_max_lines( 500 ).
    set_adt_jump_enanbled( abap_true ).
    set_show_default_repo( abap_false ).
    set_commitmsg_comment_length( c_commitmsg_comment_length_dft ).
    set_commitmsg_body_size( c_commitmsg_body_size_dft ).
    set_default_link_hint_key( ).
    set_icon_scaling( '' ).

  ENDMETHOD.
 
 
  METHOD set_default_link_hint_key.
    " Since #5859 'f' is used for "focus filter", we use 't' as the new default
    set_link_hint_key( |t| ).
  ENDMETHOD.
 
 
  METHOD set_experimental_features.
    ms_settings-experimental_features = iv_features.
  ENDMETHOD.
 
 
  METHOD set_icon_scaling.
    ms_user_settings-icon_scaling = iv_scaling.
    IF ms_user_settings-icon_scaling NA c_icon_scaling.
      ms_user_settings-icon_scaling = ''. " Reset to default
    ENDIF.
  ENDMETHOD.
 
 
  METHOD set_link_hints_enabled.
    ms_user_settings-link_hints_enabled = iv_link_hints_enabled.
  ENDMETHOD.
 
 
  METHOD set_link_hint_key.
    ms_user_settings-link_hint_key = iv_link_hint_key.
  ENDMETHOD.
 
 
  METHOD set_max_lines.
    ms_user_settings-max_lines = iv_lines.
  ENDMETHOD.
 
 
  METHOD set_parallel_proc_disabled.
    ms_user_settings-parallel_proc_disabled = iv_disable_parallel_proc.
  ENDMETHOD.
 
 
  METHOD set_proxy_authentication.
    ms_settings-proxy_auth = iv_auth.
  ENDMETHOD.
 
 
  METHOD set_proxy_bypass.
    ms_settings-proxy_bypass = it_bypass.
  ENDMETHOD.
 
 
  METHOD set_proxy_port.
    ms_settings-proxy_port = iv_port.
  ENDMETHOD.
 
 
  METHOD set_proxy_url.
    ms_settings-proxy_url = iv_url.
  ENDMETHOD.
 
 
  METHOD set_run_critical_tests.
    ms_settings-run_critical_tests = iv_run.
  ENDMETHOD.
 
 
  METHOD set_show_default_repo.
    ms_user_settings-show_default_repo = iv_show_default_repo.
  ENDMETHOD.
 
 
  METHOD set_ui_theme.
    ms_user_settings-ui_theme = iv_ui_theme.
    IF ms_user_settings-ui_theme <> c_ui_theme-default
        AND ms_user_settings-ui_theme <> c_ui_theme-dark
        AND ms_user_settings-ui_theme <> c_ui_theme-belize
        AND ms_user_settings-ui_theme <> c_ui_theme-synced_with_gui.
      ms_user_settings-ui_theme = c_ui_theme-default. " Reset to default
    ENDIF.
  ENDMETHOD.
 
 
  METHOD set_user_settings.
    ms_user_settings = is_user_settings.

    IF ms_user_settings-link_hint_key IS INITIAL.
      set_default_link_hint_key( ).
    ENDIF.

  ENDMETHOD.
 
 
  METHOD set_xml_settings.

    DATA: lo_input TYPE REF TO zif_abapgit_xml_input.


    CREATE OBJECT lo_input TYPE zcl_abapgit_xml_input EXPORTING iv_xml = iv_settings_xml.

    CLEAR ms_settings.

    lo_input->read(
      EXPORTING
        iv_name = zcl_abapgit_persistence_db=>c_type_settings
      CHANGING
        cg_data = ms_settings ).

  ENDMETHOD.
 
 
  METHOD get_default_git_uname.
    rv_default_git_uname = ms_user_settings-default_git_uname.
  ENDMETHOD.
 
 
  METHOD set_default_git_uname.
    ms_user_settings-default_git_uname = iv_default_git_uname.
  ENDMETHOD.
 
 
  METHOD get_default_git_email.
    rv_default_git_email = ms_user_settings-default_git_email.
  ENDMETHOD.
 
 
  METHOD set_default_git_email.
    ms_user_settings-default_git_email = iv_default_git_email.
  ENDMETHOD.
ENDCLASS.