use of org.adempiere.webui.component.SimpleTreeModel in project adempiere by adempiere.
the class ADTabPanel method deleteNode.
private void deleteNode(int recordId) {
if (recordId <= 0)
return;
SimpleTreeModel model = (SimpleTreeModel) treePanel.getTree().getModel();
if (treePanel.getTree().getSelectedItem() != null) {
SimpleTreeNode treeNode = (SimpleTreeNode) treePanel.getTree().getSelectedItem().getValue();
MTreeNode data = (MTreeNode) treeNode.getData();
if (data.getNode_ID() == recordId) {
model.removeNode(treeNode);
return;
}
}
SimpleTreeNode treeNode = model.find(null, recordId);
if (treeNode != null) {
model.removeNode(treeNode);
}
}
use of org.adempiere.webui.component.SimpleTreeModel in project adempiere by adempiere.
the class WTreeMaintenance method action_treeAdd.
// propertyChange
/**
* Action: Add Node to Tree
* @param item item
*/
private void action_treeAdd(ListItem item) {
log.info("Item=" + item);
if (item != null) {
SimpleTreeModel model = (SimpleTreeModel) (TreeModel<?>) centerTree.getModel();
DefaultTreeNode stn = model.find(model.getRoot(), item.id);
if (stn != null) {
MTreeNode tNode = (MTreeNode) stn.getData();
tNode.setName(item.name);
tNode.setAllowsChildren(item.isSummary);
tNode.setImageIndicator(item.imageIndicator);
model.nodeUpdated(stn);
Treeitem ti = centerTree.renderItemByPath(model.getPath(stn));
ti.setTooltiptext(item.description);
} else {
stn = new DefaultTreeNode(new MTreeNode(item.id, 0, item.name, item.description, 0, item.isSummary, item.imageIndicator, false, null), new ArrayList<Object>());
model.addNode(stn);
}
// May cause Error if in tree
addNode(item);
}
}
use of org.adempiere.webui.component.SimpleTreeModel in project adempiere by adempiere.
the class WTreeBOM method action_loadBOM.
private void action_loadBOM() {
int M_Product_ID = getM_Product_ID();
if (M_Product_ID == 0)
return;
MProduct product = MProduct.get(getCtx(), M_Product_ID);
DefaultTreeNode parent = new DefaultTreeNode(productSummary(product, false), new ArrayList());
dataBOM.clear();
if (isImplosion()) {
try {
m_tree.setModel(null);
} catch (Exception e) {
}
if (m_tree.getTreecols() != null)
m_tree.getTreecols().detach();
if (m_tree.getTreefoot() != null)
m_tree.getTreefoot().detach();
if (m_tree.getTreechildren() != null)
m_tree.getTreechildren().detach();
for (MPPProductBOMLine bomline : MPPProductBOMLine.getByProduct(product)) {
parent.getChildren().add(parent(bomline));
}
Treecols treeCols = new Treecols();
m_tree.appendChild(treeCols);
Treecol treeCol = new Treecol();
treeCols.appendChild(treeCol);
SimpleTreeModel model = new SimpleTreeModel(parent);
m_tree.setPageSize(-1);
m_tree.setTreeitemRenderer(model);
m_tree.setModel(model);
} else {
try {
m_tree.setModel(null);
} catch (Exception e) {
}
if (m_tree.getTreecols() != null)
m_tree.getTreecols().detach();
if (m_tree.getTreefoot() != null)
m_tree.getTreefoot().detach();
if (m_tree.getTreechildren() != null)
m_tree.getTreechildren().detach();
for (MPPProductBOM bom : MPPProductBOM.getProductBOMs(product)) {
parent.getChildren().add(parent(bom));
}
Treecols treeCols = new Treecols();
m_tree.appendChild(treeCols);
Treecol treeCol = new Treecol();
treeCols.appendChild(treeCol);
SimpleTreeModel model = new SimpleTreeModel(parent);
m_tree.setPageSize(-1);
m_tree.setTreeitemRenderer(model);
m_tree.setModel(model);
}
m_tree.addEventListener(Events.ON_SELECTION, this);
loadTableBOM();
}
use of org.adempiere.webui.component.SimpleTreeModel in project adempiere by adempiere.
the class WCRPDetail method getTree.
private Tree getTree() {
Tree tree = new Tree();
List<String> nodes = model.getDataset().getColumnKeys();
DefaultTreeNode root = new DefaultTreeNode(getResource(resource.getValue()).getName(), new ArrayList());
for (String node : nodes) {
root.getChildren().add(new DefaultTreeNode(node, new ArrayList()));
}
Treecols treeCols = new Treecols();
tree.appendChild(treeCols);
Treecol treeCol = new Treecol();
treeCols.appendChild(treeCol);
SimpleTreeModel model = new SimpleTreeModel(root);
tree.setPageSize(-1);
tree.setTreeitemRenderer(model);
tree.setModel(model);
return tree;
}
Aggregations