Project

General

Profile

6053.patch

Marian Edu, 06/10/2022 08:04 AM

Download (23 KB)

View differences:

new/src/com/goldencode/p2j/ui/BaseEntity.java 2022-06-10 11:16:29 +0000
187 187
**                           and converted to integer. See #5345.
188 188
**     VVT 20211118          Fixed: incorrect coordinate conversion when setting size atributes. See #5034-1422.
189 189
**     ME  20220209          Replace getAttr for "realized" with isRealized method.
190
**     RV  20220610          Modified frame col/row/x/y methods to return null is frame is null.
190 191
*/
191 192
/*
192 193
** This program is free software: you can redistribute it and/or modify
......
1870 1871
   @Override
1871 1872
   public decimal getFrameColumn()
1872 1873
   {
1873
      return MathOps.plus(getColumn(), getAttr("frameColumnOffset", () -> config.frameColumnOffset, true));
1874
      if(this.frame == null)
1875
         return new decimal();
1876
      return getColumn();
1874 1877
   }
1875 1878

  
1876 1879
   /**
......
1881 1884
   @Override
1882 1885
   public decimal getFrameRow()
1883 1886
   {
1884
      return MathOps.plus(getRow(), getAttr("frameRowOffset", () -> config.frameRowOffset, true));
1887
      if(this.frame == null)
1888
         return new decimal();
1889
      return getRow();
1885 1890
   }
1886 1891

  
1887 1892
   /**
......
1892 1897
   @Override
1893 1898
   public integer getFrameX()
1894 1899
   {
1895
      // if we are in ChUI, this actually returns the FRAME-COL
1896
      return new integer(LogicalTerminal.isChui()
1897
                            ? getFrameColumn() 
1898
                            : MathOps.plus(getX(), getAttr("frameXOffset", () -> config.frameXOffset, true)));
1900
      if(this.frame == null)
1901
         return new integer();
1902
      return LogicalTerminal.isChui() ? new integer(getColumn()) : getX();
1899 1903
   }
1900 1904

  
1901 1905
   /**
......
1906 1910
   @Override
1907 1911
   public integer getFrameY()
1908 1912
   {
1909
      // if we are in ChUI, this actually returns the FRAME-ROW
1910
      return new integer(LogicalTerminal.isChui()
1911
                            ? getFrameRow() 
1912
                            : MathOps.plus(getY(), getAttr("frameYOffset", () -> config.frameYOffset, true)));
1913
      if(this.frame == null)
1914
         return new integer();
1915
      return LogicalTerminal.isChui() ? new integer(getRow()) : getY();
1913 1916
   }
1914 1917

  
1915 1918
   /**
new/src/com/goldencode/p2j/ui/ComboBoxConfig.java 2022-06-10 11:16:29 +0000
43 43
** 023 EVL 20190401          Adding runtime support for AUTO-COMPLETION attribute.
44 44
** 024 IAS 20200823          Rework (de)serialization.
45 45
**     EVL 20200925          Pack all boolean attributes into single 32-bit integer for socket read/write.
46
**     RV  20220610          Added initialization block.
46 47
*/
47 48
/*
48 49
** This program is free software: you can redistribute it and/or modify
......
278 279
      out.writeInt(selectedIndex);
279 280
      writeEnum(out, mode);
280 281
   }
282

  
283
   /**
284
    * Initialize defaults for this config.
285
    */
286
   {
287
      widthChars = 13.8;
288
      heightChars = 1.0;
289
      format = "x(8)";
290
   }
281 291
}
new/src/com/goldencode/p2j/ui/ComboBoxWidget.java 2022-06-10 10:58:12 +0000
104 104
**                           because all values will return true in this case.
105 105
**     OM  20220304          4GL quirk: in the GUI clients, setting the SCREEN-VALUE to "" will make it ?.
106 106
**     ME  20220410          Partial fix for screen-value validation for non-character data type.
107
**     BP  20220610          Delete the conditions from setHeightChars/Pixels because it can never be set.
107 108
*/
108 109

  
109 110
/*
......
880 881
   @Override
881 882
   public void setHeightChars(NumberType height)
882 883
   {
883
      if (_isRealized())
884
      {
885 884
         ErrorManager.recordOrShowError(4078, 
886 885
            String.format("Unable to set attribute HEIGHT for %s %s",
887 886
                          type(), widgetName()), false);
888
      }
889
      else
890
      {
891
         super.setHeightChars(height);
892
      }
887
         
893 888
   }
894 889
   
895 890
   /**
......
901 896
   @Override
902 897
   public void setHeightChars(double height)
903 898
   {
904
      if (_isRealized())
905
      {
906 899
         ErrorManager.recordOrShowError(4078, 
907 900
            String.format("Unable to set attribute HEIGHT for %s %s",
908 901
                          type(), widgetName()), false);
909
      }
910
      else
911
      {
912
         super.setHeightChars(height);
913
      }
914 902
   }
915 903
   
916 904
   /**
......
922 910
   @Override
923 911
   public void setHeightPixels(NumberType heightPixels)
924 912
   {
925
      if (_isRealized())
926
      {
927 913
         ErrorManager.recordOrShowError(4078, 
928 914
            String.format("Unable to set attribute HEIGHT-PIXELS for %s %s",
929 915
                          type(), widgetName()), false);
930
      }
931
      else
932
      {
933
         super.setHeightPixels(heightPixels);
934
      }
916

  
935 917
   }
936 918

  
937 919
   /**
......
943 925
   @Override
944 926
   public void setHeightPixels(int heightPixels)
945 927
   {
946
      if (_isRealized())
947
      {
948 928
         ErrorManager.recordOrShowError(4078, 
949 929
            String.format("Unable to set attribute HEIGHT-PIXELS for %s %s",
950 930
                          type(), widgetName()), false);
951
      }
952
      else
953
      {
954
         super.setHeightPixels(heightPixels);
955
      }
956 931
   }
957 932

  
958 933
   /**
new/src/com/goldencode/p2j/ui/ControlEntity.java 2022-06-10 11:43:05 +0000
98 98
**     CA  20210709          Dynamic side-labels are part of the FIELD-GROUP in FWD, too - so they must not be  
99 99
**                           walked explicitly.
100 100
**     HC  20211102          Implemented i18n support.
101
**     RV  20220610          Modified getIndex method to return unknown if widget is dynamic.
101 102
*/
102 103

  
103 104
/*
......
572 573
   @Override
573 574
   public integer getIndex()
574 575
   {
576
      if (config.dynamic)
577
         return new integer();
575 578
      return new integer(getAttr("index", () -> config.index));
576 579
   }
577 580
   
new/src/com/goldencode/p2j/ui/ControlSetEntity.java 2022-06-10 11:05:33 +0000
106 106
**                           case for radio-set to check validity.
107 107
**     ME  20220410          Partial fix for screen-value validation for non-character data type.
108 108
**     IAS 20220527          Re-worked delete operation using deleteFromControlSet
109
**     ME  20220610          Remove use of wasRealized and use _isRealized method instead.
109 110
*/
110 111
/*
111 112
** This program is free software: you can redistribute it and/or modify
......
2902 2903
   {
2903 2904
      if (!isValidScreenValue(value))
2904 2905
      {
2905
         if (frame != null && getAttr("wasRealized", () -> config.wasRealized, true))
2906
         if (frame != null && _isRealized())
2906 2907
         {
2907 2908
            ErrorManager.recordOrShowWarning(4058, String.format(
2908 2909
                     "Attribute SCREEN-VALUE for the %s %s has an invalid value of %s", type(),
new/src/com/goldencode/p2j/ui/FillInConfig.java 2022-06-10 11:16:29 +0000
51 51
** 030 VVT 20200203          Javadoc fix.
52 52
** 031 IAS 20200823          Rework (de)serialization.
53 53
**     EVL 20200925          Pack all boolean attributes into single 32-bit integer for socket read/write.
54
**     RV  20220610          Added initialization block.
54 55
*/
55 56
/*
56 57
** This program is free software: you can redistribute it and/or modify
......
213 214
    */
214 215
   public FillInConfig()
215 216
   {
216
      heightChars = 1;
217 217
   }
218 218

  
219 219
   /**
......
225 225
   protected FillInConfig(int id)
226 226
   {
227 227
      super(id);
228
      heightChars = 1;
229 228
   }
230 229

  
231 230
   /**
......
237 236
   public FillInConfig(WidgetId id)
238 237
   {
239 238
      super(id);
240
      heightChars = 1;
241 239
   }
242 240

  
243 241
   /**
......
349 347
      writeExternalizable(out, ehFont);
350 348
      writeString(out, subtype);
351 349
  }
350

  
351
   /**
352
    * Initialize defaults for this config.
353
    */
354
   {
355
      heightChars = 1.0;
356
   }
352 357
}
new/src/com/goldencode/p2j/ui/FillInWidget.java 2022-06-10 11:16:29 +0000
60 60
**     EVL 20210709          We need to send the 0 based selection index to client side for start position
61 61
**                           when calling the SET-SELECTION method for fill-in widget.
62 62
**     EVL 20210709          Adding focusAndSelect() method as FWD extension.
63
**     RV  20220610          Added override for setDataType method.
63 64
*/ 
64 65
/*
65 66
** This program is free software: you can redistribute it and/or modify
......
1071 1072
         return;
1072 1073
      }
1073 1074
      
1075
      if (_isRealized())
1076
      {
1077
         warningAlreadyRealized("SUBTYPE");
1078
         return;
1079
      }
1080
      
1074 1081
      setSubType(value.toStringMessage());
1075 1082
   }
1076 1083

  
......
1098 1105
   }
1099 1106
   
1100 1107
   /**
1108
    * Sets new value of DATA-TYPE attribute.
1109
    *
1110
    * @param dataType
1111
    *        new value of DATA-TYPE attribute
1112
    */
1113
   @Override
1114
   public void setDataType(character dataType)
1115
   {
1116
      if (dataType == null || dataType.isUnknown())
1117
      {
1118
         ErrorManager.recordOrShowError(4056, type());
1119
         // ** Attribute DATA-TYPE for the <type> widget has an invalid value of UNKNOWN.
1120
         return;
1121
      }
1122
      
1123
      if (_isRealized())
1124
      {
1125
         warningAlreadyRealized("DATA-TYPE");
1126
         return;
1127
      }
1128
      
1129
      setDataType(dataType.toStringMessage());
1130
   }
1131
   
1132
   /**
1101 1133
    * Sets the text widget that is used as the side label for this widget. This is the
1102 1134
    * equivalent of the SIDE-LABEL-HANDLE attribute of COMBO-BOX, EDITOR, FILL-IN, RADIO-SET,
1103 1135
    * SELECTION-LIST, SLIDER and TEXT widgets.
new/src/com/goldencode/p2j/ui/FrameWidget.java 2022-06-10 11:01:36 +0000
198 198
**                           Notes resolution.  Added root frame detection code.  According to testcases the
199 199
**                           root frame should return unknown value as tab-position.
200 200
**     ME  20220512          Frame has fixed size only when size is assigned outside of frame setup.
201
**     ME  20220610          Remove use of wasRealized and use only _isRealized method instead.
201 202
*/
202 203
/*
203 204
** This program is free software: you can redistribute it and/or modify
......
2823 2824

  
2824 2825
      int restrictedWidth = restrictedWidthPixels;
2825 2826

  
2826
      if (_isRealized() && getAttr("wasRealized", () -> config.wasRealized))
2827
      if (_isRealized())
2827 2828
      {
2828 2829
         // Find the first ancestor of window or frame type, use this ancestor's maximum and virtual
2829 2830
         // widths to restrict the input frame width value
......
2890 2891
      final int restrictedHeightPixels = truncatePixelSize(heightPixels, attribute);
2891 2892
      
2892 2893
      int restrictedHeight = restrictedHeightPixels;
2893
      if (_isRealized() && getAttr("wasRealized", () -> config.wasRealized))
2894
      if (_isRealized())
2894 2895
      {
2895 2896
         // Find the first ancestor of window or frame type, use this ancestor's maximum and virtual
2896 2897
         // heights to restrict the input frame height value
new/src/com/goldencode/p2j/ui/GenericWidget.java 2022-06-10 11:16:29 +0000
341 341
**                           to reduce unnecessary warnings Ref:6208#note-22 
342 342
**     VVT 20220525          moveAfterTab method renamed to moveAfterTabItem in sake of consistence with
343 343
**                           moveBeforeTabItem. See #6383.
344
**     ME  20220610          Do not mark the widget as realized if realization not possible (no frame).
345
**     RV  20220610          Replaced displayError/recordOrShowError with recordOrShowWarning were needed.
344 346
*/
345 347

  
346 348
/*
......
2221 2223
            .append(type())
2222 2224
            .append(" widget is not in a frame");
2223 2225
         // and display it
2224
         ErrorManager.displayError(4073, err.toString());
2226
         ErrorManager.recordOrShowWarning(4073, err.toString(), true, false, true, true);
2225 2227
         return;
2226 2228
      }
2227 2229
      
......
6039 6041
   @Override
6040 6042
   public void realize()
6041 6043
   {
6042
      if (getAttr("wasRealized", () -> config.wasRealized, true))
6044
      if (getAttr("realized", () -> config.realized, true))
6043 6045
      {
6044 6046
         return;
6045 6047
      }
......
6051 6053
               false);
6052 6054
         
6053 6055
      }
6054
      /** 
6055
       * Set the auxiliary flag to indicate whether the widget's has been realized.
6056
       *  A temporary solution. Most likely should be revised
6057
       *  after a proper realization of the realize() method, 
6058
       */
6059
      config.wasRealized = true;
6060
      // TODO: implement
6056
      else 
6057
      {
6058
         config.realized = true;
6059
      }
6061 6060
   }
6062 6061
   
6063 6062
   /**
......
6132 6131
   @Override
6133 6132
   public integer getTabPosition()
6134 6133
   {
6134
      if (frame == null) 
6135
      {
6136
         return new integer();
6137
      }
6138
      
6135 6139
      return getFrame().getFieldGroup().getTabPosition(this);
6136 6140
   }
6137 6141

  
......
6164 6168
      {
6165 6169
         return true;
6166 6170
      }
6167
      if (!getAttr("wasRealized", () -> config.wasRealized, true))
6171
      if (!getAttr("realized", () -> config.realized, true))
6168 6172
      {
6169 6173
         ErrorManager.recordOrShowError(4104, 
6170 6174
               String.format(
......
6173 6177
               false);
6174 6178
         if (attr != null)
6175 6179
         {
6176
            ErrorManager.recordOrShowError(4077, 
6177
                  String.format(
6178
                  "Unable to query attribute %s for %s %s", 
6179
                  attr, type(), widgetName()),
6180
                  false);
6180
            ErrorManager.recordOrShowWarning(4077,
6181
                     String.format("Unable to query attribute %s for %s %s", attr, type(),
6182
                              widgetName()),
6183
                     true, false, true, true);
6181 6184
         }
6182 6185
         return false;
6183 6186
      }
......
6420 6423
               .append(type())
6421 6424
               .append(" widget");
6422 6425
            // and display it
6423
            ErrorManager.displayError(4072, err.toString());
6426
            ErrorManager.recordOrShowWarning(4072, err.toString(), true, false, true, true);
6424 6427
         }
6425 6428
         return false;
6426 6429
      }
new/src/com/goldencode/p2j/ui/LogicalTerminal.java 2022-06-10 06:20:19 +0000
989 989
**     AL2 20220512          Replaced getTempDirectory with readHtmlBrowserWhitelist.
990 990
**     IAS 20220527          Added deleteFromControlSet operation
991 991
**     AL2 20220606          Added getHTMLBrowserLoadTimeout.
992
**     ME  20220610          Check for invalid frame on nextTabItem/previousTabItem.
992 993
*/
993 994

  
994 995
/*
......
11267 11268
    */
11268 11269
   public static handle nextTabItem(GenericFrame frame, GenericWidget<?> widget)
11269 11270
   {
11271
      if (frame == null || frame.getFieldGroup() == null) 
11272
      {
11273
         return new handle();
11274
      }
11270 11275
      return frame.getFieldGroup().nextTabItem(widget);
11271 11276
   }
11272 11277
   
......
11283 11288
    */
11284 11289
   public static handle previousTabItem(GenericFrame frame, GenericWidget<?> widget)
11285 11290
   {
11291
      if (frame == null || frame.getFieldGroup() == null) 
11292
      {
11293
         return new handle();
11294
      }
11286 11295
      return frame.getFieldGroup().previousTabItem(widget);
11287 11296
   }
11288 11297
   
new/src/com/goldencode/p2j/ui/SelectionListWidget.java 2022-06-10 11:16:29 +0000
63 63
**     ME  20220323          Modified the manner in which  the attributes are accessed/modified. Ref. #6173.
64 64
**     VVT 20220405          Regression fixed: zero selection list widget height, introduced in
65 65
**                           rev. 13675. See #5937-79.
66
**     RV  20220610          Modified methods for properties that realize the widget to throw respective
67
**                           warnings/errors.
66 68
*/
67 69
/*
68 70
** This program is free software: you can redistribute it and/or modify
......
168 170
   @Override
169 171
   public integer getInnerChars()
170 172
   {
171
      return new integer(getAttr("innerChars", () -> config.innerChars, true));
173
      if (!canAccess(null)) // this is how 4GL works
174
      {
175
         return new integer();
176
      }
177
      return new integer(Math.max(0, getAttr("innerChars", () -> config.innerChars, true)));
172 178
   }
173 179
   
174 180
   /**
......
220 226
   {
221 227
      if (!canAccess(null)) // this is how 4GL works
222 228
      {
223
         ErrorManager.recordOrShowError(4104, String.format(
224
               "Unknown error code 1 for attribute ? on the %s widget", 
225
               type()),
226
               false);
229
         return new integer();
227 230
      }
228 231
      return new integer(Math.max(0, getAttr("innerLines", () -> config.innerLines, true)));
229 232
   }
......
336 339
   @Override
337 340
   public decimal getWidthChars()
338 341
   {
339
      if (!canAccess("WIDHTH"))
342
      if (!canAccess("WIDTH"))
340 343
      {
341 344
         return new decimal(0);
342 345
      }
......
344 347
   }
345 348

  
346 349
   /**
350
    * Gets the HEIGHT-PIXELS writable attribute.
351
    *
352
    * @return   The current value of the HEIGHT-PIXELS attribute.
353
    */
354
   @Override
355
   public integer getHeightPixels()
356
   {
357
      if (!canAccess("HEIGHT-PIXELS"))
358
      {
359
         return new integer(0);
360
      }
361
      return super.getHeightPixels();
362
   }
363

  
364
   /**
365
    * Gets the WIDTH-PIXELS writable attribute.
366
    *
367
    * @return   The current value of the WIDTH-PIXELS attribute.
368
    */
369
   @Override
370
   public integer getWidthPixels()
371
   {
372
      if (!canAccess("WIDTH-PIXELS"))
373
      {
374
         return new integer(0);
375
      }
376
      return super.getWidthPixels();
377
   }
378

  
379
   /**
347 380
    * Getter for the MULTIPLE read-only attribute.
348 381
    * 
349 382
    * @return  value of MULTIPLE attribute
......
522 555
   }
523 556
   
524 557
   /**
558
    * Set SORT attribute.
559
    * 
560
    * @param    sort
561
    *           New value for the attribute.
562
    */
563
   public void setSort(logical sort)
564
   {
565
      if (_isRealized())
566
      {
567
         warningAlreadyRealized("SORT");
568
         return;
569
      }
570
      
571
      setSort(sort.booleanValue());
572
   }
573
   
574
   /**
525 575
    * Implements the IS-SELECTED() widget method.
526 576
    *
527 577
    * @param  item
......
602 652
   @Override
603 653
   public character getScreenValue()
604 654
   {
605
      return frame.getScreenValue(this, true);
655
      if (!canAccess("SCREEN-VALUE"))
656
      {
657
         return new character();
658
      }
659
      return super.getScreenValue();
606 660
   }
607 661
   
608 662
   /**
new/src/com/goldencode/p2j/ui/WidgetConfig.java 2022-06-10 11:02:22 +0000
30 30
** 018 HC  20211102 Implemented i18n support.
31 31
**     ME  20220208 Drop temporary 'wasRealized' flag. 
32 32
**     ME  20220216 Revert drop of 'wasRealized' flag.
33
**     ME  20221006 Complete widget realization and remove temporary solution.
33 34
*/ 
34 35
/*
35 36
** This program is free software: you can redistribute it and/or modify
......
158 159
   /** Flag to indicate whether the widget has been realized. **/
159 160
   public boolean realized = false;
160 161
   
161
   /** Flag to indicate whether the widget's has been realized.
162
   *  A temporary solution. Most likely should be revised
163
   *  after a proper realization of the realize() method, 
164
   * */
165
   public boolean wasRealized = false;
166
   
167 162
   /** The HIDDEN attribute, which stops widgets from displaying. */
168 163
   public boolean hidden = false; 
169 164
   
......
457 452
      if (manualHightlight) booleanAttrs |= ATTR_MASK_MANUAL_HIGHLIGHT;
458 453
      if (selectable)       booleanAttrs |= ATTR_MASK_SELECTABLE;
459 454
      if (disableRedraw)    booleanAttrs |= ATTR_MASK_DIS_REDRAW;
460
      if (wasRealized)      booleanAttrs |= ATTR_MASK_WAS_REALIZED;
461 455
      out.writeInt(booleanAttrs);
462 456

  
463 457
//      System.err.printf("WidgetConfig.writeExternal: %s; %s: %s, %s, %s, %s, %s, %s, %s, %s\n", 
......
502 496
      manualHightlight = (booleanAttrs & ATTR_MASK_MANUAL_HIGHLIGHT) == ATTR_MASK_MANUAL_HIGHLIGHT;
503 497
      selectable       = (booleanAttrs & ATTR_MASK_SELECTABLE) == ATTR_MASK_SELECTABLE;
504 498
      disableRedraw    = (booleanAttrs & ATTR_MASK_DIS_REDRAW) == ATTR_MASK_DIS_REDRAW;
505
      wasRealized      = (booleanAttrs & ATTR_MASK_WAS_REALIZED) == ATTR_MASK_WAS_REALIZED;
506 499

  
507 500
//      System.err.printf("WidgetConfig.readExternal: %s; %s: %s, %s, %s, %s, %s, %s, %s, %s\n", 
508 501
//            this, id, frameId, popupMenuId, enabled, visible, realized, header, hidden, modified);
......
550 543
      menuKey = config.menuKey;
551 544
      menuMouse = config.menuMouse;
552 545
      disableRedraw = config.disableRedraw;
553
      wasRealized = config.wasRealized;
554 546
   }
555 547
   
556 548
   /**
new/src/com/goldencode/p2j/ui/chui/FramePlacementManager.java 2022-06-10 11:03:08 +0000
346 346
**                           init(Column|Row) is valid it should be used instead of 0.
347 347
**     ME  20220208          Use 'isRealised' frame method instead of 'wasRealised' configuration. 
348 348
**     ME  20220216          Revert drop of 'wasRealized' flag.
349
**     ME  20220610          Complete widget realization and remove temporary solution.
349 350
*/
350 351
/*
351 352
** This program is free software: you can redistribute it and/or modify
......
466 467
      
467 468
      if (!frame.isRootFrame())
468 469
      {
469
         if (!cfg.wasRealized)
470
         if (!frame.isRealized())
470 471
         {
471 472
            frame.setLocation(cfg.initColumn != BaseConfig.INV_COORD ? cfg.initColumn : 0,
472 473
                              cfg.initRow != BaseConfig.INV_COORD ? cfg.initRow : 0);
new/src/com/goldencode/p2j/ui/client/widget/AbstractWidget.java 2022-06-10 06:20:19 +0000
202 202
**                  flickering due to unexpected z-order of the overlay windows, focus lost and
203 203
**                  subsequent key input issues, submenu overlay windows showing when they should
204 204
**                  not.
205
**     ME  20220610 Complete widget realization and remove temporary solution.
205 206
*/
206 207

  
207 208
/*
......
2662 2663
         if (visible && !config.realized)
2663 2664
         {
2664 2665
            config.realized = true;
2665
            config.wasRealized = true;
2666 2666
            Frame container = parent(Frame.class);
2667 2667
            if (container != null)
2668 2668
            {
......
3762 3762
      }
3763 3763
      
3764 3764
      cfg.realized = false;
3765
      cfg.wasRealized = false;
3766 3765
      cfg.visible = false;
3767 3766
      cfg.hidden = false;
3768 3767