示例#1
0
 /*
  * Update of user tree for ordered menu nodes (favorites, create new list)
  * favorites @param menuIDs List<Integer> ordered list of menuIDs to put in
  * the tree @param menuTree MTree the tree to be reordered @return true if
  * updated
  */
 private boolean updateUserTree(List<Integer> menuIDs, MTree menuTree) {
   CTreeNode root = menuTree.getRoot();
   if (root != null) {
     Enumeration<?> nodes = root.preorderEnumeration();
     while (nodes.hasMoreElements()) {
       CTreeNode nd = (CTreeNode) nodes.nextElement();
       if (!menuIDs.contains(nd.getNode_ID())) {
         MTreeNodeMM node = null;
         if ((node = MTreeNodeMM.get(menuTree, nd.getNode_ID())) != null) {
           if (!node.delete(true)) return false;
         }
       }
     }
   }
   int seq = 0;
   for (int id : menuIDs) {
     MTreeNodeMM node = null;
     if ((node = MTreeNodeMM.get(menuTree, id)) == null) {
       node = new MTreeNodeMM(menuTree, id);
     }
     node.setSeqNo(++seq);
     if (!node.save()) return false;
   }
   return true;
 }
示例#2
0
 /**
  * Get a menu tree representation based on a AD_Tree_ID
  *
  * @param AD_Tree_ID A tree based on AD_Menu
  * @return menu as array list
  */
 private ArrayList<CTreeNode> getMenuTree(int AD_Tree_ID, boolean edit) {
   MTree tree = new MTree(m_context, AD_Tree_ID, edit, true, true, null); // Language
   // set
   // in
   // WLogin
   // Trim tree
   CTreeNode root = tree.getRoot();
   Enumeration<?> en = root.preorderEnumeration();
   while (en.hasMoreElements()) {
     CTreeNode nd = (CTreeNode) en.nextElement();
     if (nd.isTask() || nd.isWorkbench() // || nd.isWorkFlow()
     // server
     ) {
       CTreeNode parent = (CTreeNode) nd.getParent();
       parent.remove(nd);
     }
   }
   tree.trimTree();
   en = root.preorderEnumeration();
   ArrayList<CTreeNode> retValue = new ArrayList<CTreeNode>();
   while (en.hasMoreElements()) {
     CTreeNode nd = (CTreeNode) en.nextElement();
     // Issue #420: removed menu entries for un-implemented forms
     if (nd.getAD_Form_ID() == 119 || nd.getAD_Form_ID() == 102
     //					|| nd.getAD_Workflow_ID() == 106
     //					|| nd.getAD_Workflow_ID() == 104
     //					// Review
     //					|| nd.getAD_Workflow_ID() == 112
     //					// Setup
     //					|| nd.getAD_Workflow_ID() == 113
     //					|| nd.getAD_Workflow_ID() == 110
     //					|| nd.getAD_Workflow_ID() == 111
     // || nd.getAD_Process_ID() == 205
     ) {
     } else retValue.add(nd);
   }
   return retValue;
 }