use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element in project tdi-studio-se by Talend.
the class DeleteNodeAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#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()) {
foxui.updateStatus();
}
xmlViewer.refresh(parent);
xmlViewer.expandToLevel(parent, 1);
}
foxui.redrawLinkers();
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element 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;
}
}
}
}
}
Aggregations