@@ -33,6 +33,7 @@ public class DataObjectDefinitionUpdatePage
3333 GeneratedPages {
3434
3535 private DataObjectDefinition dataobject ;
36+ private DataObjectDefinition companionobject ;
3637
3738 /**
3839 * creates the update page class for the provided data object
@@ -41,11 +42,31 @@ public class DataObjectDefinitionUpdatePage
4142 */
4243 public DataObjectDefinitionUpdatePage (DataObjectDefinition dataobject ) {
4344 this .dataobject = dataobject ;
45+ this .companionobject = null ;
46+ }
47+
48+ /**
49+ * creates the update page class for the provided data object
50+ *
51+ * @param dataobject data object definition
52+ * @param companionobject companion data object definition (for typed object)
53+ */
54+ public DataObjectDefinitionUpdatePage (DataObjectDefinition dataobject , DataObjectDefinition companionobject ) {
55+ this .companionobject = companionobject ;
56+ this .dataobject = dataobject ;
4457 }
4558
4659 @ Override
4760 public void generateToFile (SourceGenerator sg , Module module ) throws IOException {
4861 String pagename = "Update" + dataobject .getName ().toLowerCase () + "Page" ;
62+ String companionclass = null ;
63+ String companionvariable = null ;
64+
65+ if (companionobject != null ) {
66+ pagename = "Update" + companionobject .getName ().toLowerCase () + "Page" ;
67+ companionclass = StringFormatter .formatForJavaClass (companionobject .getName ());
68+ companionvariable = StringFormatter .formatForAttribute (companionobject .getName ());
69+ }
4970 String objectclass = StringFormatter .formatForJavaClass (dataobject .getName ());
5071 String objectvariable = StringFormatter .formatForAttribute (dataobject .getName ());
5172 HashMap <String , String > importdeclaration = new HashMap <String , String >();
@@ -83,26 +104,35 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
83104 pageattributeentry .append (" , " );
84105 pageattributeentry .append (" controlstatus " );
85106 }
86-
87- // ------------------------ Attributes for field suggestions ---------------------
88- for (int i =0 ;i <dataobject .fieldlist .getSize ();i ++) {
107+
108+ // ------------------------ Attributes for field suggestions
109+ // ---------------------
110+ for (int i = 0 ; i < dataobject .fieldlist .getSize (); i ++) {
89111 if (dataobject .fieldlist .get (i ) instanceof StringField ) {
90- StringField stringfield = (StringField ) dataobject .fieldlist .get (i );
112+ StringField stringfield = (StringField ) dataobject .fieldlist .get (i );
91113 if (stringfield .hasListOfValuesHelper ()) {
92-
114+
93115 pageattributedeclaration
94- .append (", String[] suggestionsforfield" + stringfield .getName ().toLowerCase ()+ " " );
95-
116+ .append (", String[] suggestionsforfield" + stringfield .getName ().toLowerCase () + " " );
117+
96118 pageattributeentry .append (", suggestionsforfield" + stringfield .getName ().toLowerCase () + " " );
97119 }
98120 }
99121 }
100-
122+
101123 sg .wl ("package " + module .getPath () + ".page.generated;" );
102124 sg .wl ("" );
103125 sg .wl ("import " + module .getPath () + ".action.generated.AtgShow" + objectvariable + "Action;" );
104- sg .wl ("import " + module .getPath () + ".action.generated.AtgUpdate" + objectvariable + "Action;" );
126+ if (companionobject == null ) {
127+ sg .wl ("import " + module .getPath () + ".action.generated.AtgUpdate" + objectvariable + "Action;" );
128+ } else {
129+ sg .wl ("import " + companionobject .getOwnermodule ().getPath () + ".action.generated.AtgUpdate"
130+ + companionvariable + "Action;" );
131+ }
105132 sg .wl ("import " + module .getPath () + ".data." + objectclass + ";" );
133+ if (companionobject != null ) {
134+ sg .wl ("import " + companionobject .getOwnermodule ().getPath () + ".data." + companionclass + ";" );
135+ }
106136 sg .wl ("import org.openlowcode.server.action.SActionRef;" );
107137 sg .wl ("import org.openlowcode.server.graphic.SPageNode;" );
108138 sg .wl ("import org.openlowcode.server.graphic.widget.STextField;" );
@@ -120,8 +150,10 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
120150
121151 sg .wl (" @Override" );
122152 sg .wl (" public String generateTitle(" + objectclass + " " + objectvariable + " "
153+ + (companionobject != null ? ", " + companionclass + " " + companionvariable + " " : "" )
123154 + pageattributedeclaration .toString () + ") {" );
124- sg .wl (" String objectdisplay = \" Update " + dataobject .getLabel () + "\" ;" );
155+ sg .wl (" String objectdisplay = \" Update "
156+ + (companionobject != null ? companionobject .getLabel () : dataobject .getLabel ()) + "\" ;" );
125157 if (dataobject .getPropertyByName ("NUMBERED" ) != null ) {
126158 sg .wl (" objectdisplay+=\" \" +" + objectvariable + ".getNr();" );
127159 }
@@ -133,17 +165,20 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
133165 sg .wl (" }" );
134166
135167 sg .wl (" public Atg" + pagename + "(" + objectclass + " " + objectvariable + " "
168+ + (companionobject != null ? ", " + companionclass + " " + companionvariable + " " : "" )
136169 + pageattributedeclaration .toString () + ") {" );
137- sg .wl (" super(" + objectvariable + " " + pageattributeentry .toString () + ");" );
170+ sg .wl (" super(" + objectvariable + (companionobject != null ? ", " + companionvariable + " " : "" ) + " "
171+ + pageattributeentry .toString () + ");" );
138172 sg .wl (" " );
139173 sg .wl (" }" );
140174 sg .wl ("" );
141175 sg .wl (" @Override" );
142176 sg .wl (" protected SPageNode getContent() {" );
143177 sg .wl (" SComponentBand mainband = new SComponentBand(SComponentBand.DIRECTION_DOWN,this);" );
144178 sg .wl (" mainband.addElement(new SPageText(\" Update " + objectclass + "\" ,SPageText.TYPE_TITLE,this));" );
145- sg .wl (" AtgUpdate" + objectvariable + "Action.ActionRef update" + objectvariable + "actionref = AtgUpdate"
146- + objectvariable + "Action.get().getActionRef();" );
179+ sg .wl (" AtgUpdate" + (companionobject != null ? companionvariable : objectvariable )
180+ + "Action.ActionRef update" + objectvariable + "actionref = AtgUpdate"
181+ + (companionobject != null ? companionvariable : objectvariable ) + "Action.get().getActionRef();" );
147182 if (isdatacontrol ) {
148183 sg .wl (" STextField controlstatus = new STextField(\" Control Status\" ,\" CONTROLSTATUS\" ,\" \" ,20000, \" \" ," );
149184 sg .wl (" false,this, true, false, false,null, false);" );
@@ -157,17 +192,27 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
157192 + ".getDefinition(),this, false);" );
158193 sg .wl (" update" + objectvariable + "actionref.set" + objectclass
159194 + "(objectupdatedefinition.getObjectInput()); " );
195+ if (companionobject != null ) {
196+ sg .wl (" SObjectDisplay<" + companionclass + "> companionupdatedefinition = new SObjectDisplay<"
197+ + companionclass + ">(\" " + companionobject .getName ().toUpperCase () + "\" , this.get"
198+ + companionclass + "()," + companionclass + ".getDefinition(),this, false);" );
199+ sg .wl (" update" + objectvariable + "actionref.set" + companionclass
200+ + "(companionupdatedefinition.getObjectInput()); " );
201+ sg .wl (" companionupdatedefinition.setReducedDisplay(false);" );
202+ }
160203
161- for (int i = 0 ; i < dataobject .fieldlist .getSize ();i ++) {
204+ for (int i = 0 ; i < dataobject .fieldlist .getSize (); i ++) {
162205 if (dataobject .fieldlist .get (i ) instanceof StringField ) {
163- StringField stringfield = (StringField ) dataobject .fieldlist .get (i );
206+ StringField stringfield = (StringField ) dataobject .fieldlist .get (i );
164207 if (stringfield .hasListOfValuesHelper ()) {
165- sg .wl (" objectupdatedefinition.addTextFieldSuggestion(" +objectclass +".get" +StringFormatter .formatForJavaClass (stringfield .getName ())+"FieldMarker(),this.getSuggestionsforfield" +stringfield .getName ().toLowerCase ()+"());" );
208+ sg .wl (" objectupdatedefinition.addTextFieldSuggestion(" + objectclass + ".get"
209+ + StringFormatter .formatForJavaClass (stringfield .getName ())
210+ + "FieldMarker(),this.getSuggestionsforfield" + stringfield .getName ().toLowerCase ()
211+ + "());" );
166212 }
167213 }
168214 }
169-
170-
215+
171216 for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
172217 Property <?> thisproperty = dataobject .propertylist .get (i );
173218 if (thisproperty .isDataInputUsedForUpdate ())
@@ -199,6 +244,8 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
199244
200245 }
201246 sg .wl (" mainband.addElement(objectupdatedefinition);" );
247+ if (companionobject != null )
248+ sg .wl (" mainband.addElement(companionupdatedefinition);" );
202249
203250 for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
204251 Property <?> thisproperty = dataobject .propertylist .get (i );
0 commit comments