use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class CreateHL7ElementAction method init.
public void init() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node == null) {
this.setEnabled(false);
return;
}
if (node instanceof Attribute) {
this.setEnabled(false);
return;
}
if (node instanceof NameSpaceNode) {
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 HL7FixValueAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
setFixValue(node);
}
use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method initXmlTreeData.
private void initXmlTreeData(List<String> schemaList, List<HL7FileNode> root, List<HL7TreeNode> treeData) {
Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
List<? extends IConnection> incomingConnections = new ArrayList<IConnection>();
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().clear();
incomingConnections = NodeUtil.getIncomingConnections(hl7ui.gethl7Manager().getHl7Component(), IConnectionCategory.FLOW);
}
}
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<MetadataTable> iMetadataTables = new ArrayList<MetadataTable>();
HL7TreeNode rootNode = null;
Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
Map<String, MetadataTable> schemaNameToOutputTable = new HashMap<String, MetadataTable>();
for (String schemaName : schemaList) {
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(schemaName)) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
break;
}
}
MetadataTable targetMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
targetMetadataTable.setId(factory.getNextId());
schemaNameToOutputTable.put(schemaName, targetMetadataTable);
targetMetadataTable.setLabel(schemaName);
iMetadataTables.add(targetMetadataTable);
}
HL7TreeNode current = null;
HL7TreeNode temp = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
for (int i = 0; i < root.size(); i++) {
HL7FileNode node = root.get(i);
String newPath = node.getFilePath();
defaultValue = node.getDefaultValue();
String columnName = node.getRelatedColumn();
// String type = node.getType();
String orderValue = String.valueOf(node.getOrder());
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = node.getOrder();
}
String rowName = columnName;
if (columnName != null && columnName.contains(":")) {
String[] names = columnName.split(":");
rowName = names[0];
columnName = names[1];
} else {
columnName = null;
}
temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
if (temp == null) {
// should not happen
continue;
}
// temp.setDataType(type);
if (rootNode == null) {
rootNode = temp;
}
if (node.getAttribute().equals("main")) {
temp.setMain(true);
}
current = temp;
currentPath = newPath;
if (haveOrder) {
temp.setOrder(nodeOrder);
}
if (rowName != null && rowName.length() > 0) {
temp.setRow(rowName);
}
if (columnName != null) {
IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
// group node can not get the metadata table
if (metadataTable == null) {
IMetadataTable metadataTableTemp = null;
for (IConnection connection : incomingConnections) {
metadataTableTemp = connection.getMetadataTable();
String connectionName = metadataTableTemp.getLabel();
if (connectionName == null) {
connectionName = connection.getUniqueName();
}
if (columnName.startsWith(connectionName)) {
break;
}
}
temp.setColumnName(columnName);
if (metadataTableTemp != null) {
temp.setColumn(metadataTableTemp.getColumn(columnName));
temp.setTable(metadataTableTemp);
}
} else {
temp.setColumnName(columnName);
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
//
if (!temp.isMain()) {
MetadataColumn newColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
newColumn.setLabel(columnName);
newColumn.setName(temp.getLabel());
newColumn.setLength(226);
newColumn.setTalendType("id_String");
schemaNameToOutputTable.get(rowName).getColumns().add(newColumn);
}
}
}
if (rootNode == null) {
rootNode = new Element("rootTag");
}
if (haveOrder) {
orderNode(rootNode);
}
if (rootNode != null) {
treeData.add(rootNode);
}
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().put(rootNode.getColumnLabel(), treeData);
}
} else if (form != null) {
for (HL7TreeNode hl7Node : treeData) {
form.getContents().put(rootNode.getColumnLabel(), hl7Node);
}
}
if (hl7ui != null) {
// execute the commands,initialize the propertiesView .
List<Command> commands = new ArrayList<Command>();
for (MetadataTable tableTemp : iMetadataTables) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(hl7ui.gethl7Manager().getHl7Component(), IHL7Constant.TABLE_SCHEMAS, tableTemp.getLabel(), ConvertionHelper.convert(tableTemp));
commands.add(hl7Cmd);
}
for (Command command : commands) {
command.execute();
}
}
}
use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method selectionChanged.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public void selectionChanged(IStructuredSelection selection) {
this.setEnabled(true);
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node != null && form != null) {
// hl7ui.setSelectedText(node.getLabel());
// Added by Marvin Wang on Sep. 11, 2012 for bug TDI-20702.
form.setSelectedText(node.getLabel());
}
}
use of org.talend.designer.hl7.ui.data.HL7TreeNode in project tdi-studio-se by Talend.
the class SetRepetableAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (!node.isRepetable()) {
if (node.isGroup()) {
node.setGroup(false);
}
node.setRepetable(true);
node.setMain(true);
upsetMainNode(node);
} else {
node.setRepetable(false);
}
xmlViewer.refresh();
}
Aggregations