use of org.talend.designer.xmlmap.ui.dialog.NameSpaceDialog in project tdi-studio-se by Talend.
the class FixValueAction method run.
@Override
public void run() {
if (selectedNode != null) {
NameSpaceDialog nsDialog = new NameSpaceDialog(null);
nsDialog.setCurrentNode(selectedNode);
nsDialog.setParentNode((TreeNode) selectedNode.eContainer());
int status = nsDialog.open();
if (status == nsDialog.OK) {
String defaultValue = nsDialog.getNSValue();
if (defaultValue != null) {
defaultValue = defaultValue.trim();
}
String prefix = nsDialog.getPrefix().trim();
selectedNode.setDefaultValue(defaultValue);
if (prefix == null || "".equals(prefix)) {
prefix = XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX;
}
selectedNode.setName(prefix);
XmlMapData externalEmfData = (XmlMapData) mapperManager.getExternalData();
XmlMapUtil.updateXPathAndExpression(externalEmfData, mapperManager.getMapperComponent().getExpressionManager(), selectedNode, prefix, XmlMapUtil.getXPathLength(selectedNode.getXpath()), true);
}
}
}
use of org.talend.designer.xmlmap.ui.dialog.NameSpaceDialog in project tdi-studio-se by Talend.
the class CreateNameSpaceAction method run.
@Override
public void run() {
String prefix = null;
String defaultValue = null;
NameSpaceDialog nsDialog = new NameSpaceDialog(null);
nsDialog.setParentNode(parent);
int status = nsDialog.open();
if (status == nsDialog.OK) {
defaultValue = nsDialog.getNSValue();
if (defaultValue != null) {
defaultValue = defaultValue.trim();
}
prefix = nsDialog.getPrefix().trim();
}
if (status == nsDialog.CANCEL) {
return;
}
TreeNode createdNode = null;
if (input) {
createdNode = XmlmapFactory.eINSTANCE.createTreeNode();
} else {
createdNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
}
createdNode.setName(prefix);
createdNode.setNodeType(NodeType.NAME_SPACE);
createdNode.setDefaultValue(defaultValue);
createdNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
String label = createdNode.getName();
if (prefix == null || "".equals(prefix)) {
label = XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX;
createdNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
}
String parentXpath = parent.getXpath();
if (parent.isChoice() || parent.isSubstitution()) {
TreeNode realPrant = XmlMapUtil.getRealParentNode(parent);
if (realPrant != null) {
parentXpath = realPrant.getXpath();
}
}
createdNode.setXpath(XmlMapUtil.getXPath(parentXpath, label, NodeType.NAME_SPACE));
final EList<TreeNode> children = parent.getChildren();
int index = 0;
for (int i = 0; i < children.size(); i++) {
final TreeNode treeNode = children.get(i);
if (treeNode.getNodeType() == NodeType.NAME_SPACE) {
if (i == children.size() - 1) {
index = children.size();
}
continue;
} else {
index = i;
break;
}
}
children.add(index, createdNode);
// children.add(createdNode);
// if (input) {
// mapperManager.inputTreeSchemaBeanListModified();
// } else {
// mapperManager.outputTreeSchemaBeanListModified();
// }
Object object = graphicViewer.getEditPartRegistry().get(createdNode);
if (object instanceof TreeNodeEditPart) {
graphicViewer.select((TreeNodeEditPart) object);
}
}
Aggregations