Project

General

Profile

Bug #4907

implement triggers phrase support

Added by Vladimir Tsichevski about 6 years ago. Updated 5 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

Related issues

Related to User Interface - Bug #6028: Define rectangle widget: triggers section is not converted and other issues New

History

#1 Updated by Vladimir Tsichevski about 6 years ago

The trigger, associated with a button is not converted.

The 4gl:

main.p

DEFINE FRAME theFrame
   WITH SIZE 30 BY 10.

DEFINE BUTTON applyFormat LABEL "Apply" 
  TRIGGERS:
    ON CHOOSE DO:
       MESSAGE "Hello".
    END.
  END TRIGGERS.

ENABLE applyFormat WITH FRAME theFrame.

VIEW FRAME theFrame.
WAIT-FOR GO OF FRAME theFrame.

The conversion result (no trace of the trigger code):

package com.test3820;
import com.goldencode.p2j.util.*;
import com.test3820.ui.*;
import com.goldencode.p2j.ui.*;
import static com.goldencode.p2j.util.BlockManager.*;
import static com.goldencode.p2j.util.InternalEntry.Type;
import static com.goldencode.p2j.ui.LogicalTerminal.*;

/**
 * Business logic (converted to Java from the 4GL source code
 * in main.p).
 */

public class Main
{
   MainTheframe theframeFrame = GenericFrame.createFrame(MainTheframe.class, "theFrame");

   /**
    * External procedure (converted to Java from the 4GL source code
    * in main.p).
    */

   @LegacySignature(type = Type.MAIN, name = "main.p")

   public void execute()

   {
      externalProcedure(Main.this, new Block((Body) () -> 
      {
         theframeFrame.openScope();
         FrameElement[] elementList0 = new FrameElement[]
         {
            new WidgetElement(theframeFrame.widgetApplyFormat())
         };
         theframeFrame.enable(elementList0);
         theframeFrame.view();
         LogicalTerminal.waitFor(theframeFrame, new EventList("GO", theframeFrame.asWidget()));
      }));
   }
}

In OW the 4gl above works as expected: pressing the button prints "Hello".

#2 Updated by Greg Shah about 6 years ago

I guess this is related to the TRIGGERS phrase which is not as commonly used as the ON statement.

As a workaround, just move the trigger outside of the triggers phrase and into an ON statement.

ON CHOOSE OF applyFormat DO:
   MESSAGE "Hello".
END.

#3 Updated by Vladimir Tsichevski about 6 years ago

Greg Shah wrote:

I guess this is related to the TRIGGERS phrase which is not as commonly used as the ON statement.

As a workaround, just move the trigger outside of the triggers phrase and into an ON statement.

[...]

Yes, if I rewrite the example as following, it compiles and works as expected:

DEFINE BUTTON applyFormat LABEL "Apply".

DEFINE FRAME theFrame
   applyFormat
   WITH SIZE 30 BY 10.

ON CHOOSE OF applyFormat
DO:
   MESSAGE "Hello".
END.

ENABLE applyFormat WITH FRAME theFrame.

VIEW FRAME theFrame.
WAIT-FOR GO OF FRAME theFrame.

#4 Updated by Greg Shah about 6 years ago

The problem is most likely in rules/annotations/triggers_phrase_rewrite.rules. This code:

      <!-- ON phrase for a trigger inside a TRIGGERS block of a CREATE WIDGET/BROWSE

      Rewrites

      TRIGGERS                           STATEMENT
         ON                                 ON
            EVENT_LIST                         OF
               EVENT             to               EVENT_LIST
            TRIGGER_BLOCK                            EVENT
                                                  WIDGET_LIST
                                                     VAR_HANDLE
                                               TRIGGER_BLOCK
      -->
      <rule>relativePath("STATEMENT/CREATE_WIDGET/KW_TRIGGERS/KW_ON") or
            relativePath("STATEMENT/CREATE_BROWSE/KW_TRIGGERS/KW_ON")
...

Notice that it only processing for CREATE <widget> and CREATE BROWSE cases. It ignores other cases. Searching for trigger_phrase in progress.g shows that it can be matched in the following other constructs: DEFINE VARIABLE, DEFINE BUTTON, DEFINE RECTANGLE and in the menu item phrase of a DEFINE MENU or DEFINE SUB-MENU.

The solution is to add cases to the above matching logic and to make some modifications to the re-parenting code for the "non-handle" statement cases.

#5 Updated by Greg Shah about 6 years ago

  • Project changed from Conversion Tools to User Interface
  • Start date deleted (09/18/2020)

#6 Updated by Greg Shah 5 days ago

  • Related to Bug #6028: Define rectangle widget: triggers section is not converted and other issues added

#7 Updated by Greg Shah 5 days ago

  • Subject changed from Conversion bug with button triggers to implement triggers phrase support

The intention of this task is to implement support for the TRIGGERS phrase on all widgets, not just button. This will include the work previously discussed in #6028 for RECTANGLE.

Also available in: Atom PDF