Skip to content

Commit a9e1b8e

Browse files
author
Open Lowcode SAS
committed
Close #89
1 parent ee0be9f commit a9e1b8e

File tree

4 files changed

+113
-13
lines changed

4 files changed

+113
-13
lines changed

src/org/openlowcode/design/advanced/AdvancedDesignFeature.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ public abstract class AdvancedDesignFeature
3030
implements
3131
ActionGroup {
3232

33+
private String menuname = null;
34+
35+
/**
36+
* @param menuname for advanced design features that are launched from an object
37+
* page, the action is put in a menu of the following name
38+
*/
39+
public void setTabForObject(String menuname) {
40+
this.menuname = menuname;
41+
}
42+
43+
/**
44+
* @return
45+
*/
46+
public String getMenuForObject() {
47+
return this.menuname;
48+
}
49+
3350
private Module parentmodule;
3451

3552
/**

src/org/openlowcode/design/advanced/SmartReport.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ public void generateActionsAndPages() {
9999
blankreport = dynamicblankreport;
100100
UniqueIdentified rootobjectuniqueidentified = (UniqueIdentified) rootnode.getRelevantObject()
101101
.getPropertyByName("UNIQUEIDENTIFIED");
102-
rootobjectuniqueidentified.addActionOnObjectId(dynamicblankreport);
102+
String menuname = this.getMenuForObject();
103+
if (menuname!=null) {
104+
rootobjectuniqueidentified.addActionOnObjectId(dynamicblankreport,menuname);
105+
106+
} else {
107+
rootobjectuniqueidentified.addActionOnObjectId(dynamicblankreport);
108+
}
103109
this.getParentModule().addAction(dynamicblankreport);
104110
dynamicblankreport.addOutputArgument(new ObjectIdArgument("PARENTID_THRU", rootnode.getRelevantObject()));
105111
dynamicblankreport.addOutputArgument(new StringArgument("PARENTOBJECTLABEL_THRU", 256));

src/org/openlowcode/design/data/DataObjectDefinitionShowPage.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,20 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
397397
+ objectstoshow.get(i).getName().toLowerCase() + "Action;"); // because tables link to action
398398
}
399399

400+
ArrayList<String> specifictablist = uniqueidentifiedproperty.getSpecificTabList();
401+
for (int i=0;i<specifictablist.size();i++) {
402+
String specifictabname = specifictablist.get(i);
403+
ArrayList<DynamicActionDefinition> actionsfortab = uniqueidentifiedproperty.getActionsOnSpecifictab(specifictabname);
404+
405+
for (int j = 0; j < actionsfortab.size(); j++) {
406+
DynamicActionDefinition thisaction = actionsfortab.get(j);
407+
String path = "import " + thisaction.getModule().getPath() + ".action.";
408+
if (thisaction.isAutogenerated())
409+
path = path + "generated.Atg";
410+
path = path + StringFormatter.formatForJavaClass(thisaction.getName()) + "Action;";
411+
sg.wl(path);
412+
}
413+
}
400414
for (int i = 0; i < actionlistonobjectid.getSize(); i++) {
401415
DynamicActionDefinition thisaction = actionlistonobjectid.get(i);
402416
String path = "import " + thisaction.getModule().getPath() + ".action.";
@@ -820,7 +834,43 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
820834
sg.wl(" objectbuttonband.addElement(" + actionattributename + "forobjectbandbutton); ");
821835
sg.wl("");
822836
}
837+
838+
/// ------------------------------------------------ Specific tabs for object --------------------
839+
840+
for (int i=0;i<specifictablist.size();i++) {
841+
String specifictabname = specifictablist.get(i);
842+
sg.wl(" // Manage Specific Band "+i+" - "+specifictabname);
843+
sg.wl("");
844+
sg.wl(" SComponentBand specificpopup"+i+" = new SComponentBand(SComponentBand.DIRECTION_DOWN,this);");
845+
ArrayList<DynamicActionDefinition> actionsfortab = uniqueidentifiedproperty.getActionsOnSpecifictab(specifictabname);
846+
847+
for (int j = 0; j < actionsfortab.size(); j++) {
848+
DynamicActionDefinition thisaction = actionsfortab.get(j);
849+
String actionclassname = StringFormatter.formatForJavaClass(thisaction.getName());
850+
if (thisaction.isAutogenerated())
851+
actionclassname = "Atg" + actionclassname;
852+
String actionattributename = StringFormatter.formatForAttribute(thisaction.getName());
853+
ArgumentContent uniqueinputargument = thisaction.getInputArguments().get(0);
854+
String inputargumentclass = StringFormatter.formatForJavaClass(uniqueinputargument.getName());
855+
String buttonname = actionclassname + "Action.get().getName().toLowerCase()";
856+
if (thisaction.getButtonlabel() != null)
857+
buttonname = "\"" + thisaction.getButtonlabel() + "\"";
823858

859+
sg.wl(" " + actionclassname + "Action.ActionRef " + actionattributename
860+
+ "forobjectbandaction = " + actionclassname + "Action.get().getActionRef();");
861+
sg.wl(" " + actionattributename + "forobjectbandaction.set" + inputargumentclass
862+
+ "(objectdisplaydefinition.getAttributeInput(" + objectclass + ".getIdMarker()));");
863+
sg.wl(" SActionButton " + actionattributename + "forobjectbandbutton = new SActionButton("
864+
+ buttonname + ",\"\"," + actionattributename + "forobjectbandaction,this);");
865+
sg.wl(" specificpopup"+i+".addElement(" + actionattributename + "forobjectbandbutton); ");
866+
sg.wl("");
867+
}
868+
869+
870+
sg.wl(" SPopupButton specificpopup"+i+"button = new SPopupButton(this, specificpopup"+i+", \""+specifictabname+"\",\"\",true,true,null);");
871+
sg.wl(" objectbuttonband.addElement(specificpopup"+i+"button);");
872+
}
873+
824874
boolean first = true;
825875
sg.wl(" // Manage Band");
826876
sg.wl("");

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

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.io.IOException;
1414
import java.util.ArrayList;
15+
import java.util.HashMap;
1516

1617
import org.openlowcode.design.action.DynamicActionDefinition;
1718
import org.openlowcode.design.data.ArgumentContent;
@@ -48,8 +49,18 @@ public class UniqueIdentified
4849
Property<UniqueIdentified> {
4950
private NamedList<DynamicActionDefinition> actionsonobjectid;
5051
private NamedList<DynamicActionDefinition> actionsonobjectidonmanagetab;
52+
private HashMap<String,ArrayList<DynamicActionDefinition>> actionsonspecifictab;
53+
private ArrayList<String> specifictabs;
5154
private StoredObject storedobject;
5255

56+
public ArrayList<String> getSpecificTabList() {
57+
return this.specifictabs;
58+
}
59+
60+
public ArrayList<DynamicActionDefinition> getActionsOnSpecifictab(String specifictabname) {
61+
return this.actionsonspecifictab.get(specifictabname);
62+
}
63+
5364
/**
5465
* @return the list of actions on object id to be added to button band of the
5566
* object page
@@ -80,7 +91,8 @@ public UniqueIdentified() {
8091
super("UNIQUEIDENTIFIED");
8192
this.actionsonobjectid = new NamedList<DynamicActionDefinition>();
8293
this.actionsonobjectidonmanagetab = new NamedList<DynamicActionDefinition>();
83-
94+
this.actionsonspecifictab = new HashMap<String,ArrayList<DynamicActionDefinition>>();
95+
specifictabs = new ArrayList<String>();
8496
}
8597

8698
@Override
@@ -157,17 +169,18 @@ public void addActionOnObjectId(DynamicActionDefinition action) {
157169
addActionOnObjectId(action, false);
158170
}
159171

160-
/**
161-
* adds an action on the object, either in the main button band, or in the
162-
* manage tab
163-
*
164-
* @param action adds an action on the object id. The action should
165-
* have a single input attribute being the data object
166-
* id
167-
* @param actioninmanagetab if true, action is put in manage tabs, if false,
168-
* action is directly in the action button
169-
*/
170-
public void addActionOnObjectId(DynamicActionDefinition action, boolean actioninmanagetab) {
172+
public void addActionOnObjectId(DynamicActionDefinition action,String specialmenuname) {
173+
validateActionOnObjectId(action);
174+
ArrayList<DynamicActionDefinition> actionsforspecialmenu = this.actionsonspecifictab.get(specialmenuname);
175+
if (actionsforspecialmenu==null) {
176+
actionsforspecialmenu = new ArrayList<DynamicActionDefinition>();
177+
this.actionsonspecifictab.put(specialmenuname,actionsforspecialmenu);
178+
this.specifictabs.add(specialmenuname);
179+
}
180+
actionsforspecialmenu.add(action);
181+
}
182+
183+
private void validateActionOnObjectId(DynamicActionDefinition action) {
171184
if (action.getInputArguments().getSize() != 1)
172185
throw new RuntimeException("you can add an action on object id only if it has 1 argument, action "
173186
+ action.getName() + " has " + action.getInputArguments().getSize() + ".");
@@ -182,6 +195,20 @@ public void addActionOnObjectId(DynamicActionDefinition action, boolean actionin
182195
+ objectforid.getOwnermodule().getName() + "/" + objectforid.getName() + ", object parentid type = "
183196
+ parent.getOwnermodule().getName() + "/" + parent.getName());
184197
}
198+
}
199+
200+
/**
201+
* adds an action on the object, either in the main button band, or in the
202+
* manage tab
203+
*
204+
* @param action adds an action on the object id. The action should
205+
* have a single input attribute being the data object
206+
* id
207+
* @param actioninmanagetab if true, action is put in manage tabs, if false,
208+
* action is directly in the action button
209+
*/
210+
public void addActionOnObjectId(DynamicActionDefinition action, boolean actioninmanagetab) {
211+
validateActionOnObjectId(action);
185212

186213
if (actioninmanagetab) {
187214
this.actionsonobjectidonmanagetab.add(action);

0 commit comments

Comments
 (0)