use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.AttributeNode in project scout.rt by eclipse.
the class AbstractComposerField method execCreateAttributeNode.
/**
* Override this method to decorate or enhance new nodes whenever they are created
*
* @return the new node or null to ignore the add of a new node of this type
* <p>
* Normally overrides call super. {@link #execCreateAttributeNode(ITreeNode, IDataModelAttribute, Integer,
* IComposerOp, Object[], List<String>)}
*/
@ConfigOperation
@Order(120)
protected AttributeNode execCreateAttributeNode(ITreeNode parentNode, IDataModelAttribute a, Integer aggregationType, IDataModelAttributeOp op, List<? extends Object> values, List<String> texts) {
if (aggregationType != null && aggregationType == DataModelConstants.AGGREGATION_NONE) {
aggregationType = null;
}
AttributeNode node = new AttributeNode(this, a);
node.setAggregationType(aggregationType);
node.setOp(op);
node.setValues(values);
node.setTexts(texts);
node.setStatus(ITreeNode.STATUS_INSERTED);
return node;
}
use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.AttributeNode in project scout.rt by eclipse.
the class AbstractComposerField method storeXMLRec.
private void storeXMLRec(Element x, ITreeNode parent) {
for (ITreeNode node : parent.getChildNodes()) {
if (node instanceof EntityNode) {
EntityNode entityNode = (EntityNode) node;
Element xEntity = x.getOwnerDocument().createElement("entity");
xEntity.setAttribute("id", DataModelUtility.entityPathToExternalId(getDataModel(), interceptResolveEntityPath(entityNode)));
xEntity.setAttribute("negated", (entityNode.isNegative() ? "true" : "false"));
List<String> texts = entityNode.getTexts();
xEntity.setAttribute("displayValues", CollectionUtility.hasElements(texts) ? StringUtility.emptyIfNull(CollectionUtility.firstElement(texts)) : null);
x.appendChild(xEntity);
// recursion
storeXMLRec(xEntity, node);
} else if (node instanceof AttributeNode) {
AttributeNode attNode = (AttributeNode) node;
Element xAtt = x.getOwnerDocument().createElement("attribute");
xAtt.setAttribute("id", DataModelUtility.attributePathToExternalId(getDataModel(), interceptResolveAttributePath(attNode)));
IDataModelAttributeOp op = attNode.getOp();
try {
xAtt.setAttribute("op", op.getOperator() + "");
if (attNode.getAggregationType() != null) {
xAtt.setAttribute("aggregationType", attNode.getAggregationType() + "");
}
} catch (Exception e) {
LOG.warn("write op {}", op, e);
}
List<String> texts = attNode.getTexts();
if (CollectionUtility.hasElements(texts)) {
Iterator<String> it = texts.iterator();
xAtt.setAttribute("displayValue", StringUtility.emptyIfNull(it.next()));
int i = 2;
while (it.hasNext()) {
xAtt.setAttribute(("displayValue" + i), StringUtility.emptyIfNull(it.next()));
i++;
}
}
List<Object> values = attNode.getValues();
if (values != null) {
int i = 0;
for (Object value : values) {
String valueName = (i == 0 ? "value" : "value" + (i + 1));
try {
XmlUtility.setObjectAttribute(xAtt, valueName, value);
} catch (Exception e) {
LOG.warn("write value[{}] for attribute {}: {}", i, attNode.getAttribute(), value, e);
}
i++;
}
}
x.appendChild(xAtt);
} else if (node instanceof EitherOrNode) {
EitherOrNode orNode = (EitherOrNode) node;
Element xOr = x.getOwnerDocument().createElement("or");
xOr.setAttribute("begin", "" + orNode.isBeginOfEitherOr());
xOr.setAttribute("negated", (orNode.isNegative() ? "true" : "false"));
x.appendChild(xOr);
// recursion
storeXMLRec(xOr, node);
}
}
}
use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.AttributeNode in project scout.rt by eclipse.
the class ComposerDisplayTextBuilder method visitAndNodes.
private void visitAndNodes(List<? extends ITreeNode> nodes, StringBuilder buf, String prefix) {
Iterator<? extends ITreeNode> nodeIt = nodes.iterator();
ITreeNode node = null;
boolean skipDoNext = false;
while (nodeIt.hasNext() || skipDoNext) {
// to ensure visit first node after an either or...
if (!skipDoNext) {
node = nodeIt.next();
}
// reset
skipDoNext = false;
if (node instanceof EntityNode) {
visitEntityNode((EntityNode) node, buf, prefix);
} else if (node instanceof AttributeNode) {
visitAttributeNode((AttributeNode) node, buf, prefix);
} else if (node instanceof EitherOrNode) {
List<EitherOrNode> eitherOrNodes = new ArrayList<EitherOrNode>();
eitherOrNodes.add((EitherOrNode) node);
while (nodeIt.hasNext()) {
node = nodeIt.next();
if (node instanceof EitherOrNode) {
eitherOrNodes.add((EitherOrNode) node);
} else {
skipDoNext = true;
break;
}
}
visitOrNodes(eitherOrNodes, buf, prefix);
}
}
}
Aggregations