use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode in project scout.rt by eclipse.
the class AbstractComposerField method execCreateEntityNode.
/**
* 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 #execCreateEntityNode(ITreeNode, IDataModelEntity, boolean, Object[],
* List<String>)}
*/
@ConfigOperation
@Order(110)
protected EntityNode execCreateEntityNode(ITreeNode parentNode, IDataModelEntity e, boolean negated, List<? extends Object> values, List<String> texts) {
EntityNode node = new EntityNode(this, e);
node.setValues(values);
node.setTexts(texts);
node.setNegative(negated);
node.setStatus(ITreeNode.STATUS_INSERTED);
return node;
}
use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode in project scout.rt by eclipse.
the class AbstractComposerField method execResolveEntityPath.
/**
* For {@link #exportFormFieldData(AbstractFormFieldData)}, {@link AbstractTree#exportTreeData(AbstractTreeFieldData)}
* and {@link #storeToXml(Element)} it is necessary to export {@link IDataModelEntity} and {@link IDataModelAttribute}
* as external strings. see {@link EntityPath}
* <p>
* This callback completes an entity path to its root. The parameter path contains the entity path represented in the
* composer tree of {@link EntityNode}s, the last element is the deepest tree node.
* <p>
* The default traverses the tree up to the root and collects all non-null {@link EntityNode#getEntity()}
* <p>
* This is prefixed with {@link #interceptResolveRootPathForTopLevelEntity(IDataModelEntity, List)}
*/
@ConfigOperation
@Order(99)
protected EntityPath execResolveEntityPath(EntityNode node) {
LinkedList<IDataModelEntity> list = new LinkedList<IDataModelEntity>();
EntityNode tmp = node;
while (tmp != null) {
if (tmp.getEntity() != null) {
list.add(0, tmp.getEntity());
}
// next
tmp = tmp.getAncestorNode(EntityNode.class);
}
if (list.size() > 0) {
interceptResolveRootPathForTopLevelEntity(list.get(0), list);
}
return new EntityPath(list);
}
use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode in project scout.rt by eclipse.
the class AbstractComposerField method addEntityNode.
@Override
public EntityNode addEntityNode(ITreeNode parentNode, IDataModelEntity e, boolean negated, List<? extends Object> values, List<String> texts) {
EntityNode node = interceptCreateEntityNode(parentNode, e, negated, values, texts);
if (node != null) {
getTree().addChildNode(parentNode, node);
getTree().setNodeExpanded(node, true);
}
return node;
}
use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode 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.EntityNode in project scout.rt by eclipse.
the class AbstractComposerField method execResolveAttributePath.
/**
* see {@link #execResolveEntityPathForEntityExport(EntityNode)}, {@link AttributePath} for more details
* <p>
* The path in the composer tree is prefixed with
* {@link #interceptResolveRootPathForTopLevelAttribute(IDataModelAttribute, List)}
*/
@ConfigOperation
@Order(99)
protected AttributePath execResolveAttributePath(AttributeNode node) {
LinkedList<IDataModelEntity> list = new LinkedList<IDataModelEntity>();
if (node == null) {
return null;
}
EntityNode tmp = node.getAncestorNode(EntityNode.class);
while (tmp != null) {
if (tmp.getEntity() != null) {
list.add(0, tmp.getEntity());
}
// next
tmp = tmp.getAncestorNode(EntityNode.class);
}
if (list.size() > 0) {
interceptResolveRootPathForTopLevelEntity(list.get(0), list);
} else {
interceptResolveRootPathForTopLevelAttribute(node.getAttribute(), list);
}
return new AttributePath(list, node.getAttribute());
}
Aggregations