Skip to content

Commit

Permalink
added launchpad samples (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblomov-dev authored Nov 30, 2024
1 parent 8d46e9c commit 3746058
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/01/package.devc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DEVC" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DEVC>
<CTEXT>launchpad</CTEXT>
</DEVC>
</asx:values>
</asx:abap>
</abapGit>
50 changes: 50 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_01.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
CLASS z2ui5_cl_demo_app_lp_01 DEFINITION PUBLIC.

PUBLIC SECTION.
INTERFACES z2ui5_if_app.

DATA check_initialized TYPE abap_bool.

PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_demo_app_lp_01 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
IF check_initialized = abap_false.
check_initialized = abap_true.

IF client->get( )-check_launchpad_active = abap_false.
client->message_box_display( `No Launchpad Active, Sample not working!` ).
ENDIF.

DATA(view) = z2ui5_cl_xml_view=>factory( ).
DATA(page) = view->shell( )->page( showheader = abap_false ).
client->view_display( page->simple_form( title = 'Laucnhpad I - Read Startup Parameters' editable = abap_true
)->content( 'form'
)->label( ``
)->button( text = 'Read Parameters'
press = client->_event( val = 'READ_PARAMS' )
)->label( ``
)->button( text = 'Go Back'
press = client->_event( val = 'BACK' ) )->stringify( ) ).

ENDIF.

CASE client->get( )-event.

WHEN 'READ_PARAMS'.
DATA(lv_text) = `Start Parameter: `.
DATA(lt_params) = client->get( )-t_comp_params.
LOOP AT lt_params INTO DATA(ls_param).
lv_text = |{ lv_text } / { ls_param-n } = { ls_param-v }|.
ENDLOOP.
client->message_box_display( lv_text ).

WHEN 'BACK'.
client->nav_app_leave( ).
ENDCASE.

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_01.clas.xml
Original file line number Diff line number Diff line change
@@ -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>Z2UI5_CL_DEMO_APP_LP_01</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>launchpad I - Startup Parameters</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
60 changes: 60 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_02.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
CLASS z2ui5_cl_demo_app_lp_02 DEFINITION PUBLIC.

PUBLIC SECTION.
INTERFACES z2ui5_if_app.

DATA mv_title TYPE string VALUE `my title`.
DATA check_initialized TYPE abap_bool.

PROTECTED SECTION.

PRIVATE SECTION.
ENDCLASS.



CLASS Z2UI5_CL_DEMO_APP_LP_02 IMPLEMENTATION.


METHOD z2ui5_if_app~main.
IF check_initialized = abap_false.
check_initialized = abap_true.

IF client->get( )-check_launchpad_active = abap_false.
client->message_box_display( `No Launchpad Active, Sample not working!` ).
ENDIF.

DATA(shell) = z2ui5_cl_xml_view=>factory( )->shell( ).
IF client->get( )-check_launchpad_active = abap_true.
DATA(page) = shell->page( showheader = abap_false ).
page->_z2ui5( )->lp_title( client->_bind_edit( mv_title ) ).
ELSE.
page = shell->page( title = client->_bind_edit( mv_title ) ).
ENDIF.

client->view_display( page->simple_form( title = 'Set Launchpad Title Dynamically' editable = abap_true
)->content( 'form'
)->label( ``
)->input( client->_bind_edit( mv_title )
)->label( ``
)->button( text = 'Go Back'
press = client->_event( val = 'BACK' ) )->stringify( ) ).

ENDIF.

CASE client->get( )-event.

WHEN 'READ_PARAMS'.
DATA(lv_text) = `Start Parameter: `.
DATA(lt_params) = client->get( )-t_comp_params.
LOOP AT lt_params INTO DATA(ls_param).
lv_text = |{ lv_text } / { ls_param-n } = { ls_param-v }|.
ENDLOOP.
client->message_box_display( lv_text ).

WHEN 'BACK'.
client->nav_app_leave( ).
ENDCASE.

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_02.clas.xml
Original file line number Diff line number Diff line change
@@ -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>Z2UI5_CL_DEMO_APP_LP_02</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>launchpad II - Set Title</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
83 changes: 83 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_03.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
CLASS z2ui5_cl_demo_app_lp_03 DEFINITION PUBLIC.

PUBLIC SECTION.

INTERFACES z2ui5_if_app.

* DATA product TYPE string.
* DATA quantity TYPE string.
DATA check_initialized TYPE abap_bool.

DATA:
BEGIN OF nav_params,
product TYPE string,
quantity TYPE string,
END OF nav_params.

PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.



CLASS z2ui5_cl_demo_app_lp_03 IMPLEMENTATION.


METHOD z2ui5_if_app~main.

DATA(lt_startup_params) = client->get( )-s_config-t_startup_params.

IF check_initialized = abap_false.
check_initialized = abap_true.

nav_params-product = '102343333'.

IF client->get( )-check_launchpad_active = abap_false.
client->message_box_display( `No Launchpad Active, Sample not working!` ).
ENDIF.

DATA(view) = z2ui5_cl_xml_view=>factory( ).
client->view_display( view->shell(
)->page(
showheader = xsdbool( abap_false = client->get( )-check_launchpad_active )
title = 'abap2UI5 - Cross App Navigation App 127 - This App only works when started via Launchpad'
navbuttonpress = client->_event( val = 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
)->header_content(
)->link(
text = 'Source_Code'

target = '_blank'
)->get_parent(
)->simple_form( title = 'App 127' editable = abap_true
)->content( 'form'
)->label( `Product`
)->input( client->_bind_edit( nav_params-product )
)->button( text = 'BACK' press = client->_event_client( client->cs_event-cross_app_nav_to_prev_app )
)->button(
text = 'go to app 128'
press = client->_event_client(
val = client->cs_event-cross_app_nav_to_ext
t_arg = VALUE #(
( `{ semanticObject: "Z2UI5_CL_LP_SAMPLE_04", action: "display" }` )
* ( `{ "Product" : "102343333" }` )
( `$` && client->_bind_edit( nav_params ) )
)
)
)->stringify( ) ).

ENDIF.

CASE client->get( )-event.

WHEN 'BUTTON_POST'.

* client->message_toast_display( |{ product } { quantity } - send to the server| ).

WHEN 'BACK'.
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).

ENDCASE.

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_03.clas.xml
Original file line number Diff line number Diff line change
@@ -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>Z2UI5_CL_DEMO_APP_LP_03</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Launchpad III - cross app navigation I</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
85 changes: 85 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_04.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
CLASS z2ui5_cl_demo_app_lp_04 DEFINITION PUBLIC.

PUBLIC SECTION.

INTERFACES z2ui5_if_app.

DATA product TYPE string.
DATA product_url TYPE string.
DATA quantity TYPE string.
DATA check_initialized TYPE abap_bool.
DATA check_launchpad_active TYPE abap_bool.

PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.



CLASS z2ui5_cl_demo_app_lp_04 IMPLEMENTATION.


METHOD z2ui5_if_app~main.

DATA(view) = z2ui5_cl_xml_view=>factory( ).
product_url = z2ui5_cl_util=>url_param_get(
val = `product`
url = client->get( )-s_config-search ).
check_launchpad_active = client->get( )-check_launchpad_active.

data(lt_params) = client->get( )-t_comp_params.
try.
product = lt_params[ n = `PRODUCT` ]-v.
catch cx_root.
endtry.
IF check_initialized = abap_false.
check_initialized = abap_true.

quantity = '500'.

client->view_display( view->shell(
)->page(
showheader = xsdbool( abap_false = client->get( )-check_launchpad_active )
title = 'abap2UI5 - Cross App Navigation App 128'
navbuttonpress = client->_event( val = 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
)->header_content(
)->link(
text = 'Source_Code'

target = '_blank'
)->get_parent(
)->simple_form( title = 'App 128' editable = abap_true
)->content( 'form'
)->title( 'Input'
)->label( 'product nav param'
)->input( client->_bind_edit( product )
)->label( `CHECK_LAUNCHPAD_ACTIVE`
)->input( check_launchpad_active
)->button( press = client->_event( )
)->button( text = 'BACK' press = client->_event_client( client->cs_event-cross_app_nav_to_prev_app )
)->button(
text = 'go to app 127'
press = client->_event_client(
val = client->cs_event-cross_app_nav_to_ext
t_arg = VALUE #( ( `{ semanticObject: "Z2UI5_CL_LP_SAMPLE_03", action: "display" }` ) ( `{ ProductID : "123234" }`) )
)
)->stringify( ) ).

ENDIF.

client->view_model_update( ).

CASE client->get( )-event.

WHEN 'BUTTON_POST'.

* client->message_toast_display( |{ product } { quantity } - send to the server| ).

WHEN 'BACK'.
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).

ENDCASE.

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/01/z2ui5_cl_demo_app_lp_04.clas.xml
Original file line number Diff line number Diff line change
@@ -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>Z2UI5_CL_DEMO_APP_LP_04</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Launchpad IV - cross app navigation II</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

0 comments on commit 3746058

Please sign in to comment.