use of org.talend.componentdesigner.ui.composite.xmltree.TreeNodeData in project tdi-studio-se by Talend.
the class AbstractXMLConfigPage method initialize.
/*
* (non-Javadoc)
*
* @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractComponentPage#initialize()
*/
protected void initialize() {
availableXmlTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (availableXmlTree.getMenu() != null) {
availableXmlTree.getMenu().dispose();
}
final TreeItem[] treeItem = ((Tree) event.getSource()).getSelection();
Menu popMenu = new Menu(availableXmlTree);
MenuItem itemNew = new MenuItem(popMenu, SWT.CASCADE);
//$NON-NLS-1$
itemNew.setText(Messages.getString("AbstractXMLConfigPage.New"));
MenuItem itemDel = new MenuItem(popMenu, SWT.CASCADE);
//$NON-NLS-1$
itemDel.setText(Messages.getString("AbstractXMLConfigPage.Delete"));
itemDel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeNodeData currentNodeData = (TreeNodeData) treeItem[0].getParentItem().getData();
currentNodeData.getXMLNode().removeChild(((TreeNodeData) treeItem[0].getData()).getXMLNode());
treeItem[0].dispose();
}
});
final TreeNodeData treeNodeData = ((TreeNodeData) treeItem[0].getData());
if (treeNodeData.isHasChildTreeNode()) {
Menu subNewMenu = new Menu(itemNew);
itemNew.setMenu(subNewMenu);
Object[] subNodeNames = treeNodeData.getChildNodeNames();
for (Object nodeName : subNodeNames) {
final MenuItem nodeMenuItem = new MenuItem(subNewMenu, SWT.CASCADE);
final String itemName = (String) nodeName;
nodeMenuItem.setText(itemName);
nodeMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeItem newItem = new TreeItem(treeItem[0], 0);
newItem.setText(itemName);
TreeNodeData newNodeData = null;
newNodeData = new TreeNodeData();
Node parentNode = treeNodeData.getXMLNode();
newNodeData.setXMLNode(parentNode.appendChild(parentNode.getOwnerDocument().createElement(itemName)));
//$NON-NLS-1$
newNodeData.setTreePath(treeNodeData.getTreePath() + "/" + itemName);
newNodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(newNodeData.getTreePath()));
newItem.setData(newNodeData);
}
});
}
} else {
itemNew.setEnabled(false);
}
availableXmlTree.setMenu(popMenu);
if (nodeAttrCompsite != null) {
nodeAttrCompsite.dispose();
}
rebuildAttrComposite(treeNodeData);
setComponentMinSize(treeNodeData.getTreeNode().getLabel());
rightComposite.layout();
}
});
}
use of org.talend.componentdesigner.ui.composite.xmltree.TreeNodeData in project tdi-studio-se by Talend.
the class JavaXMLConfigWizardPage method fillImportItems.
/*
* (non-Javadoc)
*
* @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractXMLConfigPage#fillImportItems()
*/
protected void fillImportItems() {
for (int i = 0; i < availableXmlTree.getItems().length; i++) {
TreeItem item = availableXmlTree.getItem(i);
if (item.getText().equals(CODEGENERATION)) {
Node codeGenNode = ((TreeNodeData) item.getData()).getXMLNode();
TreeItem importsItem = new TreeItem(item, SWT.CASCADE);
importsItem.setText(IMPORTS);
Element importsEle = codeGenNode.getOwnerDocument().createElement(IMPORTS);
codeGenNode.appendChild(importsEle);
TreeNodeData importsData = new TreeNodeData();
importsData.setXMLNode(importsEle);
importsData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTSITEMPATH));
importsItem.setData(importsData);
List<Node> jarImportNodes = new ArrayList<Node>();
List<Node> pmImportNodes = new ArrayList<Node>();
for (ILibEntry libEntry : componentPref.getLibEntries()) {
TreeItem importItem = new TreeItem(importsItem, SWT.CASCADE);
importItem.setText(IMPORT);
Element importEle = importsEle.getOwnerDocument().createElement(IMPORT);
importsEle.appendChild(importEle);
importEle.setAttribute(NAME, libEntry.getNamePrefix());
importEle.setAttribute(MODULE, libEntry.getName());
//$NON-NLS-1$
importEle.setAttribute(REQUIRED, "true");
TreeNodeData nodeData = new TreeNodeData();
nodeData.putAttrValue(NAME, libEntry.getNamePrefix());
nodeData.putAttrValue(MODULE, libEntry.getName());
//$NON-NLS-1$
nodeData.putAttrValue(REQUIRED, "true");
nodeData.setXMLNode(importEle);
nodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTITEMPATH));
importItem.setData(nodeData);
if (libEntry instanceof JarLibEntry) {
jarImportNodes.add(importEle);
} else {
pmImportNodes.add(importEle);
}
}
this.componentPref.setJavaImportNodes(jarImportNodes.toArray(new Node[jarImportNodes.size()]));
}
}
}
use of org.talend.componentdesigner.ui.composite.xmltree.TreeNodeData in project tdi-studio-se by Talend.
the class PerlXMLConfigWizardPage method fillImportItems.
/*
* (non-Javadoc)
*
* @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractXMLConfigPage#fillImportItems()
*/
protected void fillImportItems() {
for (int i = 0; i < availableXmlTree.getItems().length; i++) {
TreeItem item = availableXmlTree.getItem(i);
if (item.getText().equals(CODEGENERATION)) {
Node codeGenNode = ((TreeNodeData) item.getData()).getXMLNode();
TreeItem importsItem = new TreeItem(item, SWT.CASCADE);
importsItem.setText(IMPORTS);
Element importsEle = codeGenNode.getOwnerDocument().createElement(IMPORTS);
codeGenNode.appendChild(importsEle);
TreeNodeData importsData = new TreeNodeData();
importsData.setXMLNode(importsEle);
importsData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTSITEMPATH));
importsItem.setData(importsData);
List<Node> jarImportNodes = new ArrayList<Node>();
List<Node> pmImportNodes = new ArrayList<Node>();
for (ILibEntry libEntry : componentPref.getLibEntries()) {
TreeItem importItem = new TreeItem(importsItem, SWT.CASCADE);
importItem.setText(IMPORT);
Element importEle = importsEle.getOwnerDocument().createElement(IMPORT);
importsEle.appendChild(importEle);
importEle.setAttribute(NAME, libEntry.getNamePrefix());
importEle.setAttribute(MODULE, libEntry.getName());
//$NON-NLS-1$
importEle.setAttribute(REQUIRED, "true");
TreeNodeData nodeData = new TreeNodeData();
nodeData.putAttrValue(NAME, libEntry.getNamePrefix());
nodeData.putAttrValue(MODULE, libEntry.getName());
//$NON-NLS-1$
nodeData.putAttrValue(REQUIRED, "true");
nodeData.setXMLNode(importEle);
nodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(IMPORTITEMPATH));
importItem.setData(nodeData);
if (libEntry instanceof JarLibEntry) {
jarImportNodes.add(importEle);
} else {
pmImportNodes.add(importEle);
}
}
this.componentPref.setPerlImportNodes(pmImportNodes.toArray(new Node[pmImportNodes.size()]));
}
}
}
Aggregations