use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.
the class AddTreeNodeButton method updateStatus.
@Override
protected void updateStatus(TreeSelection selection) {
if (selection.getFirstElement() instanceof FOXTreeNode) {
FOXTreeNode node = (FOXTreeNode) selection.getFirstElement();
if (node == null) {
getButton().setEnabled(false);
return;
}
if (node instanceof Attribute) {
getButton().setEnabled(false);
return;
}
if (node instanceof NameSpaceNode) {
getButton().setEnabled(false);
return;
}
getButton().setEnabled(true);
} else {
getButton().setEnabled(false);
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.
the class AddTreeNodeButton method updateStatus.
@Override
protected void updateStatus(TreeSelection selection) {
if (selection.getFirstElement() instanceof FOXTreeNode) {
FOXTreeNode node = (FOXTreeNode) selection.getFirstElement();
if (node == null) {
getButton().setEnabled(false);
return;
}
if (node instanceof Attribute) {
getButton().setEnabled(false);
return;
}
if (node instanceof NameSpaceNode) {
getButton().setEnabled(false);
return;
}
getButton().setEnabled(true);
} else {
getButton().setEnabled(false);
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.
the class MoveUpTreeNodeButton method updateStatus.
/*
* (non-Javadoc)
*
* @see org.talend.designer.fileoutputJSON.ui.footer.AbstractTreeNodeButton#updateButtonStatus()
*/
@Override
protected void updateStatus(TreeSelection selection) {
if (selection.isEmpty()) {
getButton().setEnabled(false);
return;
}
final TreePath[] paths = selection.getPaths();
boolean sameSegment = true;
for (int i = 0; i < paths.length - 1; i++) {
if (paths[i].getSegmentCount() != paths[i + 1].getSegmentCount()) {
sameSegment = false;
}
}
if (sameSegment) {
getButton().setEnabled(true);
} else {
getButton().setEnabled(false);
return;
}
// if same segment ,they have the same parent and parent must be an element
FOXTreeNode foxNode = (FOXTreeNode) selection.getFirstElement();
if (foxNode.getParent() instanceof Element) {
final Element parent = (Element) foxNode.getParent();
if (parent == null) {
getButton().setEnabled(false);
return;
}
final List<? extends FOXTreeNode> attrChildren = parent.getAttributeChildren();
final List<? extends FOXTreeNode> nameSpaceChildren = parent.getNameSpaceChildren();
final List<FOXTreeNode> elementChildren = parent.getElementChildren();
final Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
final Object next = iterator.next();
if (next instanceof Attribute) {
if (attrChildren.contains(next) && attrChildren.indexOf(next) == 0) {
getButton().setEnabled(false);
return;
}
} else if (next instanceof NameSpaceNode) {
if (nameSpaceChildren.contains(next) && nameSpaceChildren.indexOf(next) == 0) {
getButton().setEnabled(false);
return;
}
} else if (next instanceof Element) {
if (elementChildren.contains(next) && elementChildren.indexOf(next) == 0) {
getButton().setEnabled(false);
return;
}
}
}
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.
the class ImportTreeFromXml method prepareEmfTreeNode.
private void prepareEmfTreeNode(List<FOXTreeNode> list, TreeNode parent) {
if (list == null || list.isEmpty()) {
return;
}
String xPath = parent.getXpath();
TreeNode realParentNode = parent;
if (parent.isSubstitution() || parent.isChoice()) {
realParentNode = XmlMapUtil.getRealParentNode(parent);
if (realParentNode != null) {
xPath = realParentNode.getXpath();
}
}
for (FOXTreeNode foxNode : list) {
TreeNode createTreeNode = null;
if (input) {
createTreeNode = XmlmapFactory.eINSTANCE.createTreeNode();
} else {
createTreeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
}
String label = foxNode.getLabel();
createTreeNode.setName(label);
createTreeNode.setOptional(foxNode.isOptional());
if (foxNode instanceof Element) {
createTreeNode.setNodeType(NodeType.ELEMENT);
if (foxNode.isChoice()) {
createTreeNode.setChoice(foxNode.isChoice());
} else if (foxNode.isSubstitution()) {
createTreeNode.setSubstitution(foxNode.isSubstitution());
}
} else if (foxNode instanceof Attribute) {
createTreeNode.setNodeType(NodeType.ATTRIBUT);
} else if (foxNode instanceof NameSpaceNode) {
createTreeNode.setNodeType(NodeType.NAME_SPACE);
createTreeNode.setDefaultValue(foxNode.getDefaultValue());
if (createTreeNode.getName() == null || createTreeNode.getName().equals("")) {
createTreeNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
}
}
createTreeNode.setXpath(XmlMapUtil.getXPath(xPath, label, createTreeNode.getNodeType()));
if (foxNode.getDataType() != null && !"".equals(foxNode.getDataType())) {
if (foxNode.getDataType().equals("id_Date")) {
//$NON-NLS-1$
createTreeNode.setPattern("\"dd-MM-yyyy\"");
}
createTreeNode.setType(foxNode.getDataType());
} else {
createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
}
parent.getChildren().add(createTreeNode);
if (foxNode.getChildren() != null && !foxNode.getChildren().isEmpty()) {
prepareEmfTreeNode(foxNode.getChildren(), createTreeNode);
}
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.
the class ImportTreeFromRepository method isMappedChoiceSubsOutput.
private boolean isMappedChoiceSubsOutput(FOXTreeNode node, String pXpath) {
List<FOXTreeNode> children = node.getChildren();
List<FOXTreeNode> subsChoice = new ArrayList<FOXTreeNode>();
XMLFileNode found = null;
for (FOXTreeNode child : children) {
if (child.isSubstitution() || child.isChoice()) {
subsChoice.add(child);
} else {
String childXpath = "";
if (child instanceof Element) {
childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.ELEMENT);
} else if (child instanceof Attribute) {
childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.ATTRIBUT);
} else if (child instanceof NameSpaceNode) {
childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.NAME_SPACE);
}
found = findXmlFileNode(childXpath, root);
if (found == null) {
found = findXmlFileNode(childXpath, group);
}
if (found == null) {
found = findXmlFileNode(childXpath, loop);
}
if (found != null) {
break;
}
}
}
if (found != null) {
return true;
}
if (!subsChoice.isEmpty()) {
for (FOXTreeNode foxNode : subsChoice) {
boolean isChildMapped = isMappedChoiceSubsOutput(foxNode, pXpath);
if (isChildMapped) {
return true;
}
}
}
return found != null;
}
Aggregations