use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class SetRepetableAction method init.
public void init() {
setText(SET_AS_REPEATABLE_ELEMENT);
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node == null) {
this.setEnabled(false);
return;
}
if (node.isRepetable()) {
this.setEnabled(true);
this.setText(REMOVE_REPEATABLE);
return;
}
if (node.getLabel().length() != 3) {
this.setEnabled(false);
return;
}
this.setEnabled(true);
}
use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method sortOrder.
private void sortOrder(HL7TreeNode treeNode, HL7TreeNode node) {
if (node != null) {
List<HL7TreeNode> children = node.getChildren();
if (treeNode != null) {
int tmpOrder = 0;
int attrNsCount = 0;
for (HL7TreeNode child : children) {
if (child.getOrder() < treeNode.getOrder()) {
tmpOrder++;
}
if (child.isAttribute() || child.isNameSpace()) {
attrNsCount++;
}
}
if (tmpOrder > -1) {
int oldOrder = children.indexOf(treeNode);
if (oldOrder != -1 && oldOrder != tmpOrder) {
node.removeChild(treeNode);
if (children.size() > tmpOrder) {
node.addChild(tmpOrder - attrNsCount, treeNode);
} else {
node.addChild(treeNode);
}
}
}
}
}
}
use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method treeNodeAdapt.
private List treeNodeAdapt() {
List<HL7TreeNode> treeData = new ArrayList<HL7TreeNode>();
FileDialog f = null;
if (hl7ui != null) {
f = new FileDialog(hl7ui.getHl7UIParent().getShell());
} else if (form != null) {
f = new FileDialog(form.getShell());
}
String file = f.open();
if (file == null) {
return treeData;
}
HL7Parse hl7Parse = new HL7Parse();
List<String> msgContentList = new ArrayList<String>();
List<Message> messageList = hl7Parse.doParse(file, "'\\u000b'", "'\\u001c'");
List<HL7TreeNode> nodeList = hl7Util.getHL7TreeNodes(messageList);
if (!nodeList.isEmpty()) {
HL7TreeNode hl7TreeNode = nodeList.get(0);
List<HL7FileNode> table = new ArrayList<HL7FileNode>();
if (hl7Connection != null) {
EList root = hl7Connection.getRoot();
root.clear();
if (hl7TreeNode != null) {
hl7Util.initNodeOrder(hl7TreeNode, orderMap);
hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap);
}
table.addAll(root);
} else {
if (hl7TreeNode != null) {
hl7Util.initNodeOrder(hl7TreeNode, orderMap);
hl7Util.tableLoader((Element) hl7TreeNode, "", table, hl7TreeNode.getDefaultValue(), orderMap);
}
}
List<String> schemaList = new ArrayList<String>();
for (HL7FileNode node : table) {
String columnName = node.getRelatedColumn();
if (columnName.contains(":")) {
columnName = columnName.substring(0, columnName.indexOf(":"));
}
if (!schemaList.contains(columnName) && !"".equals(columnName)) {
schemaList.add(columnName);
}
}
initXmlTreeData(schemaList, table, treeData);
}
return treeData;
}
use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method orderNode.
private void orderNode(HL7TreeNode node) {
// reset the order.
if (node != null) {
List<HL7TreeNode> firstSubChildren = node.getChildren();
HL7TreeNode foundNode = null;
for (HL7TreeNode childen : firstSubChildren) {
if (childen.isRepetable()) {
foundNode = childen;
sortOrder(foundNode, node);
break;
} else if (childen.isGroup()) {
foundNode = childen;
sortOrder(foundNode, node);
orderNode(childen);
} else {
orderNode(childen);
}
}
}
}
use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method addElement.
protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue, Map<String, HL7TreeNode> mapNodes) {
HL7TreeNode temp = mapNodes.get(newPath);
if (temp == null) {
// if node is not existing, create it.
//$NON-NLS-1$
String name = newPath.substring(newPath.lastIndexOf("/") + 1);
temp = new Element(name, defaultValue);
if (current == null) {
// root node
mapNodes.put(newPath, temp);
return temp;
}
mapNodes.put(newPath, temp);
//$NON-NLS-1$
String parentPath = newPath.substring(0, newPath.lastIndexOf("/"));
HL7TreeNode parentNode = mapNodes.get(parentPath);
if (parentNode != null) {
parentNode.addChild(temp);
} else {
ExceptionHandler.log("Error when parsing the HL7 data, parent not existing for:" + parentPath);
}
}
return temp;
}
Aggregations