@@ -37,6 +37,7 @@ public class DataObjectDefinitionCreatePageToFile
3737 implements
3838 GeneratedPages {
3939 private DataObjectDefinition dataobject ;
40+ private DataObjectDefinition companion ;
4041
4142 /**
4243 * creates the utility class to generate the creation page
@@ -45,13 +46,33 @@ public class DataObjectDefinitionCreatePageToFile
4546 */
4647 public DataObjectDefinitionCreatePageToFile (DataObjectDefinition dataobject ) {
4748 this .dataobject = dataobject ;
49+ this .companion =null ;
50+ }
51+
52+
53+ /**
54+ * creates the utility class to generate the creation page
55+ *
56+ * @param dataobject data object
57+ */
58+ public DataObjectDefinitionCreatePageToFile (DataObjectDefinition dataobject ,DataObjectDefinition companion ) {
59+ this .dataobject = dataobject ;
60+ this .companion =companion ;
4861 }
4962
5063 @ Override
5164 public void generateToFile (SourceGenerator sg , Module module ) throws IOException {
5265 String objectclass = StringFormatter .formatForJavaClass (dataobject .getName ());
5366 String objectvariable = StringFormatter .formatForAttribute (dataobject .getName ());
5467
68+ String pagename = objectvariable ;
69+ String companionclass = null ;
70+
71+ if (companion !=null ) {
72+ pagename = StringFormatter .formatForAttribute (companion .getName ());
73+ companionclass = StringFormatter .formatForJavaClass (companion .getName ());
74+ }
75+
5576 sg .wl ("package " + module .getPath () + ".page.generated;" );
5677 sg .wl ("" );
5778
@@ -131,6 +152,14 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
131152 String objectimport = "import " + dataobject .getOwnermodule ().getPath () + ".data." + objectclass + ";" ;
132153 importdeclaration .put (objectimport , objectimport );
133154
155+ if (companion !=null ) {
156+ String companionimport = "import " + companion .getOwnermodule ().getPath () + ".data." + companionclass + ";" ;
157+
158+ importdeclaration .put (companionimport , companionimport );
159+ String companioncreateaction = "import gallium.test.action.generated.AtgStandardcreate" +companion .getName ().toLowerCase ()+"Action;" ;
160+ importdeclaration .put (companioncreateaction , companioncreateaction );
161+ }
162+
134163 for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
135164 Property <?> thisproperty = dataobject .propertylist .get (i );
136165 if (thisproperty instanceof LinkedToParent ) {
@@ -179,8 +208,8 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
179208 sg .wl ("import org.openlowcode.server.graphic.widget.SObjectSearcher;" );
180209 sg .wl ("import org.openlowcode.server.graphic.widget.SPageText;" );
181210 sg .wl ("" );
182- sg .wl ("public class AtgStandardcreate" + objectvariable + "Page extends" );
183- sg .wl (" AbsStandardcreate" + objectvariable + "Page {" );
211+ sg .wl ("public class AtgStandardcreate" + pagename + "Page extends" );
212+ sg .wl (" AbsStandardcreate" + pagename + "Page {" );
184213 for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++)
185214 for (int j = 0 ; j < dataobject .propertylist .get (i ).getContextDataForCreationSize (); j ++) {
186215 ArgumentContent contextfordatacreation = dataobject .propertylist .get (i ).getContextDataForCreation (j );
@@ -199,15 +228,15 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
199228
200229 sg .wl (" @Override" );
201230 sg .wl (" public String generateTitle(" + pageattributedeclaration .toString ());
202- sg .wl (" " + objectclass + " object) {" );
231+ sg .wl (" " + objectclass + " object" +( companion != null ? ", " + companionclass + " companion" : "" )+ " ) {" );
203232 sg .wl (" return \" Create " + dataobject .getLabel () + "\" ;" );
204233 sg .wl (" }" );
205234
206- sg .wl (" public AtgStandardcreate" + objectvariable + "Page(" + pageattributedeclaration .toString ());
207- sg .wl (" " + objectclass + " object) {" );
235+ sg .wl (" public AtgStandardcreate" + pagename + "Page(" + pageattributedeclaration .toString ());
236+ sg .wl (" " + objectclass + " object" +( companion != null ? ", " + companionclass + " companion" : "" )+ " ) {" );
208237
209238 sg .wl (" super(" + pageattributeentry .toString ());
210- sg .wl (" object);" );
239+ sg .wl (" object" +( companion != null ? ",companion" : "" )+ " );" );
211240 sg .wl (" " );
212241 for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++)
213242 for (int j = 0 ; j < dataobject .propertylist .get (i ).getContextDataForCreationSize (); j ++) {
@@ -227,8 +256,8 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
227256 sg .wl (" " );
228257 sg .wl (" SComponentBand mainband = new SComponentBand(SComponentBand.DIRECTION_DOWN,this);" );
229258
230- sg .wl (" AtgStandardcreate" + objectvariable + "Action.ActionRef create" + objectvariable
231- + "actionref = AtgStandardcreate" + objectvariable + "Action.get().getActionRef();" );
259+ sg .wl (" AtgStandardcreate" + pagename + "Action.ActionRef create" + pagename
260+ + "actionref = AtgStandardcreate" + pagename + "Action.get().getActionRef();" );
232261 if (subobject != null ) {
233262 sg .wl (" AtgShow" + StringFormatter .formatForAttribute (subobject .getParentObjectForLink ().getName ())
234263 + "Action.ActionRef back = AtgShow"
@@ -259,7 +288,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
259288 + " = new SObjectIdStorage<" + objectidclass + ">(\" PARENTID\" ,this, this.get" + nameclass
260289 + "());" );
261290 sg .wl (" mainband.addElement(" + namevariable + ");" );
262- sg .wl (" create" + objectvariable + "actionref.set" + nameclass + "(" + namevariable
291+ sg .wl (" create" + pagename + "actionref.set" + nameclass + "(" + namevariable
263292 + ".getObjectIdInput());" );
264293 if (issubobject )
265294 sg .wl (" back.setId(" + namevariable + ".getObjectIdInput());" );
@@ -271,7 +300,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
271300 sg .wl (" mainband.addElement(new SPageText(\" Select relevant "
272301 + contextobjectid .getObject ().getLabel () + "\" ,SPageText.TYPE_TITLE,this));" );
273302 sg .wl (" mainband.addElement(" + objectidvariable + "searcher);" );
274- sg .wl (" create" + objectvariable + "actionref.set" + nameclass + "("
303+ sg .wl (" create" + pagename + "actionref.set" + nameclass + "("
275304 + objectidvariable + "searcher.getresultarray().getAttributeInput(" + objectidclass
276305 + ".getIdMarker())); " );
277306 sg .wl (" }" );
@@ -299,7 +328,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
299328 }
300329
301330 }
302- sg .wl (" SPageText title = new SPageText(\" Enter data for new " + dataobject .getLabel ()
331+ sg .wl (" SPageText title = new SPageText(\" Enter data for new " + ( companion != null ? companion . getLabel (): dataobject .getLabel () )
303332 + "\" ,SPageText.TYPE_TITLE,this);" );
304333
305334 sg .wl (" mainband.addElement(title);" );
@@ -321,7 +350,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
321350 sg .wl (" " + argumentvariable + "entryfield.setTextBusinessData(this.get"
322351 + argumentclass + "());" );
323352 sg .wl (" mainband.addElement(" + argumentvariable + "entryfield);" );
324- sg .wl (" create" + objectvariable + "actionref.set" + argumentclass + "("
353+ sg .wl (" create" + pagename + "actionref.set" + argumentclass + "("
325354 + argumentvariable + "entryfield.getTextInput()); " );
326355 treated = true ;
327356 }
@@ -339,7 +368,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
339368 sg .wl (" " + argumentvariable + "entryfield.setDateBusinessData(this.get"
340369 + argumentclass + "());" );
341370 sg .wl (" mainband.addElement(" + argumentvariable + "entryfield);" );
342- sg .wl (" create" + objectvariable + "actionref.set" + argumentclass + "("
371+ sg .wl (" create" + pagename + "actionref.set" + argumentclass + "("
343372 + argumentvariable + "entryfield.getDateInput());" );
344373 treated = true ;
345374 treated = true ;
@@ -358,7 +387,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
358387 sg .wl (" STimeslotField timeslotfield = new STimeslotField(\" ORIGINTIMESLOT\" ,\" Start Time\" ,\" End Time\" ,\" Start Time\" ,\" End Time\" , STimeslotField.DEFAULT_EMPTY," );
359388 sg .wl (" this.getStarttime(),this.getEndtime(), true, this);" );
360389 sg .wl (" mainband.addElement(timeslotfield);" );
361- sg .wl (" create" + objectvariable
390+ sg .wl (" create" + pagename
362391 + "actionref.setStarttime(timeslotfield.getStartDateInput());" );
363392 sg .wl (" create" + objectvariable + "actionref.setEndtime(timeslotfield.getEndDateInput()); " );
364393
@@ -369,10 +398,10 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
369398 sg .wl (" mainband.addElement(timeslotfield);" );
370399 sg .wl (" SIntegerField sequencefield = new SIntegerField(\" Sequence Number\" ,\" SEQUENCEFIELD\" , \" \" , new Integer(1), true,this, false,false,false, null);" );
371400 sg .wl (" mainband.addElement(sequencefield);" );
372- sg .wl (" create" + objectvariable
401+ sg .wl (" create" + pagename
373402 + "actionref.setStarttime(timeslotfield.getStartDateInput()); " );
374- sg .wl (" create" + objectvariable + "actionref.setEndtime(timeslotfield.getEndDateInput()); " );
375- sg .wl (" create" + objectvariable + "actionref.setSequence(sequencefield.getIntegerInput()); " );
403+ sg .wl (" create" + pagename + "actionref.setEndtime(timeslotfield.getEndDateInput()); " );
404+ sg .wl (" create" + pagename + "actionref.setSequence(sequencefield.getIntegerInput()); " );
376405
377406 sg .wl (" " );
378407
@@ -395,7 +424,13 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
395424 }
396425 sg .wl (" " + objectvariable + "display.setHideReadOnly();" );
397426 sg .wl (" mainband.addElement(" + objectvariable + "display);" );
398-
427+ if (companion !=null ) {
428+ sg .wl (" SObjectDisplay<" + companionclass + "> " + pagename + "display = new SObjectDisplay<"
429+ + companionclass + ">(\" COMPANIONDISPLAY\" , this.getCompanion()," + companionclass
430+ + ".getDefinition(),this, false);" );
431+ sg .wl (" " + pagename + "display.setHideReadOnly();" );
432+ sg .wl (" mainband.addElement(" + pagename + "display);" ) ;
433+ }
399434 for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
400435 Property <?> thisproperty = dataobject .propertylist .get (i );
401436 for (int j = 0 ; j < thisproperty .getDataInputSize (); j ++) {
@@ -414,7 +449,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
414449 sg .wl (" " + argumentvariable + "entryfield.setTextBusinessData(this.get"
415450 + argumentclass + "());" );
416451 sg .wl (" mainband.addElement(" + argumentvariable + "entryfield);" );
417- sg .wl (" create" + objectvariable + "actionref.set" + argumentclass + "("
452+ sg .wl (" create" + pagename + "actionref.set" + argumentclass + "("
418453 + argumentvariable + "entryfield.getActionDataInput());" );
419454 treated = true ;
420455 }
@@ -426,12 +461,16 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
426461 }
427462 }
428463
429- sg .wl (" create" + objectvariable + "actionref.setObject(" + objectvariable
464+ sg .wl (" create" + pagename + "actionref.setObject(" + objectvariable
430465 + "display.getObjectInput()); " );
466+ if (companion !=null ) {
467+ sg .wl (" create" + pagename + "actionref.setCompanion(" + pagename
468+ + "display.getObjectInput()); " );
469+ }
431470 if (dataobject .getPropertyByName ("TYPED" )!=null ) {
432- sg .wl (" create" + objectvariable + "actionref.setType(typefield.getChoiceInput());" );
471+ sg .wl (" create" + pagename + "actionref.setType(typefield.getChoiceInput());" );
433472 }
434- sg .wl (" SActionButton create = new SActionButton(\" Create\" , create" + objectvariable
473+ sg .wl (" SActionButton create = new SActionButton(\" Create\" , create" + pagename
435474 + "actionref, this);" );
436475 sg .wl (" SActionButton backbutton = new SActionButton(\" Back\" ,back,this);" );
437476 sg .wl (" " );
0 commit comments