-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
GridFieldVO.java
935 lines (879 loc) · 33 KB
/
GridFieldVO.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
* @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] *
*****************************************************************************/
package org.compiere.model;
import static org.compiere.model.SystemIDs.REFERENCE_AD_USER;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Comparator;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
/**
* Field Model Value Object
*
* @author Jorg Janke
* @author Victor Perez , e-Evolution.SC FR [ 1757088 ] , [1877902] Implement JSR 223 Scripting APIs to Callout
* @author Carlos Ruiz, qss FR [1877902]
* @author Juan David Arboleda (arboleda), GlobalQSS, [ 1795398 ] Process Parameter: add display and readonly logic
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1877902&group_id=176962 to FR [1877902]
* @version $Id: GridFieldVO.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
*/
public class GridFieldVO implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -7810037179946135749L;
/**
* Return the SQL statement used for the MFieldVO.create
* @param ctx context
* @return SQL with or w/o translation and 1 parameter
*/
public static String getSQL (Properties ctx)
{
// IsActive is part of View
MRole role = MRole.getDefault(ctx, false);
String advancedFilter=" AND IsAdvancedField='N' ";
StringBuilder sql;
if (!Env.isBaseLanguage(ctx, "AD_Tab")){
sql = new StringBuilder("SELECT * FROM AD_Field_vt WHERE AD_Tab_ID=?")
.append(" AND AD_Language='" + Env.getAD_Language(ctx) + "'");
if (!role.isAccessAdvanced()) {
sql.append(advancedFilter);
}
sql.append(" ORDER BY IsDisplayed DESC, SeqNo");
}
else{
sql = new StringBuilder("SELECT * FROM AD_Field_v WHERE AD_Tab_ID=?");
if (!role.isAccessAdvanced()) {
sql.append(advancedFilter);
}
sql.append(" ORDER BY IsDisplayed DESC, SeqNo");
}
return sql.toString();
} // getSQL
/**
* Create Field Value Object
* @param ctx context
* @param WindowNo window
* @param TabNo tab
* @param AD_Window_ID window
* @param AD_Tab_ID tab
* @param readOnly r/o
* @param rs resultset AD_Field_v
* @return MFieldVO
*/
public static GridFieldVO create (Properties ctx, int WindowNo, int TabNo,
int AD_Window_ID, int AD_Tab_ID, boolean readOnly, ResultSet rs)
{
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, TabNo,
AD_Window_ID, AD_Tab_ID, readOnly);
String columnName = "ColumnName";
int AD_Field_ID = 0;
try
{
vo.ColumnName = rs.getString("ColumnName");
if (vo.ColumnName == null)
return null;
CLogger.get().fine(vo.ColumnName);
ResultSetMetaData rsmd = rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++)
{
columnName = rsmd.getColumnName (i);
if (columnName.equalsIgnoreCase("Name"))
vo.Header = rs.getString (i);
else if (columnName.equalsIgnoreCase("AD_Reference_ID"))
vo.displayType = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_Column_ID"))
vo.AD_Column_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_Table_ID"))
vo.AD_Table_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("DisplayLength"))
vo.DisplayLength = rs.getInt (i);
else if (columnName.equalsIgnoreCase("IsSameLine"))
vo.IsSameLine = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsDisplayed"))
vo.IsDisplayed = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsDisplayedGrid"))
vo.IsDisplayedGrid = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("SeqNo"))
vo.SeqNo = rs.getInt (i);
else if (columnName.equalsIgnoreCase("SeqNoGrid"))
vo.SeqNoGrid = rs.getInt (i);
else if (columnName.equalsIgnoreCase("DisplayLogic"))
vo.DisplayLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("DefaultValue"))
vo.DefaultValue = rs.getString (i);
else if (columnName.equalsIgnoreCase("IsMandatory"))
vo.IsMandatory = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsReadOnly"))
vo.IsReadOnly = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsUpdateable"))
vo.IsUpdateable = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsAlwaysUpdateable"))
vo.IsAlwaysUpdateable = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsHeading"))
vo.IsHeading = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsFieldOnly"))
vo.IsFieldOnly = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsEncryptedField"))
vo.IsEncryptedField = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsEncryptedColumn"))
vo.IsEncryptedColumn = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsSelectionColumn"))
vo.IsSelectionColumn = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("SeqNoSelection"))
vo.SeqNoSelection = rs.getInt (i);
else if (columnName.equalsIgnoreCase("SortNo"))
vo.SortNo = rs.getInt (i);
else if (columnName.equalsIgnoreCase("FieldLength"))
vo.FieldLength = rs.getInt (i);
else if (columnName.equalsIgnoreCase("VFormat"))
vo.VFormat = rs.getString (i);
else if (columnName.equalsIgnoreCase("FormatPattern"))
vo.FormatPattern = rs.getString (i);
else if (columnName.equalsIgnoreCase("ValueMin"))
vo.ValueMin = rs.getString (i);
else if (columnName.equalsIgnoreCase("ValueMax"))
vo.ValueMax = rs.getString (i);
else if (columnName.equalsIgnoreCase("FieldGroup"))
vo.FieldGroup = rs.getString (i);
else if (columnName.equalsIgnoreCase("FieldGroupType"))
vo.FieldGroupType = rs.getString (i);
else if (columnName.equalsIgnoreCase("IsKey"))
vo.IsKey = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsParent"))
vo.IsParent = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("Description"))
{
String s = rs.getString (i);
vo.Description = s != null ? s.intern() : s;
}
else if (columnName.equalsIgnoreCase("Help"))
{
String s = rs.getString (i);
vo.Help = s != null ? s.intern() : s;
}
else if (columnName.equalsIgnoreCase("Callout"))
vo.Callout = rs.getString (i);
else if (columnName.equalsIgnoreCase("AD_Process_ID"))
vo.AD_Process_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("ReadOnlyLogic"))
vo.ReadOnlyLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("MandatoryLogic"))
vo.MandatoryLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("ObscureType"))
vo.ObscureType = rs.getString (i);
else if (columnName.equalsIgnoreCase("IsDefaultFocus"))
vo.IsDefaultFocus = "Y".equals(rs.getString(i));
//
else if (columnName.equalsIgnoreCase("AD_Reference_Value_ID"))
vo.AD_Reference_Value_ID = rs.getInt(i);
else if (columnName.equalsIgnoreCase("ValidationCode"))
vo.ValidationCode = rs.getString(i);
else if (columnName.equalsIgnoreCase("IsQuickForm"))
vo.IsQuickForm = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("ColumnSQL")) {
vo.ColumnSQL = rs.getString(i);
if (vo.ColumnSQL != null && !vo.ColumnSQL.startsWith("@SQL=") && !vo.ColumnSQL.startsWith("@SQLFIND=") && vo.ColumnSQL.contains("@")) {
// NOTE: cannot use window context because this is set globally on the query, not per record
vo.ColumnSQL = Env.parseContext(ctx, -1, vo.ColumnSQL, false, true);
}
//Feature Request FR [ 1757088 ]
} else if (columnName.equalsIgnoreCase("Included_Tab_ID"))
vo.Included_Tab_ID = rs.getInt(i);
// Collapse Default State
else if (columnName.equalsIgnoreCase("IsCollapsedByDefault"))
vo.IsCollapsedByDefault = "Y".equals(rs.getString(i));
// Feature Request FR [ 2003044 ]
else if (columnName.equalsIgnoreCase("IsAutocomplete"))
vo.IsAutocomplete = "Y".equals(rs.getString(i));
else if (columnName.equalsIgnoreCase("IsAllowCopy"))
vo.IsAllowCopy = "Y".equals(rs.getString(i));
else if (columnName.equalsIgnoreCase("AD_Field_ID"))
vo.AD_Field_ID = rs.getInt(i);
/*IDEMPIERE-358*/
else if (columnName.equalsIgnoreCase("XPosition"))
vo.XPosition=rs.getInt(i);
else if (columnName.equalsIgnoreCase("ColumnSpan"))
vo.ColumnSpan=rs.getInt(i);
else if (columnName.equalsIgnoreCase("NumLines"))
vo.NumLines=rs.getInt(i);
else if (columnName.equalsIgnoreCase("IsToolbarButton"))
vo.IsToolbarButton = rs.getString(i);
else if (columnName.equalsIgnoreCase("AD_Chart_ID"))
vo.AD_Chart_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_LabelStyle_ID"))
vo.AD_LabelStyle_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_FieldStyle_ID"))
vo.AD_FieldStyle_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("PA_DashboardContent_ID"))
vo.PA_DashboardContent_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("placeholder"))
vo.Placeholder = rs.getString(i);
else if (columnName.equalsIgnoreCase("IsHtml"))
vo.IsHtml = "Y".equals(rs.getString(i));
}
if (vo.Header == null)
vo.Header = vo.ColumnName;
AD_Field_ID = rs.getInt("AD_Field_ID");
}
catch (SQLException e)
{
CLogger.get().log(Level.SEVERE, "ColumnName=" + columnName, e);
return null;
}
// ASP
if (vo.IsDisplayed) {
MClient client = MClient.get(ctx);
// ASP for fields has a different approach - it must be defined as a field but hidden
// in order to have the proper context variable filled with defaults
// Validate field and put IsDisplayed=N if must be hidden
if (! client.isDisplayField(AD_Field_ID))
vo.IsDisplayed = false;
}
// FR IDEMPIERE-177
// Field Customization
if (vo.IsDisplayed) {
MUserDefField userDef = null;
userDef = MUserDefField.get(vo.ctx,AD_Field_ID, AD_Tab_ID, AD_Window_ID);
if (userDef != null)
{
if (userDef.getName() != null)
vo.Header = userDef.getName();
if (userDef.getDescription() != null)
vo.Description = userDef.getDescription();
if (userDef.getHelp() != null)
vo.Help = userDef.getHelp();
if (userDef.getDisplayLength() > 0)
vo.DisplayLength = userDef.getDisplayLength();
if (userDef.getDisplayLogic() != null)
vo.DisplayLogic = userDef.getDisplayLogic();
if (userDef.getDefaultValue() != null)
vo.DefaultValue = userDef.getDefaultValue();
if (userDef.getSortNo() > 0)
vo.SortNo = userDef.getSortNo();
//IDEMPIERE-163
if (userDef.getIsDisplayed()!= null)
vo.IsDisplayed = "Y".equals(userDef.getIsDisplayed());
if (userDef.getIsReadOnly()!= null)
vo.IsReadOnly = "Y".equals(userDef.getIsReadOnly());
if (userDef.getIsSameLine()!= null)
vo.IsSameLine = "Y".equals(userDef.getIsSameLine());
if (userDef.getIsUpdateable()!= null)
vo.IsUpdateable = "Y".equals(userDef.getIsUpdateable());
if (userDef.getIsAlwaysUpdateable()!= null)
vo.IsAlwaysUpdateable = "Y".equals(userDef.getIsAlwaysUpdateable());
if (userDef.getReadOnlyLogic()!= null)
vo.ReadOnlyLogic = userDef.getReadOnlyLogic();
if (userDef.getMandatoryLogic()!= null )
vo.MandatoryLogic = userDef.getMandatoryLogic();
if (userDef.getAD_Reference_ID()>0)
vo.displayType = userDef.getAD_Reference_ID();
if (userDef.getAD_Reference_Value_ID()>0)
vo.AD_Reference_Value_ID = userDef.getAD_Reference_Value_ID();
if (userDef.getIsMandatory()!= null)
vo.IsMandatory = "Y".equals(userDef.getIsMandatory());
if (userDef.getXPosition() > 0)
vo.XPosition = userDef.getXPosition();
if (userDef.getColumnSpan() > 0)
vo.ColumnSpan=userDef.getColumnSpan();
if (userDef.getNumLines() > 0)
vo.NumLines=userDef.getNumLines();
if (userDef.getIsToolbarButton() != null)
vo.IsToolbarButton = userDef.getIsToolbarButton();
if (userDef.getVFormat() != null)
vo.VFormat = userDef.getVFormat();
//IDEMPIERE-1120 Implement Field SeqNo customization
if (userDef.getSeqNo() > 0)
vo.SeqNo = userDef.getSeqNo();
if (userDef.getAD_Val_Rule_ID() > 0)
vo.ValidationCode = MValRule.get(ctx, userDef.getAD_Val_Rule_ID()).getCode();
if (userDef.getAD_LabelStyle_ID() > 0)
vo.AD_LabelStyle_ID = userDef.getAD_LabelStyle_ID();
if (userDef.getAD_FieldStyle_ID() > 0)
vo.AD_FieldStyle_ID = userDef.getAD_FieldStyle_ID();
if (userDef.getPA_DashboardContent_ID() > 0)
vo.PA_DashboardContent_ID = userDef.getPA_DashboardContent_ID();
if (userDef.getPlaceholder() != null)
vo.Placeholder = userDef.getPlaceholder();
if (userDef.getIsAutocomplete() != null)
vo.IsAutocomplete = "Y".equals(userDef.getIsAutocomplete());
}
}
//
vo.initFinish();
return vo;
} // create
/**
* Init Field for Process Parameter
* @param ctx context
* @param WindowNo window
* @param rs result set AD_Process_Para
* @return MFieldVO
*/
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int ProcessIDOfPanel, int WindowIDOfPanel, int adInfoPaneId, ResultSet rs)
{
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, 0, 0, 0, false);
vo.isProcess = true;
vo.IsDisplayed = true;
vo.IsReadOnly = false;
vo.IsUpdateable = true;
vo.AD_Process_ID_Of_Panel = ProcessIDOfPanel;
vo.AD_Window_ID_Of_Panel = WindowIDOfPanel;
vo.AD_Infowindow_ID = adInfoPaneId;
try
{
vo.AD_Table_ID = 0;
vo.AD_Column_ID = rs.getInt("AD_Process_Para_ID"); // **
vo.ColumnName = rs.getString("ColumnName");
vo.Header = rs.getString("Name");
vo.Description = rs.getString("Description");
vo.Help = rs.getString("Help");
vo.SeqNo = rs.getInt("SeqNo");
vo.displayType = rs.getInt("AD_Reference_ID");
vo.IsMandatory = rs.getString("IsMandatory").equals("Y");
vo.FieldLength = rs.getInt("FieldLength");
vo.DisplayLength = vo.FieldLength;
vo.DefaultValue = rs.getString("DefaultValue");
vo.DefaultValue2 = rs.getString("DefaultValue2");
vo.VFormat = rs.getString("VFormat");
vo.FormatPattern = rs.getString("FormatPattern");
vo.ValueMin = rs.getString("ValueMin");
vo.ValueMax = rs.getString("ValueMax");
vo.isRange = rs.getString("IsRange").equals("Y");
//
vo.AD_Reference_Value_ID = rs.getInt("AD_Reference_Value_ID");
vo.ValidationCode = rs.getString("ValidationCode");
vo.ReadOnlyLogic = rs.getString("ReadOnlyLogic");
vo.DisplayLogic= rs.getString("DisplayLogic");
vo.IsEncryptedField=rs.getString("IsEncrypted").equals("Y");
vo.MandatoryLogic = rs.getString("MandatoryLogic");
vo.Placeholder = rs.getString("Placeholder");
vo.Placeholder2 = rs.getString("Placeholder2");
vo.IsAutocomplete = "Y".equals(rs.getString("IsAutoComplete"));
}
catch (SQLException e)
{
CLogger.get().log(Level.SEVERE, "createParameter", e);
}
//devCoffee - #3858
if(vo.IsDisplayed) {
MUserDefProcParameter userDef = MUserDefProcParameter.get(ctx, vo.AD_Column_ID, vo.AD_Process_ID_Of_Panel);
if(userDef != null) {
if(userDef.getName() != null)
vo.Header = userDef.getName();
if(userDef.getDescription() != null)
vo.Description = userDef.getDescription();
if(userDef.getHelp() != null)
vo.Help = userDef.getHelp();
if(userDef.getReadOnlyLogic() != null)
vo.ReadOnlyLogic = userDef.getReadOnlyLogic();
if(userDef.getDefaultValue() != null)
vo.DefaultValue = userDef.getDefaultValue();
if(userDef.getDisplayLogic() != null)
vo.DisplayLogic = userDef.getDisplayLogic();
if(userDef.getMandatoryLogic() != null)
vo.MandatoryLogic = userDef.getMandatoryLogic();
if (userDef.getIsDisplayed()!= null)
vo.IsDisplayed = "Y".equals(userDef.getIsDisplayed());
if (userDef.getPlaceholder()!= null)
vo.Placeholder = userDef.getPlaceholder();
if (userDef.getPlaceholder2()!= null)
vo.Placeholder2 = userDef.getPlaceholder2();
if (userDef.getSeqNo() > 0)
vo.SeqNo = userDef.getSeqNo();
if (userDef.getAD_Reference_ID()>0)
vo.displayType = userDef.getAD_Reference_ID();
if (userDef.getAD_Reference_Value_ID()>0)
vo.AD_Reference_Value_ID = userDef.getAD_Reference_Value_ID();
if (userDef.getVFormat() != null)
vo.VFormat = userDef.getVFormat();
if (userDef.getAD_Val_Rule_ID() > 0)
vo.ValidationCode = MValRule.get(ctx, userDef.getAD_Val_Rule_ID()).getCode();
if(userDef.getDefaultValue2() != null)
vo.DefaultValue2 = userDef.getDefaultValue2();
if(userDef.getValueMin() != null)
vo.ValueMin = userDef.getValueMin();
if(userDef.getValueMax() != null)
vo.ValueMax = userDef.getValueMax();
if (userDef.getIsMandatory()!= null)
vo.IsMandatory = "Y".equals(userDef.getIsMandatory());
}
}
//fim devCoffee - 3858
//
vo.initFinish();
if (vo.DefaultValue2 == null)
vo.DefaultValue2 = "";
if (vo.Placeholder2 == null)
vo.Placeholder2 = "";
return vo;
} // createParameter
/**
* Create range "to" Parameter Field from "from" Parameter Field
* @param voF field value object
* @return to MFieldVO
*/
public static GridFieldVO createParameter (GridFieldVO voF)
{
GridFieldVO voT = new GridFieldVO (voF.ctx, voF.WindowNo, voF.TabNo,
voF.AD_Window_ID, voF.AD_Tab_ID, voF.tabReadOnly);
voT.isProcess = true;
voT.IsDisplayed = true;
voT.IsReadOnly = false;
voT.IsUpdateable = true;
//
voT.AD_Table_ID = voF.AD_Table_ID;
voT.AD_Column_ID = voF.AD_Column_ID; // AD_Process_Para_ID
voT.ColumnName = voF.ColumnName;
voT.Header = voF.Header;
voT.Description = voF.Description;
voT.Help = voF.Help;
voT.displayType = voF.displayType;
voT.IsMandatory = voF.IsMandatory;
voT.FieldLength = voF.FieldLength;
voT.DisplayLength = voF.FieldLength;
voT.DefaultValue = voF.DefaultValue2;
voT.Placeholder2 = voF.Placeholder2;
voT.VFormat = voF.VFormat;
voT.FormatPattern = voF.FormatPattern;
voT.ValueMin = voF.ValueMin;
voT.ValueMax = voF.ValueMax;
voT.isRange = voF.isRange;
//
// Genied: For a range parameter the second field
// lookup behaviour should match the first one.
voT.AD_Reference_Value_ID = voF.AD_Reference_Value_ID;
// IDEMPIERE-229 Bug with Process parameter range
voT.ValidationCode = voF.ValidationCode;
voT.IsEncryptedField = voF.IsEncryptedField;
voT.ReadOnlyLogic = voF.ReadOnlyLogic;
voT.DisplayLogic = voF.DisplayLogic;
voT.AD_Process_ID_Of_Panel = voF.AD_Process_ID_Of_Panel;
voT.initFinish();
return voT;
} // createParameter
/**
* Create parameter for infoWindow
* @param ctx ctx
* @param WindowNo WindowNo
* @param AD_Column_ID AD_Column_ID
* @param ColumnName ColumnName
* @param Name Name
* @param AD_Reference_ID AD_Reference_ID
* @param AD_Reference_Value_ID AD_Reference_Value_ID
* @param IsMandatory IsMandatory
* @param IsEncrypted IsEncrypted
* @return GridFieldV0 v0
*/
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int WindowIDOfPanel, int infoWindowID,
int AD_Column_ID, String ColumnName, String Name, int AD_Reference_ID, int AD_Reference_Value_ID,
boolean IsMandatory, boolean IsEncrypted, String Placeholder)
{
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, 0, 0, 0, false);
vo.isProcess = true;
vo.IsDisplayed = true;
vo.IsReadOnly = false;
vo.IsUpdateable = true;
vo.AD_Table_ID = 0;
vo.AD_Column_ID = AD_Column_ID; // **
vo.ColumnName = ColumnName;
vo.Header = Name;
vo.displayType = AD_Reference_ID;
vo.AD_Reference_Value_ID = AD_Reference_Value_ID;
vo.IsMandatory = IsMandatory;
vo.IsEncryptedField= IsEncrypted;
vo.AD_Infowindow_ID = infoWindowID;
vo.AD_Window_ID_Of_Panel = WindowIDOfPanel;
vo.Placeholder = Placeholder;
//
vo.initFinish();
return vo;
}
/**
* Make a standard field (Created/Updated/By)
* @param ctx context
* @param WindowNo window
* @param TabNo tab
* @param AD_Window_ID window
* @param AD_Tab_ID tab
* @param tabReadOnly rab is r/o
* @param isCreated is Created field
* @param isTimestamp is the timestamp (not by)
* @return MFieldVO
*/
public static GridFieldVO createStdField (Properties ctx, int WindowNo, int TabNo,
int AD_Window_ID, int AD_Tab_ID, boolean tabReadOnly,
boolean isCreated, boolean isTimestamp)
{
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, TabNo,
AD_Window_ID, AD_Tab_ID, tabReadOnly);
vo.ColumnName = isCreated ? "Created" : "Updated";
if (!isTimestamp)
vo.ColumnName += "By";
vo.displayType = isTimestamp ? DisplayType.DateTime : DisplayType.Table;
if (!isTimestamp)
vo.AD_Reference_Value_ID = REFERENCE_AD_USER; // AD_User Table Reference
vo.IsDisplayed = false;
vo.IsMandatory = false;
vo.IsReadOnly = false;
vo.IsUpdateable = true;
vo.initFinish();
return vo;
} // initStdField
/**************************************************************************
* Private constructor.
* @param Ctx context
* @param windowNo window
* @param tabNo tab
* @param ad_Window_ID window
* @param ad_Tab_ID tab
* @param TabReadOnly tab read only
*/
private GridFieldVO (Properties Ctx, int windowNo, int tabNo,
int ad_Window_ID, int ad_Tab_ID, boolean TabReadOnly)
{
ctx = Ctx;
WindowNo = windowNo;
TabNo = tabNo;
AD_Window_ID = ad_Window_ID;
AD_Tab_ID = ad_Tab_ID;
tabReadOnly = TabReadOnly;
} // MFieldVO
/** Context */
public Properties ctx = null;
/** Window No */
public int WindowNo;
/** Tab No */
public int TabNo;
/** AD_Winmdow_ID */
public int AD_Window_ID;
/**
* in case this field lie on parameter process panel, AD_Process_ID_Of_Panel is id of process will run in this panel
* it's difference with AD_Process_ID
*/
public int AD_Process_ID_Of_Panel;
/**
* ad_window_id of window show process dialog or infoWindow dialog
*/
public int AD_Window_ID_Of_Panel;
/**
* AD_Infowindow_ID call process. user in case from info window call process.
*/
public int AD_Infowindow_ID;
/** AD_Tab_ID */
public int AD_Tab_ID;
/** Is the Tab Read Only */
public boolean tabReadOnly = false;
/** Is Process Parameter */
public boolean isProcess = false;
/** Column name */
public String ColumnName = "";
/** Column sql */
public String ColumnSQL;
/** Label */
public String Header = "";
/** DisplayType */
public int displayType = 0;
/** Table ID */
public int AD_Table_ID = 0;
/** Clumn ID */
public int AD_Column_ID = 0;
/** Display Length */
public int DisplayLength = 0;
/** Same Line */
public boolean IsSameLine = false;
/** Displayed */
public boolean IsDisplayed = false;
/** Displayed Grid */
public boolean IsDisplayedGrid = false;
/** Position */
public int SeqNo = 0;
/** Grid Display sequence */
public int SeqNoGrid = 0;
/** Dislay Logic, never set null for it */
public String DisplayLogic = "";
/** Default Value, never set null for it */
public String DefaultValue = "";
/** Mandatory */
public boolean IsMandatory = false;
/** Read Only */
public boolean IsReadOnly = false;
/** Updateable */
public boolean IsUpdateable = false;
/** Always Updateable */
public boolean IsAlwaysUpdateable = false;
/** Heading Only */
public boolean IsHeading = false;
/** Field Only */
public boolean IsFieldOnly = false;
/** Display Encryption */
public boolean IsEncryptedField = false;
/** Storage Encryption */
public boolean IsEncryptedColumn = false;
/** Find Selection */
public boolean IsSelectionColumn = false;
/** Selection column sequence */
public int SeqNoSelection = 0;
/** Order By */
public int SortNo = 0;
/** Field Length */
public int FieldLength = 0;
/** Format enforcement */
public String VFormat = "";
/** Format pattern */
public String FormatPattern;
/** Min. Value */
public String ValueMin = "";
/** Max. Value */
public String ValueMax = "";
/** Field Group */
public String FieldGroup = "";
/** Field Group Type */
public String FieldGroupType = "";
/** PK */
public boolean IsKey = false;
/** FK */
public boolean IsParent = false;
/** Callout */
public String Callout = "";
/** Process */
public int AD_Process_ID = 0;
/** Description */
public String Description = "";
/** Help */
public String Help = "";
/** Mandatory Logic */
public String MandatoryLogic = "";
/** Read Only Logic */
public String ReadOnlyLogic = "";
/** Display Obscure */
public String ObscureType = null;
/** Default Focus */
public boolean IsDefaultFocus = false;
/** Lookup Validation code */
public String ValidationCode = "";
/** Reference Value */
public int AD_Reference_Value_ID = 0;
/** Process Parameter Range */
public boolean isRange = false;
/** Process Parameter Value2 */
public String DefaultValue2 = "";
/** Lookup Value Object */
public MLookupInfo lookupInfo = null;
/** Field ID */
public int AD_Field_ID = 0;
/***** XPosition IDEMPIERE368***/
public int XPosition=0;
/***** ColumnSpan IDEMPIERE368***/
public int ColumnSpan=0;
/***** NumLines IDEMPIERE368***/
public int NumLines=0;
//* Feature Request FR [ 1757088 ]
public int Included_Tab_ID = 0;
/** Collapse By Default * */
public boolean IsCollapsedByDefault = false;
/** Autocompletion for textfields - Feature Request FR [ 1757088 ] */
public boolean IsAutocomplete = false;
/* Allow copy - IDEMPIERE-67 - Carlos Ruiz - globalqss */
public boolean IsAllowCopy = false;
/** Toolbar Button **/
public String IsToolbarButton = MColumn.ISTOOLBARBUTTON_Window;
public int AD_Chart_ID = 0;
public int AD_LabelStyle_ID = 0;
public int AD_FieldStyle_ID = 0;
public int PA_DashboardContent_ID = 0;
public String Placeholder = "";
public String Placeholder2 = "";
/* Is HTML String */
public boolean IsHtml = false;
/* Allow to show field in Quick Form */
public boolean IsQuickForm = false;
/**
* Set Context including contained elements
* @param newCtx new context
*/
public void setCtx (Properties newCtx)
{
ctx = newCtx;
if (lookupInfo != null)
lookupInfo.ctx = newCtx;
} // setCtx
/**
* Validate Fields and create LookupInfo if required
*/
protected void initFinish()
{
// Not null fields
if (DisplayLogic == null)
DisplayLogic = "";
if (DefaultValue == null)
DefaultValue = "";
if (FieldGroup == null)
FieldGroup = "";
if (FieldGroupType == null)
FieldGroupType = "";
if (Description == null)
Description = "";
if (Help == null)
Help = "";
if (Callout == null)
Callout = "";
if (ReadOnlyLogic == null)
ReadOnlyLogic = "";
if (MandatoryLogic == null)
MandatoryLogic = "";
if (Placeholder == null)
Placeholder = "";
// Create Lookup, if not ID
if (DisplayType.isLookup(displayType) && IsDisplayed)
{
loadLookupInfo();
}
} // initFinish
/**
* load lookup info.
* used by findwindow to loadlookupinfo for invisible field
*/
public void loadLookupInfo() {
try
{
lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, TabNo, AD_Column_ID, displayType,
Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID,
IsParent, ValidationCode);
if (lookupInfo == null)
displayType = DisplayType.ID;
}
catch (Exception e) // Cannot create Lookup
{
CLogger.get().log(Level.SEVERE, "No LookupInfo for " + ColumnName, e);
displayType = DisplayType.ID;
}
}
/**
* Clone Field.
* @param Ctx ctx
* @param windowNo window no
* @param tabNo tab no
* @param ad_Window_ID window id
* @param ad_Tab_ID tab id
* @param TabReadOnly r/o
* @return Field or null
*/
public GridFieldVO clone(Properties Ctx, int windowNo, int tabNo,
int ad_Window_ID, int ad_Tab_ID,
boolean TabReadOnly)
{
GridFieldVO clone = new GridFieldVO(Ctx, windowNo, tabNo,
ad_Window_ID, ad_Tab_ID, TabReadOnly);
//
clone.isProcess = false;
// Database Fields
clone.ColumnName = ColumnName;
clone.ColumnSQL = ColumnSQL;
clone.Header = Header;
clone.displayType = displayType;
clone.AD_Table_ID = AD_Table_ID;
clone.AD_Column_ID = AD_Column_ID;
clone.DisplayLength = DisplayLength;
clone.IsSameLine = IsSameLine;
clone.IsDisplayed = IsDisplayed;
clone.IsDisplayedGrid = IsDisplayedGrid;
clone.AD_Field_ID = AD_Field_ID;
clone.SeqNo = SeqNo;
clone.SeqNoGrid = SeqNoGrid;
clone.DisplayLogic = DisplayLogic;
clone.DefaultValue = DefaultValue;
clone.IsMandatory = IsMandatory;
clone.IsReadOnly = IsReadOnly;
clone.AD_Chart_ID = AD_Chart_ID;
clone.IsUpdateable = IsUpdateable;
clone.IsAlwaysUpdateable = IsAlwaysUpdateable;
clone.IsHeading = IsHeading;
clone.IsFieldOnly = IsFieldOnly;
clone.IsEncryptedField = IsEncryptedField;
clone.IsEncryptedColumn = IsEncryptedColumn;
clone.IsSelectionColumn = IsSelectionColumn;
clone.SeqNoSelection = SeqNoSelection;
clone.IsAutocomplete = IsAutocomplete;
clone.IsAllowCopy = IsAllowCopy;
clone.SortNo = SortNo;
clone.FieldLength = FieldLength;
clone.VFormat = VFormat;
clone.FormatPattern = FormatPattern;
clone.ValueMin = ValueMin;
clone.ValueMax = ValueMax;
clone.FieldGroup = FieldGroup;
clone.FieldGroupType = FieldGroupType;
clone.IsKey = IsKey;
clone.IsParent = IsParent;
clone.Callout = Callout;
clone.AD_Process_ID = AD_Process_ID;
clone.Description = Description;
clone.Help = Help;
clone.ReadOnlyLogic = ReadOnlyLogic;
clone.MandatoryLogic = MandatoryLogic;
clone.ObscureType = ObscureType;
clone.IsDefaultFocus = IsDefaultFocus;
clone.AD_FieldStyle_ID = AD_FieldStyle_ID;
clone.AD_LabelStyle_ID = AD_LabelStyle_ID;
clone.PA_DashboardContent_ID = PA_DashboardContent_ID;
clone.Placeholder = Placeholder;
clone.IsHtml = IsHtml;
clone.IsQuickForm = IsQuickForm;
// Lookup
clone.ValidationCode = ValidationCode;
clone.AD_Reference_Value_ID = AD_Reference_Value_ID;
clone.lookupInfo = lookupInfo;
// Process Parameter
clone.isRange = isRange;
clone.DefaultValue2 = DefaultValue2;
clone.Placeholder2 = Placeholder2;
clone.AD_Process_ID_Of_Panel = AD_Process_ID_Of_Panel;
clone.AD_Window_ID_Of_Panel = AD_Window_ID_Of_Panel;
clone.AD_Infowindow_ID = AD_Infowindow_ID;
return clone;
} // clone
/**
* String Representation
* @return info
*/
public String toString ()
{
StringBuilder sb = new StringBuilder ("MFieldVO[");
sb.append(AD_Column_ID).append("-").append(ColumnName)
.append ("]");
return sb.toString ();
} // toString
/**
*
* @author a42niem
* IDEMPIERE-1120 Implement Field SeqNo customization
*/
public static class SeqNoComparator implements Comparator<GridFieldVO> {
@Override
public int compare(GridFieldVO gf1, GridFieldVO gf2) {
return (Integer.valueOf(gf1.SeqNo)).compareTo(Integer.valueOf(gf2.SeqNo));
}
}
} // GridFieldVO