Skip to content

Commit

Permalink
Close #264 Close #261
Browse files Browse the repository at this point in the history
  • Loading branch information
Open Lowcode SAS committed Nov 10, 2020
1 parent 9988964 commit 982bf16
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 41 deletions.
6 changes: 6 additions & 0 deletions src/org/openlowcode/client/action/CPageInlineAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.openlowcode.tools.structure.DataElt;
import org.openlowcode.tools.structure.DataEltType;
import org.openlowcode.tools.structure.MultipleChoiceDataElt;
import org.openlowcode.tools.structure.ObjectDataElt;
import org.openlowcode.tools.structure.ObjectIdDataElt;
import org.openlowcode.tools.structure.ObjectIdDataEltType;
import org.openlowcode.tools.structure.TextDataElt;
Expand Down Expand Up @@ -116,6 +117,11 @@ public CActionData getDataContent(CPage page) {
result.addActionAttribute(new ObjectIdDataElt(thisbusinessdataloc.getName()));
}

if (thisbusinessdataloc.getType().equals("OBJ")) {
treated=true;
result.addActionAttribute(new ObjectDataElt(thisbusinessdataloc.getName()));
}

if (thisbusinessdataloc.getType().startsWith("ARR")) {
String subtype = thisbusinessdataloc.getType().substring(4);
if (subtype.compareTo(CActionDataLoc.CHOICE_TYPE) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/org/openlowcode/client/graphic/CPageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void processInlineAction(String module, String name, CPageData newdata) {
throw new RuntimeException("Name in trigggered inline action is null ");

if ((currentref.getModule().compareTo(module) == 0) && (currentref.getName().compareTo(name) == 0)) {
LOGGER.finer("found one match for action");
LOGGER.finer("found one match for action for module "+module+", action "+name+" index = "+i);
DataElt dataelt = newdata.getDataElement(currentref.getFieldorder());
Platform.runLater(new Runnable() {

Expand Down
14 changes: 11 additions & 3 deletions src/org/openlowcode/client/graphic/widget/CFieldSearcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Logger;

import org.openlowcode.tools.messages.MessageReader;
import org.openlowcode.tools.messages.OLcRemoteException;
Expand All @@ -36,6 +37,7 @@
import org.openlowcode.tools.structure.SimpleDataElt;
import org.openlowcode.tools.structure.TextDataElt;
import org.openlowcode.tools.structure.TextDataEltType;

import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
Expand Down Expand Up @@ -97,6 +99,7 @@ public class CFieldSearcher
private CPageInlineAction inlineenirichaction;
private Tooltip searchtooltip;

private static Logger logger = Logger.getLogger(CFieldSearcher.class.getName());
/**
* creates the CFieldSearcher from a message from the server
*
Expand Down Expand Up @@ -228,10 +231,14 @@ public void handle(KeyEvent keyevent) {
ButtonHandler buttonhandler = new ButtonHandler(actionmanager);
bottombutton.setOnMouseClicked(buttonhandler);
}
if (inlineenirichaction != null)
if (inlineenirichaction != null) {
actionmanager.registerInlineAction(resultlist, inlineenirichaction);
if (actionaftersearch != null)
logger.finer(" --> CFieldSearcher adding inline enrich action "+inlineenirichaction.getModule()+"/"+inlineenirichaction.getName());
}
if (actionaftersearch != null) {
actionmanager.registerEvent(resultlist, actionaftersearch);
logger.finer(" --> CFieldSearcher add action after search "+actionaftersearch.getModule()+"/"+actionaftersearch.getName());
}
resultlist.addEventHandler(ActionEvent.ACTION, actionmanager);
resultlist.setOnMouseClicked(new EventHandler<MouseEvent>() {

Expand Down Expand Up @@ -301,12 +308,13 @@ public DataElt getDataElt(DataEltType type, String eltname, String objectdataloc
@SuppressWarnings("unchecked")
@Override
public void forceUpdateData(DataElt dataelt) {

logger.finer(" --> gets data element in the CFieldSearcher");
if (!(dataelt instanceof ArrayDataElt))
throw new RuntimeException(
String.format("inline page data does not have expected %s type, actually found %s",
dataelt.getName(), dataelt.getType()));
data = (ArrayDataElt<ObjectDataElt>) dataelt;
logger.finer("--> got an array with "+data.getObjectNumber()+" elements");
ArrayList<String> itemstoshow = new ArrayList<String>();
for (int i = 0; i < data.getObjectNumber(); i++) {
ObjectDataElt thisobject = data.getObjectAtIndex(i);
Expand Down
15 changes: 11 additions & 4 deletions src/org/openlowcode/client/graphic/widget/CObjectArrayField.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public Node getNode(
Window parentwindow,
TabPane[] parenttabpanes,
CollapsibleNode nodetocollapsewhenactiontriggered) {
logger.fine("built node CObjectArrayField " + this.name);
logger.finer("built node CObjectArrayField " + this.name);
this.actionmanager = actionmanager;
if (this.inlinefeeding) {
inputdata.addInlineActionDataRef(this.feedinginlineactionoutputdata);
Expand Down Expand Up @@ -280,13 +280,20 @@ public void forceUpdateData(DataElt dataelt) {
boolean treated = false;
if (dataelt instanceof ArrayDataElt) {
thiselementarray = (ArrayDataElt<ObjectDataElt>) dataelt;
logger.severe("--> putting an array of "+thiselementarray.getObjectNumber()+" elements ");

refreshDisplay();
treated = true;
}
if (dataelt instanceof ObjectDataElt) {

ObjectDataElt element = (ObjectDataElt) dataelt;
if (this.keeponlyone) if (thiselementarray.getObjectNumber()==1) thiselementarray.removeObjectAtIndex(0);
if (this.keeponlyone) if (thiselementarray.getObjectNumber()==1) {
logger.finer("--> cleaning object "+thiselementarray.getObjectAtIndex(0).getUID()+ " - "+element.toString());
thiselementarray.removeObjectAtIndex(0);

}
logger.finer("--> adding object "+element.getUID()+ " - "+element.toString()+" number of elements before = "+thiselementarray.getObjectNumber());
thiselementarray.addElement(element.deepcopy(thiselementarray.getName()));

refreshDisplay();
Expand Down Expand Up @@ -317,7 +324,7 @@ public void handle(MouseEvent mouseevent) {
}

private void refreshDisplay() {
logger.fine("Refresh CObjectArrayField " + this.name);
logger.finer("Refresh CObjectArrayField " + this.name);

datapane.getChildren().clear();
CBusinessField<?> selectedfield = null;
Expand Down Expand Up @@ -367,7 +374,7 @@ private void refreshDisplay() {

objectbutton.setOnMousePressed(new ObjectArrayFieldMouseEvent(i));

logger.fine("Add objectbutton " + buttontitle);
logger.finer("Add objectbutton " + buttontitle);
datapane.getChildren().add(objectbutton);

}
Expand Down
2 changes: 1 addition & 1 deletion src/org/openlowcode/design/data/DataObjectDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -2560,7 +2560,7 @@ private void addAttributesToCreateobject(
if (addlinks) for (int i = 0; i < object.propertylist.getSize(); i++) {
Property<?> property = object.propertylist.get(i);
if (property instanceof LeftForLink) {
LeftForLink leftforlink = (LeftForLink) property;
LeftForLink<?,?> leftforlink = (LeftForLink<?,?>) property;
if (leftforlink.getLinkObjectProperty().getBusinessRuleByName("DISPLAYASATTRIBUTEFROMLEFT") != null) {
action.addInputArgument(new ArrayArgument(
new ObjectArgument("LEFT" + leftforlink.getLinkObjectDefinition().getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
import org.openlowcode.design.generation.StringFormatter;
import org.openlowcode.design.module.Module;
import org.openlowcode.design.pages.SearchWidgetDefinition;
import org.openlowcode.module.designer.data.Dataobjectdef;
import org.openlowcode.server.action.SInlineEchoActionRef;
import org.openlowcode.server.data.message.TObjectDataEltType;

/**
* Generation of the creation page for a Data Object
*
Expand Down Expand Up @@ -147,13 +143,13 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
for (int i = 0; i < leftlinkedproperties.size(); i++) {
LeftForLink<?, ?> leftlinkedproperty = leftlinkedproperties.get(i);
DataObjectDefinition linkobject = leftlinkedproperty.getLinkObjectDefinition();
@SuppressWarnings("unused")
String linkobjectclass = StringFormatter.formatForJavaClass(linkobject.getName());
String linkobjectvariable = StringFormatter.formatForAttribute(linkobject.getName());
String rightobjectvariable = StringFormatter
.formatForAttribute(leftlinkedproperty.getRightObjectForLink().getName());
String rightobjectclass = StringFormatter
.formatForJavaClass(leftlinkedproperty.getRightObjectForLink().getName());
@SuppressWarnings("rawtypes")
DisplayLinkAsAttributeFromLeftObject<
?, ?> attributeasleft = (DisplayLinkAsAttributeFromLeftObject) leftlinkedproperty
.getLinkObjectProperty().getBusinessRuleByName("DISPLAYASATTRIBUTEFROMLEFT");
Expand Down Expand Up @@ -549,14 +545,11 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
.formatForAttribute(leftlinkedproperty.getRightObjectForLink().getName());
String rightobjectclass = StringFormatter
.formatForJavaClass(leftlinkedproperty.getRightObjectForLink().getName());
@SuppressWarnings("rawtypes")
DisplayLinkAsAttributeFromLeftObject<
?, ?> attributeasleft = (DisplayLinkAsAttributeFromLeftObject) leftlinkedproperty
.getLinkObjectProperty().getBusinessRuleByName("DISPLAYASATTRIBUTEFROMLEFT");

if (attributeasleft != null) {
Typed typed = (Typed) leftlinkedproperty.getParent().getPropertyByName("TYPED");
@SuppressWarnings("rawtypes")
ConstraintOnLinkTypeRestrictionForLeft typerestrictionforleft = (ConstraintOnLinkTypeRestrictionForLeft) leftlinkedproperty
.getLinkObjectProperty().getBusinessRuleByName("TYPERESTRICTIONFORLEFT");
sg.wl("// ---------------- Display " + linkobjectclass + " as object array field -------------------");
Expand Down Expand Up @@ -586,7 +579,8 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException

sg.wl(" mainband.addElement(left" + linkobjectvariable + "s);");
}

if (leftlinkedproperty.isUniqueLinkFromLeft()) sg.wl(" left" + linkobjectvariable
+ "s.setKeepOnlyOne(); ");
sg.wl(" ");


Expand Down Expand Up @@ -657,9 +651,6 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
}
sg.wl(" }, left" + linkobjectvariable + "nodes.toArray(new SPageNode[0]));");

sg.wl(" left" + linkobjectvariable + "s.addFeedingInlineAction(addtoleft"
+ linkobjectvariable + "ssearchaction,addtoleft" + linkobjectvariable
+ "s_resultechoaction.getOutputActionDataRef());");

}
sg.wl(" create" + pagename + "actionref.setLeft" + linkobjectvariable + "(left"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void generateArgumentsForLinkSecondaryObjects(
for (int i=0;i<sideobject.getPropertySize();i++) {
Property<?> thisproperty = sideobject.getPropertyAt(i);
if (thisproperty instanceof LinkedToParent) {
LinkedToParent linkedtoparent = (LinkedToParent) thisproperty;
LinkedToParent<?> linkedtoparent = (LinkedToParent<?>) thisproperty;
ObjectIdArgument parentidargument = new ObjectIdArgument("LINKEDTOPARENTFOR"+linkedtoparent.getInstancename()+"ID",linkedtoparent.getParentObjectForLink());
parentidargument.setOptional(true);
searchactionforrightobjectlink.addInputArgument(parentidargument);
Expand All @@ -112,7 +112,7 @@ private void generateSideAttributesArgumentsForAction(DataObjectDefinition objec
for (int i=0;i<object.getPropertySize();i++) {
Property<?> thisproperty = object.getPropertyAt(i);
if (thisproperty instanceof LinkedToParent) {
LinkedToParent linkedtoparent = (LinkedToParent) thisproperty;
LinkedToParent<?> linkedtoparent = (LinkedToParent<?>) thisproperty;
String name = ("LINKEDTOPARENTFOR"+linkedtoparent.getInstancename()+"ID").toLowerCase();
sg.w(", DataObjectId<"+StringFormatter.formatForJavaClass(linkedtoparent.getParentObjectForLink().getName())+"> "+name+" ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
Property<?> thisproperty = leftlinkedproperty.getRightObjectForLink().getPropertyAt(j);
if (thisproperty instanceof LinkedToParent) {
LinkedToParent<?> rightobjectlinkedtoparent = (LinkedToParent<?>) thisproperty;
LinkedToParent<?> leftobjectlinkedtoparent = this.getLeftLinkedToParent(
LinkedToParent<?> leftobjectlinkedtoparent = DataObjectDefinitionShowPage.getLeftLinkedToParent(
leftlinkedproperty.getLinkObjectProperty(), rightobjectlinkedtoparent);
sg.wl(" createlinkandrightobjectfor" + linkobjectvariable
+ ".setLinkedtoparentfor"
Expand Down Expand Up @@ -1552,6 +1552,12 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
+ "(null);");
sg.wl(" addtoleft" + linkobjectvariable + "ssearchaction.setNr(addtoleft"
+ linkobjectvariable + "ssearcher.getSearchTextInput());");
for (int j=0;j<this.dataobject.getPropertySize();j++) {
if (dataobject.getPropertyAt(j) instanceof LinkedToParent) {
LinkedToParent<?> parent = (LinkedToParent<?>) dataobject.getPropertyAt(j);
sg.wl(" addtoleft" + linkobjectvariable + "ssearchaction.setLinkedtoparentfor"+parent.getInstancename().toLowerCase()+"id(null);");
}
}
for (int j = 0; j < leftlinkedproperty.getRightObjectForLink().getSearchWidgets().length; j++) {
SearchWidgetDefinition searchwidget = leftlinkedproperty.getRightObjectForLink()
.getSearchWidgets()[j];
Expand Down
54 changes: 38 additions & 16 deletions src/org/openlowcode/design/data/properties/basic/LeftForLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.openlowcode.design.data.DataObjectDefinition;
import org.openlowcode.design.data.MethodAdditionalProcessing;
import org.openlowcode.design.data.Property;
import org.openlowcode.design.data.PropertyBusinessRule;
import org.openlowcode.design.data.PropertyGenerics;
import org.openlowcode.design.data.argument.ObjectIdArgument;
import org.openlowcode.design.generation.SourceGenerator;
Expand Down Expand Up @@ -297,8 +298,8 @@ public class LinkFromLeftTableWidget
super("LINKFROMLEFTTABLE");
this.parentproperty = parentproperty;
typed = (Typed) this.parentproperty.getParent().getPropertyByName("TYPED");
typerestrictionforleft = (ConstraintOnLinkTypeRestrictionForLeft) parentproperty
.getLinkObjectProperty().getBusinessRuleByName("TYPERESTRICTIONFORLEFT");
typerestrictionforleft = (ConstraintOnLinkTypeRestrictionForLeft) parentproperty.getLinkObjectProperty()
.getBusinessRuleByName("TYPERESTRICTIONFORLEFT");
}

@Override
Expand All @@ -310,7 +311,7 @@ public String[] getImportStatements() {
importstatements.add("import org.openlowcode.server.graphic.widget.SObjectArrayField;");
importstatements.add("import org.openlowcode.server.graphic.widget.SObjectSearcher;");
importstatements.add("import org.openlowcode.server.graphic.widget.SPopupButton;");
if (typerestrictionforleft!=null) {
if (typerestrictionforleft != null) {
importstatements.add("import java.util.ArrayList;");
}
String linkobjectvariable = StringFormatter
Expand Down Expand Up @@ -365,16 +366,17 @@ public void generateWidgetCode(
sg.wl(" // Display " + linkobjectclass);
sg.wl(" // ------------------------------------------------------------------------------------------");
sg.wl("");
if (this.typerestrictionforleft!=null) {
sg.wl(" ArrayList<SPageNode> left" + linkobjectvariable + "nodes = new ArrayList<SPageNode>();");
if (this.typerestrictionforleft != null) {
sg.wl(" ArrayList<SPageNode> left" + linkobjectvariable
+ "nodes = new ArrayList<SPageNode>();");
sg.wl(" left" + linkobjectvariable + "nodes.add(new SPageText(\""
+ parentproperty.getLinkObjectProperty().getLabelFromLeft()
+ "\",SPageText.TYPE_TITLE,this));");
} else {
sg.wl(" " + locationname + ".addElement(new SPageText(\""
+ parentproperty.getLinkObjectProperty().getLabelFromLeft()
+ "\",SPageText.TYPE_TITLE,this));");

sg.wl(" " + locationname + ".addElement(new SPageText(\""
+ parentproperty.getLinkObjectProperty().getLabelFromLeft()
+ "\",SPageText.TYPE_TITLE,this));");
}
sg.wl(" SObjectArray<" + linkobjectclass + "> left" + linkobjectvariable + "s = new SObjectArray<"
+ linkobjectclass + ">(\"LEFT" + linkobjectclass.toUpperCase() + "\",");
Expand Down Expand Up @@ -497,26 +499,27 @@ public void generateWidgetCode(
+ ", this);");
sg.wl(" left" + linkobjectvariable + "buttonbar.addElement(deleteoneofleft" + linkobjectvariable
+ "button);");
if (this.typerestrictionforleft!=null) {
if (this.typerestrictionforleft != null) {
sg.wl(" left" + linkobjectvariable + "nodes.add(left" + linkobjectvariable + "buttonbar);");
sg.wl(" left" + linkobjectvariable + "nodes.add(left" + linkobjectvariable + "s);");
ChoiceValue[] allowedtypes = this.typerestrictionforleft.getAllowedTypes();

sg.wl(" mainband.addConditionalElements(this.getTypechoice(),");
sg.wl(" new ChoiceValue[] { ");
for (int t=0;t<allowedtypes.length;t++) {
for (int t = 0; t < allowedtypes.length; t++) {
;
sg.wl(" "+(t>0?",":"")+StringFormatter.formatForJavaClass(this.typed.getTypes().getName())+"ChoiceDefinition.get()."+allowedtypes[t].getName());
sg.wl(" " + (t > 0 ? "," : "")
+ StringFormatter.formatForJavaClass(this.typed.getTypes().getName())
+ "ChoiceDefinition.get()." + allowedtypes[t].getName());
}
sg.wl(" }, left" + linkobjectvariable + "nodes.toArray(new SPageNode[0]));");


} else {
sg.wl(" " + locationname + ".addElement(left" + linkobjectvariable + "buttonbar);");
sg.wl(" " + locationname + ".addElement(left" + linkobjectvariable + "s);");

}
} else {
} else {
// -------------------------------------------------------------------------------------------------
// show link as field array
}
Expand All @@ -529,4 +532,23 @@ public WidgetDisplayPriority getWidgetPriority() {
}

}

/**
* utility method telling is the link is unique for left, restricting widgets
* when needed in (especially in creation page)
*
* @return
*/
public boolean isUniqueLinkFromLeft() {
LinkObject<?, ?> linkobject = this.getLinkObjectProperty();
for (int i = 0; i < linkobject.getBusinessRuleNumber(); i++) {
PropertyBusinessRule<?> businessrule = linkobject.getBusinessRule(i);
if (businessrule instanceof ConstraintOnLinkMaxOneFromLeft)
return true;
if (businessrule instanceof ConstraintOnLinkUniqueForLeftAndRight)
return true;
}
return false;
}

}
2 changes: 1 addition & 1 deletion src/org/openlowcode/design/module/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ public static void main(String args[]) {
} catch (Throwable e) {
errormodules.add(classpath + " - " + e.getMessage() + "\n - " + e.getStackTrace()[0] + "\n - "
+ (e.getStackTrace().length > 1 ? e.getStackTrace()[1] : ""));
logger.severe("Exception " + e.getMessage());
logger.severe("Exception "+e.getClass().toString()+" - " + e.getMessage());
for (int s = 0; s < e.getStackTrace().length; s++) {
logger.severe(" - " + e.getStackTrace()[s].toString());
}
Expand Down

0 comments on commit 982bf16

Please sign in to comment.