Project

General

Profile

6764.05.patch

Marian Edu, 11/10/2022 07:05 AM

Download (14.1 KB)

View differences:

new/src/com/goldencode/p2j/ui/EventDefinition.java 2022-11-10 11:50:56 +0000
65 65
**     SBI 20211024          Added containsWidget(int) method.
66 66
**     ME  20220928          Rewrite trigger lookup, move some of the logic in EventList.
67 67
**         20221003          Remove 'global anywhere' (derived), use scope self/anywhere on lookup.
68
**         20221026          Check function key code in isEventUniversal in case label key code was used.
68 69
**/
69 70

  
70 71
/*
......
439 440
                           eventCode == Keyboard.KA_END_ERROR ||
440 441
                           eventCode == Keyboard.KA_STOP);
441 442
      
443
      if (!universal) {
444
         eventCode = Keyboard.eventCode(Keyboard.keyFunction(eventCode));
445
         
446
         return eventCode != -1 && isEventUniversal(eventCode);
447
      }
448
      
442 449
      return universal;
443 450
   }
444 451

  
new/src/com/goldencode/p2j/ui/EventList.java 2022-11-10 11:50:56 +0000
169 169
**         20221003          Build events bitmap and resolve function key code in lookupWorker, avoid looping 
170 170
**                           through widget's parents chain if there is no event registered for the code.
171 171
**     HC  20221017          Fixed ANYWHERE event lookup.
172
**     ME  20221026          Fixed addEvent/ctors in respect to ANYWHERE default.
172 173
*/
173 174

  
174 175
/*
......
616 617
   }
617 618
   
618 619
   /**
619
    * Constructor that adds the given event definition.
620
    * Constructor that adds the given event definition - global anywhere.
620 621
    * <p> 
621 622
    * Event names are case-insensitive on input and stored uppercased.
622 623
    *
......
625 626
    */
626 627
   public EventList(String[] event)
627 628
   {
628
      addEvent(event, (GenericWidget[])null, false);
629
      addEvent(event, (GenericWidget[])null, true);
629 630
   }
630 631

  
631 632
   /**
632
    * Constructor that adds the given event definition.
633
    * Constructor that adds the given event definition - global anywhere.
633 634
    * <p> 
634 635
    * Event names are case-insensitive on input and stored uppercased.
635 636
    *
636 637
    * @param    event
637 638
    *           An array of event names.
638 639
    * @param    anywhere
639
    *           <code>true</code> if the global ANYWHERE option is being set.
640
    *           ignored since all non-widget events are global ANYWHERE.
640 641
    */
642
   @Deprecated
641 643
   public EventList(String[] event, boolean anywhere)
642 644
   {
643
      addEvent(event, (GenericWidget[])null, false);
645
      addEvent(event, (GenericWidget[])null, true);
644 646
   }
645 647

  
646 648
   /**
647
    * Constructor that adds the given event definition.
649
    * Constructor that adds the given event definition - global anywhere.
648 650
    * <p> 
649 651
    * Event names are case-insensitive on input and stored uppercased.
650 652
    *
......
653 655
    */
654 656
   public EventList(String event)
655 657
   {
656
      addEvent(new String[] {event}, (GenericWidget[])null, false);
658
      addEvent(event, (GenericWidget[])null, true);
657 659
   }
658 660

  
659 661
   /**
660
    * Constructor that adds the given event definition. If the ANYWHERE keyword was used, the
661
    * appropriate flag is set for this entry.
662
    * Constructor that adds the given event definition - global anywhere.
662 663
    * <p>
663 664
    * Event names are case-insensitive on input and stored uppercased.
664 665
    *
665 666
    * @param    event
666 667
    *           The event name.
667 668
    * @param    anywhere
668
    *           <code>true</code> if the global ANYWHERE option is being set.
669
    *           ignored since all non-widget events are global ANYWHERE.
669 670
    */
671
   @Deprecated
670 672
   public EventList(String event, boolean anywhere)
671 673
   {
672
      addEvent(new String[] {event}, (GenericWidget[])null, anywhere);
674
      addEvent(new String[] {event}, (GenericWidget[])null, true);
673 675
   }
674 676

  
675 677
   /**
......
1118 1120
   }
1119 1121
   
1120 1122
   /**
1121
    * Adds an event definition to the list.
1123
    * Adds an event definition to the list - global anywhere.
1122 1124
    * <p> 
1123 1125
    * Event names are case-insensitive on input and stored uppercased.
1124 1126
    *
......
1127 1129
    */
1128 1130
   public void addEvent(String[] event)
1129 1131
   {
1130
      addEvent(event, (GenericWidget[])null, false);
1132
      addEvent(event, (GenericWidget[])null, true);
1131 1133
   }
1132 1134

  
1133 1135
   /**
1134
    * Adds an event definition to the list.
1136
    * Adds an event definition to the list - global anywhere.
1135 1137
    * <p> 
1136 1138
    * Event names are case-insensitive on input and stored uppercased.
1137 1139
    *
1138 1140
    * @param    event
1139 1141
    *           An array of event names.
1140 1142
    * @param    anywhere
1141
    *           <code>true</code> if the global ANYWHERE option is being set.
1143
    *           ignored since all non-widget events are global ANYWHERE.
1142 1144
    */
1145
   @Deprecated
1143 1146
   public void addEvent(String[] event, boolean anywhere)
1144 1147
   {
1145
      addEvent(event, (GenericWidget[])null, false);
1148
      addEvent(event, (GenericWidget[])null, true);
1146 1149
   }
1147 1150

  
1148 1151
   /**
1149
    * Adds an event definition to the list.
1152
    * Adds an event definition to the list - global anywhere.
1150 1153
    * <p> 
1151 1154
    * Event names are case-insensitive on input and stored uppercased.
1152 1155
    *
......
1155 1158
    */
1156 1159
   public void addEvent(String event)
1157 1160
   {
1158
      addEvent(new String[] {event}, (GenericWidget[])null, false);
1161
      addEvent(new String[] {event}, (GenericWidget[])null, true);
1159 1162
   }
1160 1163

  
1161 1164
   /**
1162
    * Adds an event definition to the list.
1165
    * Adds an event definition to the list - global anywhere.
1163 1166
    * <p> 
1164 1167
    * Event names are case-insensitive on input and stored uppercased.
1165 1168
    *
1166 1169
    * @param    event
1167 1170
    *           The event name.
1168 1171
    * @param    anywhere
1169
    *           <code>true</code> if the global ANYWHERE option is being set.
1172
    *           ignored since all non-widget events are global ANYWHERE.
1170 1173
    */
1174
   @Deprecated
1171 1175
   public void addEvent(String event, boolean anywhere)
1172 1176
   {
1173
      addEvent(new String[] {event}, (GenericWidget[])null, anywhere);
1177
      addEvent(new String[] {event}, (GenericWidget[])null, true);
1174 1178
   }
1175 1179

  
1176 1180
   /**
new/src/com/goldencode/p2j/ui/LogicalTerminal.java 2022-11-10 11:58:03 +0000
1013 1013
**     CA  20220906          Moved the interactive client cleaner to LogicalTerminal.registerCleaner().
1014 1014
**     EVL 20221007          Adding runtime support for SESSION:LOAD-ICON.
1015 1015
**     TJD 20220504          Java 11 compatibility related minor changes
1016
**     ME  20221110          Avoid NPE on client when invalid code used in apply.
1016 1017
*/
1017 1018

  
1018 1019
/*
......
7979 7980
         return;
7980 7981
      }
7981 7982

  
7983
      if (eventCode == -1)
7984
      {
7985
         // not valid event code, it will throw error on the client
7986
         return;
7987
      }
7988
      
7982 7989
      ScreenBuffer sb[] = null;
7983 7990
      
7984 7991
      LogicalTerminal lt = locate();
new/src/com/goldencode/p2j/ui/chui/ThinClient.java 2022-11-10 11:55:42 +0000
20492 20492
         cur = src;
20493 20493
      }
20494 20494

  
20495
      boolean defaultHelp = true;
20495
      boolean defaultHelp = action == Keyboard.KA_HELP;
20496 20496
      boolean foundGo = false;
20497 20497
      boolean exceptionalExit = false;
20498 20498

  
......
20623 20623
         tr = invokeTriggers(src, key, evt.isRealKey());
20624 20624

  
20625 20625
         if (tr.executed)
20626
         {
20626
         {  
20627 20627
            evt.setTriggerFired();
20628
            
20629
            // if trigger was set for a key that maps to endkey/end-error (ESC) 
20630
            // consume it and do not handle it like stop
20631
            if (exceptionalExit)
20632
            {
20633
               evt.consume();
20634
               return;
20635
            }
20628
            // reset default help behavior if trigger registered
20629
            defaultHelp = false;
20636 20630
         }
20637 20631

  
20638 20632
         if (tr.consume)
......
20649 20643
      }
20650 20644

  
20651 20645
      // other high level events
20652
      if ((tr == null || !tr.executed) && key != action &&
20653
          action != Keyboard.SE_ENTRY)
20646
      if ((tr == null || !tr.consume))
20654 20647
      {
20655
         Widget target = src;
20656
         Browse brws = (Browse) src.parent(Browse.class);
20657
         
20658
         tr = invokeTriggers(target, event.other(), action, false);
20659

  
20660
         if (tr.executed)
20661
         {
20662
            evt.setTriggerFired();
20663
         }
20664

  
20665
         if (action == Keyboard.KA_HELP)
20666
         {
20667
            // if there was no widget-level trigger, try the frame
20668
            // TODO: this needs to be more generic because surely there are
20669
            //       other events that bubble
20670
            if (!tr.executed && !(target instanceof Frame))
20671
            {
20672
               if (brws != null && target != brws)
20673
               {
20674
                  // in this case, try the browse too
20675
                  tr = invokeTriggers(brws, event.other(), action, false);
20676
               }
20677
               
20678
               if (!tr.executed)
20679
               {
20680
                  // TODO: check if child frames/parent frame bubbling works
20681
                  // TODO: check if the window needs to be supported
20682
                  Widget<?> frm = UiUtils.locateFrame(target);
20683
                  
20684
                  if (frm != null)
20685
                  {
20686
                     tr = invokeTriggers(frm, event.other(), action, false);
20687
                  }
20688
               }
20689
            }
20690
            
20691
            if (tr.executed)
20692
            {
20693
               // execution of a HELP trigger is implicitly RETURN NO-APPLY
20694
               tr.consume = true;
20695
               defaultHelp = false;
20648
         // universal events slip into parent frame only unless consumed
20649
         if (EventDefinition.isEventUniversal(key))
20650
         {
20651
            Widget<?> srcFrame = UiUtils.locateFrame(src);
20652

  
20653
            if (srcFrame != null)
20654
            {
20655
               // use specificWidget as it doesn't need to go up the parents chain
20656
               tr = invokeTriggers(srcFrame, null, -1, key, true, true, null, null);
20696 20657
            }
20697 20658
         }
20698 20659

  
20699 20660
         // let widget perform "hard" check if necessary
20700
         if (action == Keyboard.SE_LEAVE && src instanceof FillIn)
20661
         if (key != action && action == Keyboard.SE_LEAVE && src instanceof FillIn)
20701 20662
         {
20702 20663
            src.processKeyEvent(evt);
20703 20664

  
......
20717 20678
            return;
20718 20679
         }
20719 20680
      }
20720

  
20721
      // check for possible ANY-KEY
20722
      if ((tr == null || !tr.executed) && evt != null && evt.isRealKey() && evt.id() != EventType.KEY_RELEASED)
20723
      {
20724
         tr = invokeTriggers(src, key, true);
20725

  
20726
         if (tr.consume)
20727
         {
20728
            evt.consume();
20729

  
20730
            if (foundGo)
20731
            {
20732
               subGoPending();
20733
               leaveSent = false;
20734
            }
20735
            return;
20736
         }
20737
      }
20738

  
20681
      
20739 20682
      // disable all following logic if this is a drop-down portion of a
20740 20683
      // combo-box
20741 20684
      if (src instanceof ScrollableList)
......
21224 21167
      // a standard input key (A, B, and so on)
21225 21168

  
21226 21169
      // HELP action
21227
      if (isGoPending == 0 && action == Keyboard.KA_HELP && defaultHelp)
21170
      if (isGoPending == 0 && defaultHelp)
21228 21171
      {
21229 21172
         requestHelp();
21230 21173
      }
......
21589 21532
                                        Integer   eventX,
21590 21533
                                        Integer   eventY)
21591 21534
   {
21535
      return invokeTriggers(widget, other, resourceId, evtCode, isKey, false, eventX, eventY);
21536
   }
21537
   
21538
   /**
21539
    * Check active <code>EventList</code> instance for triggers defined
21540
    * for this event and widget pair and activate the first one found.
21541
    * <p>
21542
    * Triggers are searched either for a specific widget, or, if no widget is
21543
    * enabled (in focus), for the session window. The latter is also performed
21544
    * if the specific widget happens to be the session window.
21545
    * <p>
21546
    * The specific search is done in the following order:
21547
    * <ul>
21548
    *  <li>trigger for the specified widget and event;
21549
    *  <li>trigger for the specified event anywhere within the frame;
21550
    *  <li>trigger for the specified event anywhere globally.
21551
    * </ul>
21552
    * <p>
21553
    * The search for the session window is a one step process.
21554
    * <p>
21555
    * The first found trigger, if any, gets activated.
21556
    *
21557
    * @param   widget
21558
    *          event source.
21559
    * @param   other
21560
    *          a companion widget (for ENTER/LEAVE events).
21561
    * @param   resourceId
21562
    *          When not set to -1, is a valid resource ID (for non-widget events).
21563
    * @param   evtCode
21564
    *          event code.
21565
    * @param   isKey
21566
    *          This flags marks reals keys typed by user.
21567
    * @param   specificWidget
21568
    *          This flags checks only for the triggers on specific widget.
21569
    * @param   eventX
21570
    *          The value of LAST-EVENT:X attribute; <code>null</code> if not used.
21571
    * @param   eventY
21572
    *          The value of LAST-EVENT:Y attribute; <code>null</code> if not used.
21573
    *
21574
    * @return  Execution and event consume flags for an executed trigger.
21575
    */
21576
   private TriggerResult invokeTriggers(Widget    widget,
21577
                                        Widget    other,
21578
                                        long      resourceId,
21579
                                        int       evtCode,
21580
                                        boolean   isKey,
21581
                                        boolean   specificWidget,
21582
                                        Integer   eventX,
21583
                                        Integer   eventY)
21584
   {
21592 21585
      // this method must not be called for mouse events on virtual widgets; for key presses, 
21593 21586
      // this is allowed because ANY-KEY triggers need to be reached.
21594 21587

  
......
21652 21645
      {
21653 21646
         Widget container = UiUtils.locateContainer(widget);
21654 21647
         
21655
         currentEventList.lookup(container != null && container != frame ? UiUtils.getWidgetIdAsInt(container) : frameId, widgetId, true, isKey, result);
21648
         currentEventList.lookup(container != null && container != frame ? UiUtils.getWidgetIdAsInt(container) : frameId, widgetId, true, isKey, specificWidget, result);
21656 21649
      }
21657 21650

  
21658 21651
      // activate trigger