mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-02 13:03:01 +08:00

* Refactor: Consolidate front-end classes There's no need for two "front-end classes". Moves all of ZCL_ABAPGIT_GUI_FUNCTIONS to ZCL_ABAPGIT_FRONTEND_SERVICES. Now all front-end calls are nicely together. No functional change, some method reordering. Ref #2510, #5145 * Add missing interface Co-authored-by: Christian Günter <christianguenter@googlemail.com> Co-authored-by: Lars Hvam <larshp@hotmail.com>
424 lines
12 KiB
ABAP
424 lines
12 KiB
ABAP
CLASS zcl_abapgit_frontend_services DEFINITION
|
|
PUBLIC
|
|
CREATE PRIVATE
|
|
GLOBAL FRIENDS zcl_abapgit_ui_factory.
|
|
|
|
PUBLIC SECTION.
|
|
|
|
INTERFACES zif_abapgit_frontend_services.
|
|
PROTECTED SECTION.
|
|
PRIVATE SECTION.
|
|
ENDCLASS.
|
|
|
|
|
|
|
|
CLASS zcl_abapgit_frontend_services IMPLEMENTATION.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~clipboard_export.
|
|
|
|
DATA lv_rc TYPE i.
|
|
|
|
" Note: do not use a string table for 'it_data'!
|
|
cl_gui_frontend_services=>clipboard_export(
|
|
EXPORTING
|
|
no_auth_check = iv_no_auth_check
|
|
IMPORTING
|
|
data = it_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 <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~directory_browse.
|
|
|
|
cl_gui_frontend_services=>directory_browse(
|
|
EXPORTING
|
|
window_title = iv_window_title
|
|
initial_folder = iv_initial_folder
|
|
CHANGING
|
|
selected_folder = cv_selected_folder
|
|
EXCEPTIONS
|
|
cntl_error = 1
|
|
error_no_gui = 2
|
|
not_supported_by_gui = 3
|
|
OTHERS = 4 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~directory_create.
|
|
|
|
cl_gui_frontend_services=>directory_create(
|
|
EXPORTING
|
|
directory = iv_directory
|
|
CHANGING
|
|
rc = cv_rc
|
|
EXCEPTIONS
|
|
directory_create_failed = 1
|
|
cntl_error = 2
|
|
error_no_gui = 3
|
|
directory_access_denied = 4
|
|
directory_already_exists = 5
|
|
path_not_found = 6
|
|
unknown_error = 7
|
|
not_supported_by_gui = 8
|
|
wrong_parameter = 9
|
|
OTHERS = 10 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~directory_exist.
|
|
|
|
cl_gui_frontend_services=>directory_exist(
|
|
EXPORTING
|
|
directory = iv_directory
|
|
RECEIVING
|
|
result = rv_exists
|
|
EXCEPTIONS
|
|
cntl_error = 1
|
|
error_no_gui = 2
|
|
wrong_parameter = 3
|
|
not_supported_by_gui = 4
|
|
OTHERS = 5 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~execute.
|
|
|
|
cl_gui_frontend_services=>execute(
|
|
EXPORTING
|
|
document = iv_document
|
|
application = iv_application
|
|
parameter = iv_parameter
|
|
default_directory = iv_default_directory
|
|
maximized = iv_maximized
|
|
minimized = iv_minimized
|
|
synchronous = iv_synchronous
|
|
operation = iv_operation
|
|
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 zif_abapgit_frontend_services~file_download.
|
|
|
|
TYPES ty_hex TYPE x LENGTH 200.
|
|
DATA lt_rawdata TYPE STANDARD TABLE OF ty_hex WITH DEFAULT KEY.
|
|
|
|
zcl_abapgit_convert=>xstring_to_bintab(
|
|
EXPORTING iv_xstr = iv_xstr
|
|
IMPORTING et_bintab = lt_rawdata ).
|
|
|
|
cl_gui_frontend_services=>gui_download(
|
|
EXPORTING
|
|
bin_filesize = xstrlen( iv_xstr )
|
|
filename = iv_path
|
|
filetype = 'BIN'
|
|
CHANGING
|
|
data_tab = lt_rawdata
|
|
EXCEPTIONS
|
|
file_write_error = 1
|
|
no_batch = 2
|
|
gui_refuse_filetransfer = 3
|
|
invalid_type = 4
|
|
no_authority = 5
|
|
unknown_error = 6
|
|
header_not_allowed = 7
|
|
separator_not_allowed = 8
|
|
filesize_not_allowed = 9
|
|
header_too_long = 10
|
|
dp_error_create = 11
|
|
dp_error_send = 12
|
|
dp_error_write = 13
|
|
unknown_dp_error = 14
|
|
access_denied = 15
|
|
dp_out_of_memory = 16
|
|
disk_full = 17
|
|
dp_timeout = 18
|
|
file_not_found = 19
|
|
dataprovider_exception = 20
|
|
control_flush_error = 21
|
|
not_supported_by_gui = 22
|
|
error_no_gui = 23
|
|
OTHERS = 24 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~file_upload.
|
|
|
|
TYPES: ty_hex TYPE x LENGTH 255.
|
|
|
|
DATA: lt_data TYPE TABLE OF ty_hex WITH DEFAULT KEY,
|
|
lv_length TYPE i.
|
|
|
|
cl_gui_frontend_services=>gui_upload(
|
|
EXPORTING
|
|
filename = iv_path
|
|
filetype = 'BIN'
|
|
IMPORTING
|
|
filelength = lv_length
|
|
CHANGING
|
|
data_tab = lt_data
|
|
EXCEPTIONS
|
|
file_open_error = 1
|
|
file_read_error = 2
|
|
no_batch = 3
|
|
gui_refuse_filetransfer = 4
|
|
invalid_type = 5
|
|
no_authority = 6
|
|
unknown_error = 7
|
|
bad_data_format = 8
|
|
header_not_allowed = 9
|
|
separator_not_allowed = 10
|
|
header_too_long = 11
|
|
unknown_dp_error = 12
|
|
access_denied = 13
|
|
dp_out_of_memory = 14
|
|
disk_full = 15
|
|
dp_timeout = 16
|
|
not_supported_by_gui = 17
|
|
error_no_gui = 18
|
|
OTHERS = 19 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
CONCATENATE LINES OF lt_data INTO rv_xstr IN BYTE MODE.
|
|
rv_xstr = rv_xstr(lv_length).
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~get_file_separator.
|
|
|
|
cl_gui_frontend_services=>get_file_separator(
|
|
CHANGING
|
|
file_separator = cv_file_separator
|
|
EXCEPTIONS
|
|
not_supported_by_gui = 1
|
|
error_no_gui = 2
|
|
cntl_error = 3
|
|
OTHERS = 4 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~get_gui_version.
|
|
|
|
cl_gui_frontend_services=>get_gui_version(
|
|
CHANGING
|
|
version_table = ct_version_table
|
|
rc = cv_rc
|
|
EXCEPTIONS
|
|
get_gui_version_failed = 1
|
|
cant_write_version_table = 2
|
|
gui_no_version = 3
|
|
cntl_error = 4
|
|
error_no_gui = 5
|
|
not_supported_by_gui = 6
|
|
OTHERS = 7 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~get_system_directory.
|
|
|
|
cl_gui_frontend_services=>get_system_directory(
|
|
CHANGING
|
|
system_directory = cv_system_directory
|
|
EXCEPTIONS
|
|
cntl_error = 1
|
|
error_no_gui = 2
|
|
not_supported_by_gui = 3
|
|
OTHERS = 4 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~gui_is_available.
|
|
|
|
CALL FUNCTION 'GUI_IS_AVAILABLE'
|
|
IMPORTING
|
|
return = rv_gui_is_available.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~is_sapgui_for_java.
|
|
|
|
CALL FUNCTION 'GUI_HAS_JAVABEANS'
|
|
IMPORTING
|
|
return = rv_result.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~is_sapgui_for_windows.
|
|
|
|
DATA: lv_platform TYPE i.
|
|
|
|
cl_gui_frontend_services=>get_platform(
|
|
RECEIVING
|
|
platform = lv_platform
|
|
EXCEPTIONS
|
|
error_no_gui = 1
|
|
cntl_error = 2
|
|
not_supported_by_gui = 3
|
|
OTHERS = 4 ).
|
|
IF sy-subrc <> 0.
|
|
rv_result = abap_false.
|
|
ENDIF.
|
|
|
|
CASE lv_platform.
|
|
WHEN cl_gui_frontend_services=>platform_nt351 OR
|
|
cl_gui_frontend_services=>platform_nt40 OR
|
|
cl_gui_frontend_services=>platform_nt50 OR
|
|
cl_gui_frontend_services=>platform_windows95 OR
|
|
cl_gui_frontend_services=>platform_windows98 OR
|
|
cl_gui_frontend_services=>platform_windowsxp.
|
|
" Everything after Windows XP is reported as Windows XP
|
|
rv_result = abap_true.
|
|
WHEN OTHERS.
|
|
rv_result = abap_false.
|
|
ENDCASE.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~is_webgui.
|
|
|
|
CALL FUNCTION 'GUI_IS_ITS'
|
|
IMPORTING
|
|
return = rv_is_webgui.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~show_file_open_dialog.
|
|
|
|
DATA:
|
|
lt_file_table TYPE filetable,
|
|
ls_file_table LIKE LINE OF lt_file_table,
|
|
lv_filter TYPE string,
|
|
lv_action TYPE i,
|
|
lv_rc TYPE i.
|
|
|
|
IF iv_extension = 'zip'.
|
|
lv_filter = 'ZIP Files (*.zip)|*.zip|' && cl_gui_frontend_services=>filetype_all.
|
|
ENDIF.
|
|
|
|
cl_gui_frontend_services=>file_open_dialog(
|
|
EXPORTING
|
|
window_title = iv_title
|
|
default_filename = iv_default_filename
|
|
file_filter = lv_filter
|
|
CHANGING
|
|
file_table = lt_file_table
|
|
rc = lv_rc
|
|
user_action = lv_action
|
|
EXCEPTIONS
|
|
file_open_dialog_failed = 1
|
|
cntl_error = 2
|
|
error_no_gui = 3
|
|
not_supported_by_gui = 4
|
|
OTHERS = 5 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
IF lv_action = cl_gui_frontend_services=>action_cancel.
|
|
zcx_abapgit_exception=>raise( 'Cancelled' ).
|
|
ENDIF.
|
|
|
|
READ TABLE lt_file_table INDEX 1 INTO ls_file_table.
|
|
ASSERT sy-subrc = 0.
|
|
rv_path = ls_file_table-filename.
|
|
|
|
ENDMETHOD.
|
|
|
|
|
|
METHOD zif_abapgit_frontend_services~show_file_save_dialog.
|
|
|
|
DATA:
|
|
lv_action TYPE i,
|
|
lv_filter TYPE string,
|
|
lv_filename TYPE string,
|
|
lv_path TYPE string.
|
|
|
|
IF iv_extension = 'zip'.
|
|
lv_filter = 'ZIP Files (*.zip)|*.zip|' && cl_gui_frontend_services=>filetype_all.
|
|
ENDIF.
|
|
|
|
cl_gui_frontend_services=>file_save_dialog(
|
|
EXPORTING
|
|
window_title = iv_title
|
|
default_extension = iv_extension
|
|
default_file_name = iv_default_filename
|
|
file_filter = lv_filter
|
|
CHANGING
|
|
filename = lv_filename
|
|
path = lv_path
|
|
fullpath = rv_path
|
|
user_action = lv_action
|
|
EXCEPTIONS
|
|
cntl_error = 1
|
|
error_no_gui = 2
|
|
not_supported_by_gui = 3
|
|
OTHERS = 4 ).
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise_t100( ).
|
|
ENDIF.
|
|
IF lv_action = cl_gui_frontend_services=>action_cancel.
|
|
zcx_abapgit_exception=>raise( 'Cancelled' ).
|
|
ENDIF.
|
|
|
|
ENDMETHOD.
|
|
ENDCLASS.
|