use of org.zkoss.zul.DefaultTreeNode in project adempiere by adempiere.
the class WTreeMaintenance method action_treeDelete.
// action_treeAdd
/**
* Action: Delete Node from Tree
* @param item item
*/
private void action_treeDelete(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)
model.removeNode(stn);
//
deleteNode(item);
}
}
use of org.zkoss.zul.DefaultTreeNode in project adempiere by adempiere.
the class ADTreeOnDropListener method moveNode.
/**
* Move TreeNode
* @param movingNode The node to be moved
* @param toNode The target node
*/
private void moveNode(DefaultTreeNode movingNode, DefaultTreeNode toNode) {
log.info(movingNode.toString() + " to " + toNode.toString());
if (movingNode == toNode)
return;
MTreeNode toMNode = (MTreeNode) toNode.getData();
DefaultTreeNode newParent;
int index;
if (// drop on a child node
!toMNode.isSummary()) {
moveNode(movingNode, toNode, false);
} else // drop on a summary node
{
//prompt user to select insert after or drop into the summary node
int[] path = treeModel.getPath(toNode);
Treeitem toItem = tree.renderItemByPath(path);
tree.setSelectedItem(toItem);
Events.sendEvent(tree, new Event(Events.ON_SELECT, tree));
MenuListener listener = new MenuListener(movingNode, toNode);
//TODO: translation
Menupopup popup = new Menupopup();
Menuitem menuItem = new Menuitem("Insert After");
menuItem.setValue("InsertAfter");
menuItem.setParent(popup);
menuItem.addEventListener(Events.ON_CLICK, listener);
menuItem = new Menuitem("Move Into");
menuItem.setValue("MoveInto");
menuItem.setParent(popup);
menuItem.addEventListener(Events.ON_CLICK, listener);
popup.setPage(tree.getPage());
popup.open(toItem.getTreerow());
}
}
use of org.zkoss.zul.DefaultTreeNode 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;
}
use of org.zkoss.zul.DefaultTreeNode 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.zkoss.zul.DefaultTreeNode in project adempiere by adempiere.
the class WTreeBOM method parent.
public DefaultTreeNode parent(MPPProductBOMLine bomline) {
MProduct M_Product = MProduct.get(getCtx(), bomline.getM_Product_ID());
MPPProductBOM bomproduct = new MPPProductBOM(getCtx(), bomline.getPP_Product_BOM_ID(), null);
DefaultTreeNode parent = new DefaultTreeNode(productSummary(M_Product, false), new ArrayList());
Vector<Object> line = new Vector<Object>(17);
// 0 Select
line.add(new Boolean(false));
// 1 IsActive
line.add(new Boolean(true));
// 2 Line
line.add(new Integer(bomline.getLine()));
// 3 ValidDrom
line.add((Timestamp) bomline.getValidFrom());
// 4 ValidTo
line.add((Timestamp) bomline.getValidTo());
KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(), M_Product.getName());
// 5 M_Product_ID
line.add(pp);
KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(), bomline.getC_UOM().getUOMSymbol());
// 6 C_UOM_ID
line.add(uom);
// 7 IsQtyPorcentage
line.add(new Boolean(bomline.isQtyPercentage()));
// 8 BatchPercent
line.add((BigDecimal) bomline.getQtyBatch());
// 9 QtyBOM
line.add((BigDecimal) ((bomline.getQtyBOM() != null) ? bomline.getQtyBOM() : new BigDecimal(0)));
// 10 IsCritical
line.add(new Boolean(bomline.isCritical()));
// 11 LTOffSet
line.add((Integer) bomline.getLeadTimeOffset());
// 12 Assay
line.add((BigDecimal) bomline.getAssay());
// 13 Scrap
line.add((BigDecimal) (bomline.getScrap()));
// 14 IssueMethod
line.add((String) bomline.getIssueMethod());
// 15 BackflushGroup
line.add((String) bomline.getBackflushGroup());
// 16 Forecast
line.add((BigDecimal) bomline.getForecast());
dataBOM.add(line);
for (MPPProductBOM bom : MPPProductBOM.getProductBOMs((MProduct) bomproduct.getM_Product())) {
MProduct component = MProduct.get(getCtx(), bom.getM_Product_ID());
return component(component);
}
return parent;
}
Aggregations