use of org.talend.metadata.managment.ui.dialog.RootNodeSelectDialog in project tdi-studio-se by Talend.
the class ImportTreeFromXMLAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
List<FOXTreeNode> newInput = new ArrayList<FOXTreeNode>();
String filePath = getFilePath();
if (filePath == null) {
return;
}
boolean changed = true;
try {
if (XmlUtil.isXSDFile(filePath)) {
XSDSchema xsdSchema = TreeUtil.getXSDSchema(filePath);
List<ATreeNode> list = new XSDPopulationUtil2().getAllRootNodes(xsdSchema);
if (list.size() > 1) {
RootNodeSelectDialog dialog = new RootNodeSelectDialog(xmlViewer.getControl().getShell(), list);
if (dialog.open() == IDialogConstants.OK_ID) {
ATreeNode selectedNode = dialog.getSelectedNode();
newInput = TreeUtil.getFoxTreeNodesByRootNode(xsdSchema, selectedNode);
changed = true;
} else {
changed = false;
}
} else {
newInput = TreeUtil.getFoxTreeNodesByRootNode(xsdSchema, list.get(0));
changed = true;
}
} else {
newInput = treeNodeAdapt(filePath);
changed = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (newInput.size() == 0) {
return;
}
if (changed) {
// updateNode
for (FOXTreeNode node : newInput) {
foxui.updateNode(node, getSelectedSchema());
}
List<FOXTreeNode> treeData = foxui.getFoxManager().getTreeData(getSelectedSchema());
treeData.clear();
treeData.addAll(newInput);
xmlViewer.setInput(foxui.getFoxManager().getTreeData());
// TreeUtil.guessAndSetLoopNode((FOXTreeNode) xmlViewer.getTree().getItem(0).getData());
xmlViewer.refresh();
xmlViewer.expandToLevel(3);
foxui.updateStatus();
foxui.redrawLinkers();
}
}
Aggregations