Project

General

Profile

6764.08.patch

Marian Edu, 12/16/2022 08:49 AM

Download (15.6 KB)

View differences:

new/src/com/goldencode/p2j/ui/EventDefinition.java 2022-12-16 08:20:24 +0000
64 64
**     CA  20211005          Set the matchedWidgetId when lookup is performed.
65 65
**     SBI 20211024          Added containsWidget(int) method.
66 66
**     ME  20220928          Rewrite trigger lookup, move some of the logic in EventList.
67
**         20221003          Remove 'global anywhere' (derived), use scope self/anywhere on lookup.
67
**     ME  20221003          Remove 'global anywhere' (derived), use scope self/anywhere on lookup.
68
**     ME  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-12-16 08:20:24 +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-12-16 08:25:03 +0000
1014 1014
**     EVL 20221007          Adding runtime support for SESSION:LOAD-ICON.
1015 1015
**     TJD 20220504          Java 11 compatibility related minor changes
1016 1016
**     SBI 20221110          Added getSupportedHelperApplications().
1017
**     ME  20221110          Avoid NPE on client when invalid code used in apply.
1017 1018
**     HC  20221114          Improved URL handling of the HTML browser whitelist.
1018 1019
**     EVL 20221118          Adding support for new non-blocking mode in SESSION:SET-WAIT-STATE.
1019 1020
**     EVL 20221121          Typo fix for setWaitState().
......
7990 7991
         return;
7991 7992
      }
7992 7993

  
7994
      if (eventCode == -1)
7995
      {
7996
         // not valid event code, it will throw error on the client
7997
         return;
7998
      }
7999
      
7993 8000
      ScreenBuffer sb[] = null;
7994 8001
      
7995 8002
      LogicalTerminal lt = locate();
new/src/com/goldencode/p2j/ui/chui/ThinClient.java 2022-12-16 09:34:30 +0000
20529 20529
         cur = src;
20530 20530
      }
20531 20531

  
20532
      boolean defaultHelp = true;
20532
      boolean defaultHelp = action == Keyboard.KA_HELP;
20533 20533
      boolean foundGo = false;
20534 20534
      boolean exceptionalExit = false;
20535 20535

  
......
20658 20658
      if (key > 0 && key != KeyInput.CHAR_UNDEFINED && evt.id() != EventType.KEY_RELEASED)
20659 20659
      {
20660 20660
         tr = invokeTriggers(src, key, evt.isRealKey());
20661

  
20662
         if (tr.executed)
20663
         {
20664
            evt.setTriggerFired();
20665
            
20666
            // if trigger was set for a key that maps to endkey/end-error (ESC) 
20667
            // consume it and do not handle it like stop
20668
            if (exceptionalExit)
20669
            {
20670
               evt.consume();
20671
               return;
20672
            }
20673
         }
20674

  
20675
         if (tr.consume)
20676
         {
20677
            evt.consume();
20678

  
20679
            if (foundGo)
20680
            {
20681
               subGoPending();
20682
               leaveSent = false;
20683
            }
20684
            return;
20685
         }
20661
      }
20662
      else
20663
      {
20664
         tr = invokeTriggers(src, action, evt.isRealKey());
20665
      }
20666

  
20667
      if (tr.executed)
20668
      {  
20669
         evt.setTriggerFired();
20670
         // reset default help behavior if trigger registered
20671
         defaultHelp = false;
20672
      }
20673

  
20674
      if (tr.consume)
20675
      {
20676
         evt.consume();
20677

  
20678
         if (foundGo)
20679
         {
20680
            subGoPending();
20681
            leaveSent = false;
20682
         }
20683
         return;
20686 20684
      }
20687 20685

  
20688 20686
      // other high level events
20689
      if ((tr == null || !tr.executed) && key != action &&
20690
          action != Keyboard.SE_ENTRY)
20687
      if ((tr == null || !tr.consume))
20691 20688
      {
20692
         Widget target = src;
20693
         Browse brws = (Browse) src.parent(Browse.class);
20694
         
20695
         tr = invokeTriggers(target, event.other(), action, false);
20696

  
20697
         if (tr.executed)
20698
         {
20699
            evt.setTriggerFired();
20700
         }
20701

  
20702
         if (action == Keyboard.KA_HELP)
20703
         {
20704
            // if there was no widget-level trigger, try the frame
20705
            // TODO: this needs to be more generic because surely there are
20706
            //       other events that bubble
20707
            if (!tr.executed && !(target instanceof Frame))
20708
            {
20709
               if (brws != null && target != brws)
20710
               {
20711
                  // in this case, try the browse too
20712
                  tr = invokeTriggers(brws, event.other(), action, false);
20713
               }
20714
               
20715
               if (!tr.executed)
20716
               {
20717
                  // TODO: check if child frames/parent frame bubbling works
20718
                  // TODO: check if the window needs to be supported
20719
                  Widget<?> frm = UiUtils.locateFrame(target);
20720
                  
20721
                  if (frm != null)
20722
                  {
20723
                     tr = invokeTriggers(frm, event.other(), action, false);
20724
                  }
20725
               }
20726
            }
20727
            
20728
            if (tr.executed)
20729
            {
20730
               // execution of a HELP trigger is implicitly RETURN NO-APPLY
20731
               tr.consume = true;
20732
               defaultHelp = false;
20689
         // universal events slip into parent frame only unless consumed
20690
         if (EventDefinition.isEventUniversal(key))
20691
         {
20692
            Widget<?> srcFrame = UiUtils.locateFrame(src);
20693

  
20694
            if (srcFrame != null)
20695
            {
20696
               // use specificWidget as it doesn't need to go up the parents chain
20697
               tr = invokeTriggers(srcFrame, null, -1, key, true, true, null, null);
20733 20698
            }
20734 20699
         }
20735 20700

  
20736 20701
         // let widget perform "hard" check if necessary
20737
         if (action == Keyboard.SE_LEAVE && src instanceof FillIn)
20702
         if (key != action && action == Keyboard.SE_LEAVE && src instanceof FillIn)
20738 20703
         {
20739 20704
            src.processKeyEvent(evt);
20740 20705

  
20741
            if (evt.isConsumed())
20706
            if (tr != null && evt.isConsumed())
20742 20707
               tr.consume = true;
20743 20708
         }
20744 20709

  
20745
         if (tr.consume)
20746
         {
20747
            evt.consume();
20748

  
20749
            if (foundGo)
20750
            {
20751
               subGoPending();
20752
               leaveSent = false;
20753
            }
20754
            return;
20755
         }
20756
      }
20757

  
20758
      // check for possible ANY-KEY
20759
      if ((tr == null || !tr.executed) && evt != null && evt.isRealKey() && evt.id() != EventType.KEY_RELEASED)
20760
      {
20761
         tr = invokeTriggers(src, key, true);
20762

  
20763
         if (tr.consume)
20764
         {
20765
            evt.consume();
20766

  
20767
            if (foundGo)
20768
            {
20769
               subGoPending();
20770
               leaveSent = false;
20771
            }
20772
            return;
20773
         }
20774
      }
20775

  
20710
         if (tr != null && tr.consume)
20711
         {
20712
            evt.consume();
20713

  
20714
            if (foundGo)
20715
            {
20716
               subGoPending();
20717
               leaveSent = false;
20718
            }
20719
            return;
20720
         }
20721
      }
20722
      
20776 20723
      // disable all following logic if this is a drop-down portion of a
20777 20724
      // combo-box
20778 20725
      if (src instanceof ScrollableList)
......
21261 21208
      // a standard input key (A, B, and so on)
21262 21209

  
21263 21210
      // HELP action
21264
      if (isGoPending == 0 && action == Keyboard.KA_HELP && defaultHelp)
21211
      if (isGoPending == 0 && defaultHelp)
21265 21212
      {
21266 21213
         requestHelp();
21267 21214
      }
......
21626 21573
                                        Integer   eventX,
21627 21574
                                        Integer   eventY)
21628 21575
   {
21576
      return invokeTriggers(widget, other, resourceId, evtCode, isKey, false, eventX, eventY);
21577
   }
21578
   
21579
   /**
21580
    * Check active <code>EventList</code> instance for triggers defined
21581
    * for this event and widget pair and activate the first one found.
21582
    * <p>
21583
    * Triggers are searched either for a specific widget, or, if no widget is
21584
    * enabled (in focus), for the session window. The latter is also performed
21585
    * if the specific widget happens to be the session window.
21586
    * <p>
21587
    * The specific search is done in the following order:
21588
    * <ul>
21589
    *  <li>trigger for the specified widget and event;
21590
    *  <li>trigger for the specified event anywhere within the frame;
21591
    *  <li>trigger for the specified event anywhere globally.
21592
    * </ul>
21593
    * <p>
21594
    * The search for the session window is a one step process.
21595
    * <p>
21596
    * The first found trigger, if any, gets activated.
21597
    *
21598
    * @param   widget
21599
    *          event source.
21600
    * @param   other
21601
    *          a companion widget (for ENTER/LEAVE events).
21602
    * @param   resourceId
21603
    *          When not set to -1, is a valid resource ID (for non-widget events).
21604
    * @param   evtCode
21605
    *          event code.
21606
    * @param   isKey
21607
    *          This flags marks reals keys typed by user.
21608
    * @param   specificWidget
21609
    *          This flags checks only for the triggers on specific widget.
21610
    * @param   eventX
21611
    *          The value of LAST-EVENT:X attribute; <code>null</code> if not used.
21612
    * @param   eventY
21613
    *          The value of LAST-EVENT:Y attribute; <code>null</code> if not used.
21614
    *
21615
    * @return  Execution and event consume flags for an executed trigger.
21616
    */
21617
   private TriggerResult invokeTriggers(Widget    widget,
21618
                                        Widget    other,
21619
                                        long      resourceId,
21620
                                        int       evtCode,
21621
                                        boolean   isKey,
21622
                                        boolean   specificWidget,
21623
                                        Integer   eventX,
21624
                                        Integer   eventY)
21625
   {
21629 21626
      // this method must not be called for mouse events on virtual widgets; for key presses, 
21630 21627
      // this is allowed because ANY-KEY triggers need to be reached.
21631 21628

  
......
21689 21686
      {
21690 21687
         Widget container = UiUtils.locateContainer(widget);
21691 21688
         
21692
         currentEventList.lookup(container != null && container != frame ? UiUtils.getWidgetIdAsInt(container) : frameId, widgetId, true, isKey, result);
21689
         currentEventList.lookup(container != null && container != frame ? UiUtils.getWidgetIdAsInt(container) : frameId, widgetId, true, isKey, specificWidget, result);
21693 21690
      }
21694 21691

  
21695 21692
      // activate trigger