new zcl_abapgit_ui_core_factory

This commit is contained in:
Lars Hvam 2025-04-07 15:03:40 +02:00
parent 51d115a1c1
commit 3237266367
3 changed files with 188 additions and 21 deletions

View File

@ -0,0 +1,168 @@
CLASS zcl_abapgit_ui_core_factory DEFINITION
PUBLIC
CREATE PRIVATE
GLOBAL FRIENDS zcl_abapgit_ui_core_injector .
PUBLIC SECTION.
CLASS-METHODS get_html_viewer
IMPORTING
!io_container TYPE REF TO cl_gui_container DEFAULT cl_gui_container=>screen0
!iv_disable_query_table TYPE abap_bool DEFAULT abap_true
RETURNING
VALUE(ri_viewer) TYPE REF TO zif_abapgit_html_viewer .
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA gi_html_viewer TYPE REF TO zif_abapgit_html_viewer .
ENDCLASS.
CLASS zcl_abapgit_ui_factory IMPLEMENTATION.
METHOD get_asset_manager.
DATA lo_buf TYPE REF TO zcl_abapgit_string_buffer.
DATA li_asset_man TYPE REF TO zif_abapgit_gui_asset_manager.
CREATE OBJECT lo_buf.
li_asset_man = zcl_abapgit_gui_asset_manager=>create( ).
" @@abapmerge include zabapgit_css_common.w3mi.data.css > lo_buf->add( '$$' ).
li_asset_man->register_asset(
iv_url = 'css/common.css'
iv_type = 'text/css'
iv_mime_name = 'ZABAPGIT_CSS_COMMON'
iv_inline = lo_buf->join_w_newline_and_flush( ) ).
" @@abapmerge include zabapgit_css_theme_default.w3mi.data.css > lo_buf->add( '$$' ).
li_asset_man->register_asset(
iv_url = 'css/theme-default.css'
iv_type = 'text/css'
iv_cacheable = abap_false
iv_mime_name = 'ZABAPGIT_CSS_THEME_DEFAULT'
iv_inline = lo_buf->join_w_newline_and_flush( ) ).
" @@abapmerge include zabapgit_css_theme_dark.w3mi.data.css > lo_buf->add( '$$' ).
li_asset_man->register_asset(
iv_url = 'css/theme-dark.css'
iv_type = 'text/css'
iv_cacheable = abap_false
iv_mime_name = 'ZABAPGIT_CSS_THEME_DARK'
iv_inline = lo_buf->join_w_newline_and_flush( ) ).
" @@abapmerge include zabapgit_css_theme_belize_blue.w3mi.data.css > lo_buf->add( '$$' ).
li_asset_man->register_asset(
iv_url = 'css/theme-belize-blue.css'
iv_type = 'text/css'
iv_cacheable = abap_false
iv_mime_name = 'ZABAPGIT_CSS_THEME_BELIZE_BLUE'
iv_inline = lo_buf->join_w_newline_and_flush( ) ).
" @@abapmerge include zabapgit_js_common.w3mi.data.js > lo_buf->add( '$$' ).
li_asset_man->register_asset(
iv_url = 'js/common.js'
iv_type = 'text/javascript'
iv_mime_name = 'ZABAPGIT_JS_COMMON'
iv_inline = lo_buf->join_w_newline_and_flush( ) ).
" @@abapmerge include zabapgit_icon_font_css.w3mi.data.css > lo_buf->add( '$$' ).
li_asset_man->register_asset(
iv_url = 'css/ag-icons.css'
iv_type = 'text/css'
iv_mime_name = 'ZABAPGIT_ICON_FONT_CSS'
iv_inline = lo_buf->join_w_newline_and_flush( ) ).
" @@abapmerge include-base64 zabapgit_icon_font.w3mi.data.woff > lo_buf->add( '$$' ).
li_asset_man->register_asset(
iv_url = 'font/ag-icons.woff'
iv_type = 'font/woff'
iv_mime_name = 'ZABAPGIT_ICON_FONT'
iv_base64 = lo_buf->join_and_flush( ) ).
ri_asset_man = li_asset_man.
ENDMETHOD.
METHOD get_frontend_services.
IF gi_fe_services IS INITIAL.
IF iv_disable_gui IS INITIAL.
CREATE OBJECT gi_fe_services TYPE zcl_abapgit_frontend_services.
ELSE.
CREATE OBJECT gi_fe_services TYPE zcl_abapgit_frontend_no_gui.
ENDIF.
ENDIF.
ri_fe_serv = gi_fe_services.
ENDMETHOD.
METHOD get_gui.
DATA:
li_hotkey_ctl TYPE REF TO zif_abapgit_gui_hotkey_ctl,
li_router TYPE REF TO zif_abapgit_gui_event_handler,
li_asset_man TYPE REF TO zif_abapgit_gui_asset_manager.
DATA lo_html_preprocessor TYPE REF TO zcl_abapgit_gui_html_processor.
IF go_gui IS INITIAL.
li_asset_man = get_asset_manager( ).
CREATE OBJECT lo_html_preprocessor EXPORTING ii_asset_man = li_asset_man.
lo_html_preprocessor->preserve_css( 'css/ag-icons.css' ).
lo_html_preprocessor->preserve_css( 'css/common.css' ).
CREATE OBJECT li_router TYPE zcl_abapgit_gui_router.
CREATE OBJECT li_hotkey_ctl TYPE zcl_abapgit_gui_hotkey_ctl.
CREATE OBJECT go_gui
EXPORTING
io_component = li_router
ii_hotkey_ctl = li_hotkey_ctl
ii_html_processor = lo_html_preprocessor
ii_asset_man = li_asset_man.
ENDIF.
ro_gui = go_gui.
ENDMETHOD.
METHOD get_gui_services.
IF gi_gui_services IS NOT BOUND.
gi_gui_services ?= get_gui( ).
ENDIF.
ri_gui_services = gi_gui_services.
ENDMETHOD.
METHOD get_html_viewer.
IF gi_html_viewer IS NOT BOUND.
CREATE OBJECT gi_html_viewer TYPE zcl_abapgit_html_viewer_gui
EXPORTING
io_container = io_container
iv_disable_query_table = iv_disable_query_table.
ENDIF.
ri_viewer = gi_html_viewer.
ENDMETHOD.
METHOD get_popups.
IF gi_popups IS INITIAL.
CREATE OBJECT gi_popups TYPE zcl_abapgit_popups.
ENDIF.
ri_popups = gi_popups.
ENDMETHOD.
ENDCLASS.

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>ZCL_ABAPGIT_UI_CORE_FACTORY</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>abapGit - GUI Core Factory</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

View File

@ -28,17 +28,11 @@ CLASS zcl_abapgit_ui_factory DEFINITION
!iv_disable_gui TYPE abap_bool DEFAULT abap_false
RETURNING
VALUE(ri_fe_serv) TYPE REF TO zif_abapgit_frontend_services .
CLASS-METHODS get_html_viewer
IMPORTING
!io_container TYPE REF TO cl_gui_container DEFAULT cl_gui_container=>screen0
!iv_disable_query_table TYPE abap_bool DEFAULT abap_true
RETURNING
VALUE(ri_viewer) TYPE REF TO zif_abapgit_html_viewer .
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA gi_popups TYPE REF TO zif_abapgit_popups .
CLASS-DATA gi_html_viewer TYPE REF TO zif_abapgit_html_viewer .
CLASS-DATA go_gui TYPE REF TO zcl_abapgit_gui .
CLASS-DATA gi_fe_services TYPE REF TO zif_abapgit_frontend_services .
CLASS-DATA gi_gui_services TYPE REF TO zif_abapgit_gui_services .
@ -47,6 +41,9 @@ ENDCLASS.
CLASS zcl_abapgit_ui_factory IMPLEMENTATION.
METHOD get_html_viewer.
RETURN. " todo, implement method
ENDMETHOD.
METHOD get_asset_manager.
@ -169,20 +166,6 @@ CLASS zcl_abapgit_ui_factory IMPLEMENTATION.
ENDMETHOD.
METHOD get_html_viewer.
IF gi_html_viewer IS NOT BOUND.
CREATE OBJECT gi_html_viewer TYPE zcl_abapgit_html_viewer_gui
EXPORTING
io_container = io_container
iv_disable_query_table = iv_disable_query_table.
ENDIF.
ri_viewer = gi_html_viewer.
ENDMETHOD.
METHOD get_popups.
IF gi_popups IS INITIAL.