use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode 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.FOXTreeNode 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.FOXTreeNode 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.FOXTreeNode in project tdi-studio-se by Talend.
the class ImportTreeFromJSONAction method selectionChanged.
@Override
public void selectionChanged(IStructuredSelection selection) {
this.setEnabled(true);
FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
if (node != null) {
form.setSelectedText(node.getLabel());
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class JSONDisconnectAction method run.
public void run() {
FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
if (node == null) {
return;
}
node.setColumn(null);
jsonViewer.refresh(node);
jsonViewer.expandAll();
form.redrawLinkers();
form.updateConnection();
}
Aggregations