abap2UI5

Busy Indicator

A busy indicator can be used to block the entire screen until an operation has finished.

Z2UI5_CL_SMPC_APP_147

Controls sap.ui.core UI5 1.71

The facts

Repository
abap2UI5/samples-controls
Class
Z2UI5_CL_SMPC_APP_147
Source file
z2ui5_cl_smpc_app_147.clas.abap
Library
sap.ui.core
UI5 entity
sap.ui.core.BusyIndicator
Demo kit sample
sap.ui.core.sample.BusyIndicator
SAP's own sample
running at sdk.openui5.org ↗
Minimum UI5
1.71 — the floor abap2UI5 holds its samples to
In the playground
runs in the browser, with no system and nothing installed

Keywords: busyindicator, busy, indicator, sap.ui.core, global, panel, text, button

Controls it builds

Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.

Libraries

Run it here

The sample running, in this page — the app on its own, with no editor over it. Switch to Playground with this code

Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.

The ABAP

z2ui5_cl_smpc_app_147.clas.abap — 124 lines Read it on GitHub ↗
" @keywords busyindicator busy indicator sap.ui.core global panel text button
" @summary A busy indicator can be used to block the entire screen until an operation has finished.
CLASS z2ui5_cl_smpc_app_147 DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

  PROTECTED SECTION.
    DATA client TYPE REF TO z2ui5_if_client.

    METHODS view_display.
    METHODS on_event.

  PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_smpc_app_147 IMPLEMENTATION.

  METHOD z2ui5_if_app~main.

    me->client = client.
    IF client->check_on_navigated( ).
      view_display( ).
    ELSEIF client->check_on_event( ).
      on_event( ).
    ENDIF.

  ENDMETHOD.


  METHOD view_display.

    DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).

    view->ele( n = `View` ns = `mvc`
        )->a( n = `height`     v = `100%`
        )->a( n = `xmlns:core` v = `sap.ui.core`
        )->a( n = `xmlns:mvc`  v = `sap.ui.core.mvc`
        )->a( n = `xmlns`      v = `sap.m`

        )->ele( `Page`
            )->a( n = `class`      v = `sapUiFioriObjectPage`
            )->a( n = `showHeader` v = `false`

            )->ele( `content`
                )->ele( `Panel`
                    )->tag( `Text`
                        )->a( n = `text` v = `Press a button to show the global BusyIndicator`

                )->end(

                )->ele( `Panel`
                    )->a( n = `headerText` v = `Open BusyIndicator for four seconds (default delay, which is 1 second)`
                    )->ele( `content`
                        )->tag( `Button`
                            )->a( n = `text`  v = `Show BusyIndicator`
                            )->a( n = `press` v = client->_event( `SHOW_4000` )

                    )->end(
                )->end(

                )->ele( `Panel`
                    )->a( n = `headerText` v = `Open BusyIndicator for four seconds (zero delay)`
                    )->ele( `content`
                        )->tag( `Button`
                            )->a( n = `text`  v = `Show BusyIndicator`
                            )->a( n = `press` v = client->_event( `SHOW_4000_0` )

                    )->end(
                )->end(

                )->ele( `Panel`
                    )->a( n = `headerText` v = `Open BusyIndicator for one second (two seconds delay, so it should never appear at all)`
                    )->ele( `content`
                        )->tag( `Button`
                            )->a( n = `text`  v = `Show BusyIndicator`
                            )->a( n = `press` v = client->_event( `SHOW_1000_2000` ) ).

    client->view_display( view->stringify( ) ).

  ENDMETHOD.


  METHOD on_event.

    " original showBusyIndicator(iDuration, iDelay): BusyIndicator.show(iDelay)
    " plus a setTimeout that hides it after iDuration - reproduced with the
    " BUSY_INDICATOR global target and START_TIMER (a new timer replaces the
    " previous one, matching the original's clearTimeout of _sTimeoutId)
    CASE client->get_event( ).

      WHEN `SHOW_4000`.
        " show4000: default delay (1 second), hide after 4 seconds
        client->follow_up_action( val   = client->cs_event-control_global
                                  t_arg = VALUE #( ( `BUSY_INDICATOR` ) ( `show` ) ) ).
        client->follow_up_action( val   = client->cs_event-start_timer
                                  t_arg = VALUE #( ( `HIDE_BUSY` ) ( `4000` ) ) ).

      WHEN `SHOW_4000_0`.
        " show4000_0: zero delay, hide after 4 seconds
        client->follow_up_action( val   = client->cs_event-control_global
                                  t_arg = VALUE #( ( `BUSY_INDICATOR` ) ( `show` ) ( `0` ) ) ).
        client->follow_up_action( val   = client->cs_event-start_timer
                                  t_arg = VALUE #( ( `HIDE_BUSY` ) ( `4000` ) ) ).

      WHEN `SHOW_1000_2000`.
        " show1000_2000: two seconds delay, hide after one second - the
        " indicator should never appear at all
        client->follow_up_action( val   = client->cs_event-control_global
                                  t_arg = VALUE #( ( `BUSY_INDICATOR` ) ( `show` ) ( `2000` ) ) ).
        client->follow_up_action( val   = client->cs_event-start_timer
                                  t_arg = VALUE #( ( `HIDE_BUSY` ) ( `1000` ) ) ).

      WHEN `HIDE_BUSY`.
        " the timer callback - hideBusyIndicator
        client->follow_up_action( val   = client->cs_event-control_global
                                  t_arg = VALUE #( ( `BUSY_INDICATOR` ) ( `hide` ) ) ).

    ENDCASE.

  ENDMETHOD.

ENDCLASS.

More in sap.ui.core

Search every abap2UI5 sample · the full list on one page

On this page