7 Replies Latest reply on May 9, 2019 4:51 AM by Kashif Shabbir

    Color enhacement - Current Item Example

    Kashif Shabbir

      Hi

      Found this piece of code to change the background color of current text item.

      Current_item_color.jpg

      Please can any one tell me that how to use this.

      at which place/trigger i have to apply this PL/SQL code?

      Michael Ferrante-Oracle, Please can u help me, because this document was written by you.

        • 1. Re: Color enhacement - Current Item Example
          Michael Ferrante-Oracle

          It's fairly easy to use.

           

          1.  Create two Visual Attributes.  One named VA_SET and one named VA_UNSET

           

          2.  In VA_UNSET, set the attributes as desired for when the item is not the current item.  For example, black foreground and a white background (and any other desired settings)

           

          3.  In VA_SET, set the attributes as desired for when the item is the current item. For example, set the background color to yellow or other noticeable color. You can even use one of the colorscheme colors.  For example, try setting background color to one of the OLAF colors.  This will pick up colors from the "colorscheme" palette.  The image below is the palette for SWAN  Setting the font weight to bold is also helpful.

           

          4.  Create a form or block level WHEN-NEW-ITEM-INSTANCE trigger with the code from the example.

           

          • 2. Re: Color enhacement - Current Item Example
            Kashif Shabbir

            Thank you so much.

            I was using the same functionality by using the POST-TEXT-ITEM and PRE-TEXT-ITM to SET and UN-SET the current item Visual Attribute.

            PRE.png

            post.png

             

            But by using your code I can do it in Single Trigger.

            • 3. Re: Color enhacement - Current Item Example
              Kashif Shabbir

              Just Implemented your code using WHEN-NEW-ITEM-INSTANCE trigger.

              It has a logical bug.

              It does not UN-SET the Current item's VA if Next Item is other than TEXT ITEM.

              • 4. Re: Color enhacement - Current Item Example
                Michael Ferrante-Oracle

                This seems like an easy fix.  I've reviewed the code and simplified it a bit, as well as addressing the issue you mentioned.

                 

                Declare
                    ui_type varchar2(11);
                Begin
                -- Set defaults for globals
                    Default_Value(:system.cursor_item,'global.prev_item');
                    Default_Value(:system.cursor_record,'global.prev_record');
                
                -- Only change colors if item is a TEXT ITEM
                    ui_type := GET_ITEM_PROPERTY(:system.cursor_item, ITEM_TYPE);
                   
                        -- Is the cursor item a text item?
                                    If upper(ui_type) = 'TEXT ITEM' Then
                                        -- Reset the background color of the item just exited
                                        set_item_instance_property(:global.prev_item, to_number(:global.prev_record), VISUAL_ATTRIBUTE,'VA_UNSET');
                                        -- Set the new background color   
                                        set_item_instance_property(:system.cursor_item, current_record, VISUAL_ATTRIBUTE,'VA_SET');                       
                                   
                                    Else
                                        -- Reset the background color of the previous item when current is not text
                                        set_item_instance_property(:global.prev_item, to_number(:global.prev_record), VISUAL_ATTRIBUTE,'VA_UNSET');                                   
                                    End if;
                   
                                -- Prepare for next item instance. Set previous item to the current item   
                                :global.prev_item := :system.cursor_item;
                                :global.prev_record := :system.cursor_record;
                End;
                
                • 5. Re: Color enhacement - Current Item Example
                  Kashif Shabbir

                  Can you please explain? Whats is OLAF colors and how to use it?

                  • 6. Re: Color enhacement - Current Item Example
                    Michael Ferrante-Oracle

                    The OLAF (Oracle Look and Feel) colors represent the virtual colors used by the colorSchemes. Being able to access these colors allows you to use colors that were designed to complement each other rather than choosing randomly selected colors on your own.  The valid OLAF colors that can be used as a value in place of actual colors (e.g. red, blue, etc) are:

                     

                    • OLAFVeryLight
                    • OLAFLight
                    • OLAFDark
                    • OLAFVery
                    • OLAF0
                    • OLAF1
                    • OLAF2
                    • OLAF3
                    • OLAF4

                     

                    Refer to the Builder Help in Forms 12.2.1.3.  Specifically look at the Help for Background or Foreground Color Property

                     

                    Also, take a look at MyOracle Support Note 2367517.1  This note provides a hint as to what the provided palette colors include.