Skip to content

Commit a7864d1

Browse files
author
Open Lowcode SAS
committed
1 parent 3ec4beb commit a7864d1

File tree

5 files changed

+131
-17
lines changed

5 files changed

+131
-17
lines changed

src/org/openlowcode/client/graphic/widget/CGrid.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public class CGrid
107107
private boolean updatemodeactive;
108108
private ArrayList<String> updateactionfields;
109109
private ArrayList<String> infoactionfields;
110+
private ArrayList<String> infoactionfieldsvalueexception;
110111
private CPageInlineAction updateinlineaction;
111112
private CPageAction cellaction;
112113
private ArrayList<CMultiFieldConstraint> allobjectconstraints;
@@ -207,11 +208,14 @@ public CGrid(MessageReader reader, CPageSignifPath parentpath) throws OLcRemoteE
207208
}
208209
this.reversetree = reader.returnNextBooleanField("RVT");
209210
infoactionfields = new ArrayList<String>();
211+
infoactionfieldsvalueexception = new ArrayList<String>();
210212
if (this.reversetree) {
211213
reader.startStructureArray("INFFLD");
212214
while (reader.structureArrayHasNextElement("INFFLD")) {
213215
String infofield = reader.returnNextStringField("NAM");
214216
infoactionfields.add(infofield);
217+
String valueexception = reader.returnNextStringField("EXC");
218+
infoactionfieldsvalueexception.add(valueexception);
215219
reader.returnNextEndStructure("INFFLD");
216220
}
217221
}
@@ -806,7 +810,9 @@ public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldvalue, B
806810
if (!(infofield instanceof ObjectDataElementKeyExtractor))
807811
throw new RuntimeException("Field"+infofield+" cannot be used as info column");
808812
ObjectDataElementKeyExtractor<ObjectDataElt,?> infofieldextractor = (ObjectDataElementKeyExtractor) infofield;
809-
treetable.setColumnReadOnlyField(infofield.getLabel(), infofieldextractor, EditableTreeTable.GROUPING_SAME);
813+
String exceptions = this.infoactionfieldsvalueexception.get(i);
814+
if (exceptions==null) treetable.setColumnReadOnlyField(infofield.getLabel(), infofieldextractor, EditableTreeTable.GROUPING_SAME);
815+
if (exceptions!=null )treetable.setColumnReadOnlyField(infofield.getLabel(), infofieldextractor, EditableTreeTable.GROUPING_SAME,exceptions);
810816
}
811817

812818
treetable.setColumnGrouping(columnextractor, valueupdater, "Total", EditableTreeTable.GROUPING_SUM);

src/org/openlowcode/client/graphic/widget/table/EditableTreeTable.java

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,24 @@ public <G> void setColumnReadOnlyField(
268268
String title,
269269
ObjectDataElementKeyExtractor<E, G> keyextractor,
270270
int grouping) {
271-
setColumnReadOnlyField(title,keyextractor.fieldExtractor(),keyextractor.labelExtractor(),grouping);
271+
setColumnReadOnlyField(title, keyextractor.fieldExtractor(), keyextractor.labelExtractor(),keyextractor.keyExtractor(), grouping);
272+
}
273+
274+
/**
275+
* A read-only column field
276+
*
277+
* @param title title of the column
278+
* @param keyextractor extractor of the field
279+
* @param grouping grouping criteria as a static int in the class
280+
* @param keyexception values to discard in the consolidation
281+
*/
282+
public <G> void setColumnReadOnlyField(
283+
String title,
284+
ObjectDataElementKeyExtractor<E, G> keyextractor,
285+
int grouping,
286+
String keyexception) {
287+
setColumnReadOnlyField(title, keyextractor.fieldExtractor(), keyextractor.labelExtractor(),
288+
keyextractor.keyExtractor(), grouping, keyexception);
272289
}
273290

274291
/**
@@ -277,14 +294,39 @@ public <G> void setColumnReadOnlyField(
277294
* @param title title of the column
278295
* @param payloadextractor extractor of the field from the payload
279296
* @param displaygenerator generates the display value from the field
297+
* @param keygenerator generates the key value from the field
280298
* @param grouping grouping criteria as a static int in the class
281299
*/
282300
public <G> void setColumnReadOnlyField(
283301
String title,
284302
Function<E, G> payloadextractor,
285303
Function<G, String> displaygenerator,
304+
Function<G, String> keygenerator,
286305
int grouping) {
287-
ReadOnlyColumn<G> column = new ReadOnlyColumn<G>(title, payloadextractor, displaygenerator, grouping);
306+
ReadOnlyColumn<
307+
G> column = new ReadOnlyColumn<G>(title, payloadextractor, displaygenerator, keygenerator, grouping);
308+
this.columngroups.add(column);
309+
}
310+
311+
/**
312+
* A read-only column field
313+
*
314+
* @param title title of the column
315+
* @param payloadextractor extractor of the field from the payload
316+
* @param displaygenerator generates the display value from the field
317+
* @param keygenerator generates the key value from the field
318+
* @param grouping grouping criteria as a static int in the class
319+
* @param keyexception values to discard in the consolidation
320+
*/
321+
public <G> void setColumnReadOnlyField(
322+
String title,
323+
Function<E, G> payloadextractor,
324+
Function<G, String> displaygenerator,
325+
Function<G, String> keygenerator,
326+
int grouping,
327+
String keyexception) {
328+
ReadOnlyColumn<G> column = new ReadOnlyColumn<G>(title, payloadextractor, displaygenerator, keygenerator,grouping,
329+
keyexception);
288330
this.columngroups.add(column);
289331
}
290332

@@ -367,10 +409,10 @@ public Node getNode() {
367409
@Override
368410
public void handle(MouseEvent event) {
369411
if (treetableview.isEditable()) {
370-
logger.severe("Sink event as editable mode");
412+
logger.fine("Sink event as editable mode");
371413
} else {
372414
if (event.getClickCount() > 1 && (event.getButton().equals(MouseButton.PRIMARY))) {
373-
logger.severe(" >>> Proper Event");
415+
logger.fine(" >>> Proper Event");
374416
if (readonlyactioneventhandler != null) {
375417

376418
ObservableList<
@@ -976,17 +1018,37 @@ private class ReadOnlyColumn<G extends Object>
9761018
private String title;
9771019
private Function<E, G> payloadextractor;
9781020
private Function<G, String> displaygenerator;
1021+
private Function<G, String> keyextractor;
9791022
private int grouping;
1023+
private String keyexception;
9801024

9811025
public ReadOnlyColumn(
9821026
String title,
9831027
Function<E, G> payloadextractor,
9841028
Function<G, String> displaygenerator,
1029+
Function<G, String> keyextractor,
9851030
int grouping) {
9861031
this.title = title;
9871032
this.payloadextractor = payloadextractor;
9881033
this.displaygenerator = displaygenerator;
1034+
this.keyextractor = keyextractor;
1035+
this.grouping = grouping;
1036+
this.keyexception = null;
1037+
}
1038+
1039+
public ReadOnlyColumn(
1040+
String title,
1041+
Function<E, G> payloadextractor,
1042+
Function<G, String> displaygenerator,
1043+
Function<G, String> keyextractor,
1044+
int grouping,
1045+
String keyexception) {
1046+
this.title = title;
1047+
this.payloadextractor = payloadextractor;
1048+
this.displaygenerator = displaygenerator;
1049+
this.keyextractor = keyextractor;
9891050
this.grouping = grouping;
1051+
this.keyexception = keyexception;
9901052
}
9911053

9921054
@Override
@@ -1012,23 +1074,35 @@ public ObservableValue<String> call(
10121074
}
10131075
if (grouping == GROUPING_SAME) {
10141076
boolean burnt = false;
1077+
logger.fine("Starting analysis for a cell -----------------------------");
10151078
for (int i = 0; i < listofobjects.getItemsNumber(); i++) {
10161079
E object = listofobjects.getItemAt(i).getPayload();
10171080
G payload = payloadextractor.apply(object);
1081+
10181082
String value = null;
1019-
if (payload != null)
1083+
String key=null;
1084+
if (payload != null) {
10201085
value = displaygenerator.apply(payload);
1086+
key = keyextractor.apply(payload);
1087+
logger.fine(" analyzing element value '"+value+"', key '"+key+"', valueexception = '"+keyexception+"'");
1088+
}
10211089
if (result == null)
1022-
if (!burnt) {
1090+
if (!burnt) if (key!=null) if (!key.equals(keyexception)) {
10231091
result = value;
1092+
logger.fine(" put in value "+result+" as '"+key+"' <> '"+keyexception+"'");
10241093
logger.finest(" > found value " + value + " for " + object.toString());
10251094
}
10261095
if (result != null)
1027-
if (!result.equals(value)) {
1028-
burnt = true;
1029-
result = null;
1030-
}
1096+
if (!result.equals(value))
1097+
if (key!=null) if (!key.equals(keyexception)) {
1098+
logger.fine(" value "+value+" burning "+result);
1099+
burnt = true;
1100+
result = null;
1101+
1102+
}
1103+
10311104
}
1105+
logger.fine(" --> "+result+", burnt = "+burnt);
10321106
}
10331107
if (grouping == GROUPING_FIRST) {
10341108
if (listofobjects.getItemsNumber() >= 1) {

src/org/openlowcode/design/data/properties/basic/LinkedFromChildren.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class LinkedFromChildren
7070
private String specifictitleforchildrentable = null;
7171
private String[] infofieldforreverseshow;
7272
private boolean reversetree;
73+
private String[] exceptionsforinfofieldconsolidation;
7374

7475
/**
7576
* @return the related linked to parent property on the child object
@@ -556,8 +557,21 @@ public void generateWidgetCode(SourceGenerator sg, Module module, String locatio
556557
readonlyfields.append(childclassname+".get"+StringFormatter.formatForJavaClass(field)+"FieldMarker()");
557558

558559
}
560+
StringBuffer readonlyfieldsexceptions = new StringBuffer();
561+
if (LinkedFromChildren.this.exceptionsforinfofieldconsolidation!=null)
562+
for (int i=0;i<LinkedFromChildren.this.exceptionsforinfofieldconsolidation.length;i++) {
563+
String exception = LinkedFromChildren.this.exceptionsforinfofieldconsolidation[i];
564+
if (i>0) readonlyfieldsexceptions.append(',');
565+
if (exception==null) {
566+
readonlyfieldsexceptions.append("null");
567+
} else {
568+
readonlyfieldsexceptions.append("\"");
569+
readonlyfieldsexceptions.append(StringFormatter.escapeforjavastring(exception));
570+
readonlyfieldsexceptions.append("\"");
571+
}
572+
}
559573
sg.wl(" " + linknameattribute + "grid.setReverseTree((DataObjectFieldMarker<" + childclassname + ">[])");
560-
sg.wl(" (new DataObjectFieldMarker<?>[] {"+readonlyfields+"}));");
574+
sg.wl(" (new DataObjectFieldMarker<?>[] {"+readonlyfields+"}),new String[]{"+readonlyfieldsexceptions.toString()+"});");
561575

562576

563577

@@ -732,9 +746,11 @@ public LinkedFromChildren(
732746
String columndisplayforgrid,
733747
String secondarycolumndisplayforgrid,
734748
String[] cellfieldsforgrid,
735-
String[] infofieldforreverseshow) {
749+
String[] infofieldforreverseshow,
750+
String[] exceptionsforinfofieldconsolidation) {
736751
this(name,childobjectforlink,originobjectproperty,linedisplayforgrid,columndisplayforgrid,secondarycolumndisplayforgrid,cellfieldsforgrid);
737752
this.infofieldforreverseshow = infofieldforreverseshow;
753+
this.exceptionsforinfofieldconsolidation = exceptionsforinfofieldconsolidation;
738754
this.reversetree=true;
739755
}
740756

src/org/openlowcode/design/data/properties/basic/LinkedToParent.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class LinkedToParent<E extends DataObjectDefinition>
7878
private String specifictitleforchildrentable = null;
7979
private HashMap<String, ArrayList<Field>> compositeindexlist;
8080
private boolean reversetreegrid;
81+
private String[] exceptionsforinfofieldconsolidation;
8182

8283
/**
8384
* gets the unique identified property on the child object the linked to parent
@@ -246,7 +247,7 @@ public LinkedToParent(
246247
String columndisplayforgrid,
247248
String secondarycolumndisplayforgrid,
248249
String cellvaluestoshow,
249-
String[] infofieldforreverseshow) {
250+
String[] infofieldforreverseshow,String [] exceptionsforinfofieldconsolidation) {
250251
super(name, "LINKEDTOPARENT");
251252
this.parentobjectforlink = parentobjectforlink;
252253
this.priorityforlinkedfromparent = priorityforlinkedfromparent;
@@ -257,7 +258,9 @@ public LinkedToParent(
257258
this.columndisplayforgrid = columndisplayforgrid;
258259
this.secondarycolumndisplayforgrid = secondarycolumndisplayforgrid;
259260
this.cellvaluestoshow = new String[] { cellvaluestoshow };
261+
260262
this.infofieldforreverseshow = infofieldforreverseshow;
263+
this.exceptionsforinfofieldconsolidation = exceptionsforinfofieldconsolidation;
261264
compositeindexlist = new HashMap<String, ArrayList<Field>>();
262265
reversetreegrid=true;
263266
}
@@ -326,7 +329,7 @@ public void controlAfterParentDefinition() {
326329
linkedfromchildren = new LinkedFromChildren(
327330
this.getInstancename() + "for" + parent.getName().toLowerCase(), this.parent, this,
328331
this.linedisplayforgrid, this.columndisplayforgrid, this.secondarycolumndisplayforgrid,
329-
this.cellvaluestoshow,this.infofieldforreverseshow);
332+
this.cellvaluestoshow,this.infofieldforreverseshow,this.exceptionsforinfofieldconsolidation);
330333
}
331334
if (this.specifictitleforchildrentable != null)
332335
linkedfromchildren.setSpecificTitleForChildrenTable(specifictitleforchildrentable);

src/org/openlowcode/server/graphic/widget/SGrid.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class SGrid<E extends DataObject<E>>
7272
private String unsavedwarningstopmessage;
7373
private boolean updatenote;
7474
private boolean reversetree = false;
75+
private ArrayList<String> exceptionskeysforeversetree;
7576

7677
/**
7778
* gives a reference to the updated objects in the grid
@@ -177,13 +178,22 @@ public SGrid(
177178
/**
178179
* display as a reverse tree. The several columns criteria will actually be
179180
* shown as lines for grouping in a tree
181+
*
182+
* @param fieldmarkersforinfo list of fields to show as column
183+
* @param exceptionsforfieldconsolidation keys to excluded for the consolidation
180184
*/
181-
public void setReverseTree(DataObjectFieldMarker<E>[] fieldmarkersforinfo) {
185+
public void setReverseTree(
186+
DataObjectFieldMarker<E>[] fieldmarkersforinfo,
187+
String[] exceptionsforfieldconsolidation) {
182188
this.reversetree = true;
183189
infofieldsforreversetree = new ArrayList<DataObjectFieldMarker<E>>();
184190
if (fieldmarkersforinfo != null)
185191
for (int i = 0; i < fieldmarkersforinfo.length; i++)
186192
infofieldsforreversetree.add(fieldmarkersforinfo[i]);
193+
exceptionskeysforeversetree = new ArrayList<String>();
194+
if (exceptionsforfieldconsolidation!=null)
195+
for (int i=0;i<exceptionsforfieldconsolidation.length;i++)
196+
exceptionskeysforeversetree.add(exceptionsforfieldconsolidation[i]);
187197

188198
}
189199

@@ -330,9 +340,14 @@ public void WritePayloadToCDL(MessageWriter writer, SPageData input, SecurityBuf
330340
writer.addBooleanField("RVT", this.reversetree);
331341
if (this.reversetree) {
332342
writer.startStructure("INFFLDS");
333-
for (int i=0;i<this.infofieldsforreversetree.size();i++) {
343+
for (int i = 0; i < this.infofieldsforreversetree.size(); i++) {
334344
writer.startStructure("INFFLD");
335345
writer.addStringField("NAM", infofieldsforreversetree.get(i).toString());
346+
if (exceptionskeysforeversetree.size()>i) {
347+
writer.addStringField("EXC", exceptionskeysforeversetree.get(i));
348+
} else {
349+
writer.addStringField("EXC", null);
350+
}
336351
writer.endStructure("INFFLD");
337352
}
338353
writer.endStructure("INFFLDS");

0 commit comments

Comments
 (0)