use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element in project tdi-studio-se by Talend.
the class MoveDownTreeNodeButton method handleSelectionEvent.
/*
* (non-Javadoc)
*
* @see org.talend.designer.fileoutputJSON.ui.footer.AbstractTreeNodeButton#handleSelectionEvent()
*/
@Override
protected void handleSelectionEvent(TreeSelection selection) {
if (!selection.isEmpty()) {
FOXTreeNode foxNode = (FOXTreeNode) selection.getFirstElement();
if (!(foxNode.getParent() instanceof Element)) {
return;
}
final Element parentNode = (Element) foxNode.getParent();
final List<? extends FOXTreeNode> attrChildren = parentNode.getAttributeChildren();
final List<? extends FOXTreeNode> nameSpaceChildren = parentNode.getNameSpaceChildren();
final List<FOXTreeNode> elementChildren = parentNode.getElementChildren();
List<Integer> attrIndices = new ArrayList<Integer>();
List<Integer> nameSpaceIndices = new ArrayList<Integer>();
List<Integer> elementIndices = new ArrayList<Integer>();
final Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
final Object next = iterator.next();
if (next instanceof Attribute) {
if (attrChildren.contains(next)) {
attrIndices.add(attrChildren.indexOf(next));
}
} else if (next instanceof NameSpaceNode) {
if (nameSpaceChildren.contains(next)) {
nameSpaceIndices.add(nameSpaceChildren.indexOf(next));
}
} else if (next instanceof Element) {
if (elementChildren.contains(next)) {
elementIndices.add(elementChildren.indexOf(next));
}
}
}
Collections.sort(attrIndices);
Collections.sort(nameSpaceIndices);
Collections.sort(elementIndices);
swapElements(attrChildren, attrIndices);
swapElements(nameSpaceChildren, nameSpaceIndices);
swapElements(elementChildren, elementIndices);
treeViewer.refresh(parentNode);
treeViewer.expandAll();
form.redrawLinkers();
treeViewer.setSelection(selection);
form.updateConnection();
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element in project tdi-studio-se by Talend.
the class MoveUpTreeNodeButton method handleSelectionEvent.
/*
* (non-Javadoc)
*
* @see org.talend.designer.fileoutputJSON.ui.footer.AbstractTreeNodeButton#handleSelectionEvent()
*/
@Override
protected void handleSelectionEvent(TreeSelection selection) {
if (!selection.isEmpty()) {
FOXTreeNode foxNode = (FOXTreeNode) selection.getFirstElement();
if (!(foxNode.getParent() instanceof Element)) {
return;
}
final Element parentNode = (Element) foxNode.getParent();
final List<? extends FOXTreeNode> attrChildren = parentNode.getAttributeChildren();
final List<? extends FOXTreeNode> nameSpaceChildren = parentNode.getNameSpaceChildren();
final List<FOXTreeNode> elementChildren = parentNode.getElementChildren();
List<Integer> attrIndices = new ArrayList<Integer>();
List<Integer> nameSpaceIndices = new ArrayList<Integer>();
List<Integer> elementIndices = new ArrayList<Integer>();
final Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
final Object next = iterator.next();
if (next instanceof Attribute) {
if (attrChildren.contains(next)) {
attrIndices.add(attrChildren.indexOf(next));
}
} else if (next instanceof NameSpaceNode) {
if (nameSpaceChildren.contains(next)) {
nameSpaceIndices.add(nameSpaceChildren.indexOf(next));
}
} else if (next instanceof Element) {
if (elementChildren.contains(next)) {
elementIndices.add(elementChildren.indexOf(next));
}
}
}
Collections.sort(attrIndices);
Collections.sort(nameSpaceIndices);
Collections.sort(elementIndices);
swapElements(attrChildren, attrIndices);
swapElements(nameSpaceChildren, nameSpaceIndices);
swapElements(elementChildren, elementIndices);
treeViewer.refresh(parentNode);
treeViewer.expandAll();
form.redrawLinkers();
treeViewer.setSelection(selection);
form.updateConnection();
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element in project tdi-studio-se by Talend.
the class DeleteJSONNodeAction method run.
@Override
public void run() {
List<FOXTreeNode> objectToRemove = new ArrayList<FOXTreeNode>();
final Iterator iterator = this.getStructuredSelection().iterator();
while (iterator.hasNext()) {
FOXTreeNode selectedNode = (FOXTreeNode) iterator.next();
objectToRemove.add(selectedNode);
}
for (FOXTreeNode node : objectToRemove) {
if (node == null) {
return;
}
FOXTreeNode parent = node.getParent();
if (parent == null) {
return;
}
if (node instanceof Element) {
disconnectSubTree(node);
}
parent.removeChild(node);
if (node.isLoop() || node.isGroup()) {
form.updateStatus();
}
jsonViewer.refresh(parent);
}
jsonViewer.expandAll();
form.updateConnection();
form.redrawLinkers();
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element in project tdi-studio-se by Talend.
the class AbstractJSONFileStepForm method updateConnectionProperties.
protected void updateConnectionProperties(FOXTreeNode foxTreeNode) {
EList root = getConnection().getRoot();
EList loop = getConnection().getLoop();
EList group = getConnection().getGroup();
root.clear();
loop.clear();
group.clear();
if (foxTreeNode != null) {
initNodeOrder(foxTreeNode);
tableLoader((Element) foxTreeNode, "", root, foxTreeNode.getDefaultValue());
Element loopNode = (Element) TreeUtil.getLoopNode(foxTreeNode);
if (loopNode != null) {
String path = TreeUtil.getPath(loopNode);
tableLoader(loopNode, path.substring(0, path.lastIndexOf("/")), loop, loopNode.getDefaultValue());
}
Element groupNode = (Element) TreeUtil.getGroupNode(foxTreeNode);
if (groupNode != null) {
String path = TreeUtil.getPath(groupNode);
tableLoader(groupNode, path.substring(0, path.lastIndexOf("/")), group, groupNode.getDefaultValue());
}
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element in project tdi-studio-se by Talend.
the class CreateJSONElementAction method createChildNode.
private boolean createChildNode(FOXTreeNode node) {
if (node.getColumn() != null) {
if (!MessageDialog.openConfirm(jsonViewer.getControl().getShell(), "Warning", "Do you want to disconnect the existing linker and then add an sub element for the selected element " + node.getLabel() + " \"?")) {
return false;
}
node.setColumn(null);
}
String label = "";
while (!JSONUtil.validateLabelForJSON(label)) {
InputDialog dialog = new InputDialog(null, "Input element's label", "Input the new element's valid label", "", null);
int status = dialog.open();
if (status == InputDialog.OK) {
label = dialog.getValue().trim();
}
if (status == InputDialog.CANCEL) {
return false;
}
}
FOXTreeNode child = new Element(label);
// child.setRow(node.getRow());
node.addChild(child);
// fix for TDI-18802
if (node.getParent() == null && node.isLoop()) {
node.setLoop(false);
}
this.jsonViewer.refresh();
this.jsonViewer.expandAll();
return true;
}
Aggregations