use of org.compiere.model.MTree in project adempiere by adempiere.
the class WebProjectDeploy method doIt.
// prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
org.compiere.cm.CacheHandler thisHandler = new org.compiere.cm.CacheHandler(org.compiere.cm.CacheHandler.convertJNPURLToCacheURL(getCtx().getProperty("java.naming.provider.url")), log, getCtx(), get_TrxName());
log.info("CM_WebProject_ID=" + p_CM_WebProject_ID);
m_project = new MWebProject(getCtx(), p_CM_WebProject_ID, get_TrxName());
if (m_project.get_ID() != p_CM_WebProject_ID)
throw new AdempiereUserError("@NotFound@ @CM_WebProject_ID@ " + p_CM_WebProject_ID);
// Deploy Media
MMedia[] media = MMedia.getMedia(m_project);
MMediaServer[] mserver = MMediaServer.getMediaServer(m_project);
for (int i = 0; i < mserver.length; i++) mserver[i].deploy(media);
// Stage
MCStage[] stages = MCStage.getStages(m_project);
for (int i = 0; i < stages.length; i++) m_map.put(new Integer(stages[i].getCM_CStage_ID()), stages[i]);
// Copy Stage Tree
MTree treeS = new MTree(getCtx(), m_project.getAD_TreeCMS_ID(), false, false, get_TrxName());
MTreeNode root = treeS.getRoot();
copyStage(root, "/");
// Delete Inactive Containers
MContainer[] containers = MContainer.getContainers(m_project);
for (int i = 0; i < containers.length; i++) {
MContainer container = containers[i];
if (!m_idList.contains(new Integer(container.getCM_Container_ID()))) {
String name = container.getName();
if (container.delete(true))
log.fine("Deleted: " + name);
else // e.g. was referenced
{
log.warning("Failed Delete: " + name);
addLog(0, null, null, "@Error@ @Delete@: " + name);
}
}
// Remove Container from cache
thisHandler.cleanContainer(container.get_ID());
}
// Delete Inactive
// Sync Stage & Container Tree
MTree_NodeCMS[] nodesCMS = MTree_NodeCMS.getTree(getCtx(), m_project.getAD_TreeCMS_ID(), get_TrxName());
MTree_NodeCMC[] nodesCMC = MTree_NodeCMC.getTree(getCtx(), m_project.getAD_TreeCMC_ID(), get_TrxName());
for (int s = 0; s < nodesCMS.length; s++) {
MTree_NodeCMS nodeCMS = nodesCMS[s];
int Node_ID = nodeCMS.getNode_ID();
for (int c = 0; c < nodesCMC.length; c++) {
MTree_NodeCMC nodeCMC = nodesCMC[c];
if (nodeCMC.getNode_ID() == Node_ID) {
//if (nodeCMS.getParent_ID()!=0)
nodeCMC.setParent_ID(nodeCMS.getParent_ID());
nodeCMC.setSeqNo(nodeCMS.getSeqNo());
nodeCMC.saveEx();
break;
}
}
}
// for all stage nodes
// Clean ContainerTree Cache
thisHandler.cleanContainerTree(p_CM_WebProject_ID);
return "@Copied@ @CM_Container_ID@ #" + m_idList.size();
}
use of org.compiere.model.MTree in project adempiere by adempiere.
the class VTreePanel method initTree.
/**
* Tree initialization.
* May be called several times
* @param AD_Tree_ID tree to load
* @return true if loaded ok
*/
public boolean initTree(int AD_Tree_ID, String whereClause) {
log.config("AD_Tree_ID=" + AD_Tree_ID);
//
m_AD_Tree_ID = AD_Tree_ID;
// Yamel Senih [ 9223372036854775807 ]
// Add Where Clause
// Get Tree
// MTree vTree = new MTree (Env.getCtx(), AD_Tree_ID, m_editable, true, null);
MTree vTree = new MTree(Env.getCtx(), AD_Tree_ID, m_editable, true, null);
// End Yamel Senih
m_root = vTree.getRoot();
// translate name of menu.
m_root.setName(Msg.getMsg(Env.getCtx(), vTree.getName()));
// m_root.setName(Msg.getMsg(Env.getCtx(), "Menu") ); // @Trifon; this is the hardcoded way.
log.config("root=" + m_root);
m_nodeTableName = vTree.getNodeTableName();
treeModel = new AdempiereTreeModel(m_root, true);
treeModel.setMTree(vTree);
tree.setModel(treeModel);
// Shortcut Bar
if (m_hasBar) {
for (JToolBar jt : toolbar) jt.removeAll();
toolbarMap = new HashMap<Integer, JToolBar>();
Enumeration<?> enTop = m_root.children();
JToolBar jt = null;
Map<JToolBar, String> titleMap = new HashMap<JToolBar, String>();
while (enTop.hasMoreElements()) {
MTreeNode ndTop = (MTreeNode) enTop.nextElement();
Enumeration<?> en = ndTop.preorderEnumeration();
boolean labelDrawn = false;
while (en.hasMoreElements()) {
MTreeNode nd = (MTreeNode) en.nextElement();
if (nd.isOnBar()) {
if (!labelDrawn) {
jt = new JToolBar(JToolBar.VERTICAL);
titleMap.put(jt, ndTop.toString().trim());
labelDrawn = true;
toolbarMap.put(ndTop.getNode_ID(), jt);
}
addToBar(nd, jt, false);
}
}
if (jt != null)
toolbar.add(jt);
jt = null;
}
//jbInit();
for (JToolBar jt2 : toolbar) {
jt2.setOpaque(false);
//jt2.setLayout(new GridBagLayout());
jt2.setFloatable(false);
jt2.setRollover(true);
jt2.setBorder(BorderFactory.createEmptyBorder());
JXTaskPane barPart = new JXTaskPane();
//Begin - [FR 1953769]
barPart.setUI(new AdempiereTaskPaneUI());
barPart.getContentPane().setBackground(AdempierePLAF.getFormBackground());
//End - [FR 1953769]
barPart.setAnimated(true);
barPart.setLayout(new BorderLayout());
barPart.add(jt2, BorderLayout.NORTH);
barPart.setTitle(titleMap.get(jt2));
bar.add(barPart);
//Begin - [FR 1953769]
bar.setBackground(AdempierePLAF.getFormBackground());
//End - [FR 1953769]
}
}
return true;
}
use of org.compiere.model.MTree in project adempiere by adempiere.
the class TreeMaintenance method doIt.
// prepare
/**
* Perform process.
* @return Message (clear text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
log.info("AD_Tree_ID=" + m_AD_Tree_ID);
if (m_AD_Tree_ID == 0)
throw new IllegalArgumentException("Tree_ID = 0");
MTree tree = new MTree(getCtx(), m_AD_Tree_ID, get_TrxName());
if (tree == null || tree.getAD_Tree_ID() == 0)
throw new IllegalArgumentException("No Tree -" + tree);
//
if (MTree.TREETYPE_BoM.equals(tree.getTreeType()))
return "BOM Trees not implemented";
return verifyTree(tree);
}
use of org.compiere.model.MTree in project adempiere by adempiere.
the class VTreeMaintenance method action_loadTree.
// actionPerformed
/**
* Action: Fill Tree with all nodes
*/
private void action_loadTree() {
KeyNamePair tree = (KeyNamePair) treeField.getSelectedItem();
log.info("Tree=" + tree);
if (tree.getKey() <= 0) {
centerList.setModel(new DefaultListModel());
return;
}
// Tree
m_tree = new MTree(Env.getCtx(), tree.getKey(), null);
cbAllNodes.setSelected(m_tree.isAllNodes());
bAddAll.setEnabled(!m_tree.isAllNodes());
bAdd.setEnabled(!m_tree.isAllNodes());
bDelete.setEnabled(!m_tree.isAllNodes());
bDeleteAll.setEnabled(!m_tree.isAllNodes());
//
// List
DefaultListModel model = new DefaultListModel();
ArrayList<ListItem> items = getTreeItemData();
for (ListItem item : items) model.addElement(item);
// List
log.config("#" + model.getSize());
centerList.setModel(model);
// Tree
centerTree.initTree(m_tree.getAD_Tree_ID());
}
use of org.compiere.model.MTree in project adempiere by adempiere.
the class WMenu method createPage.
// checkLogin
/**
* Create Menu Page
* @param request request
* @param wsc context
* @param AD_Role_ID role
* @return document
*/
private WebDoc createPage(HttpServletRequest request, WebSessionCtx wsc, int AD_Role_ID, int AD_User_ID, int AD_Client_ID, int AD_Org_ID) {
// Document
//Modified by Rob Klein 4/29/07
//String windowTitle = Msg.getMsg(wsc.ctx, "Menu");
String windowTitle = "Menu";
WebDoc doc = WebDoc.create(windowTitle);
head head = doc.getHead();
// Target
head.addElement(new base().setTarget(WebEnv.TARGET_WINDOW));
// Specific Menu Script/Stylesheet
head.addElement(new link(WebEnv.getBaseDirectory("/css/menu.css"), link.REL_STYLESHEET, link.TYPE_CSS));
head.addElement(new script((Element) null, WebEnv.getBaseDirectory("/js/menu.js")));
head.addElement(new script((Element) null, WebEnv.getBaseDirectory("/js/window.js")));
//Modified by Rob Klein 4/29/07
//head.addElement(new script((Element)null, WebEnv.getBaseDirectory("/js/mktree.js")));
//head.addElement(new link(WebEnv.getBaseDirectory("/css/mktree.css"), link.REL_STYLESHEET, link.TYPE_CSS));
// Scripts
String statusMessage = Msg.getMsg(wsc.ctx, "SelectMenuItem");
String scriptTxt = "top.document.title='" + windowTitle + " - " + wsc.loginInfo + "'; " + "var defaultStatus='" + statusMessage + "';";
//Rob 12-16-2006 head.addElement(new script(scriptTxt));
// Body
body body = doc.getBody();
body.setTitle(statusMessage);
// Clear Window Frame
//Rob 12-16-2006 body.addElement(WebUtil.getClearFrame(WebEnv.TARGET_WINDOW));
// Header
table table = doc.getTable();
doc.setClasses("menuTable", "menuHeader");
//Rob 12-16-2006 doc.getTopLeft().addElement(new cite(wsc.loginInfo));
input txtSearch = new input(input.TYPE_TEXT, "txtSearch", "");
txtSearch.setOnKeyDown("searchMenu('main',this.value,event,'" + WebEnv.TARGET_WINDOW + "')");
doc.getTopLeft().addElement("Find: ");
doc.getTopLeft().addElement(txtSearch);
// Load Menu Structure ----------------------
int AD_Tree_ID = DB.getSQLValue(null, "SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)" + "FROM AD_ClientInfo ci" + " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) " + "WHERE AD_Role_ID=?", AD_Role_ID);
if (AD_Tree_ID <= 0)
// Menu
AD_Tree_ID = 10;
log.fine("doPost - AD_Tree_ID=" + AD_Tree_ID + " - " + Env.getAD_Language(wsc.ctx));
// Language set in WLogin
MTree tree = new MTree(wsc.ctx, AD_Tree_ID, false, false, null);
// Trim tree
MTreeNode root = tree.getRoot();
Enumeration en = root.preorderEnumeration();
/*while (en.hasMoreElements())
{
MTreeNode nd = (MTreeNode)en.nextElement();
if (nd.isTask()
|| nd.isWorkbench()
|| nd.isWorkFlow()
|| nd.getNode_ID() == 383 // Reset Cache - kills the server
)
{
MTreeNode parent = (MTreeNode)nd.getParent();
parent.remove(nd);
}
}*/
tree.trimTree();
// Print tree
StringBuffer buf = new StringBuffer();
StringBuffer buffav = new StringBuffer();
en = root.preorderEnumeration();
int oldLevel = 0;
while (en.hasMoreElements()) {
MTreeNode nd = (MTreeNode) en.nextElement();
// Level
// 0 == root
int level = nd.getLevel();
if (level == 0)
continue;
//
while (oldLevel < level) {
if (level == 1)
// start first level
buf.append("<ul class=\"mktree\" id=\"main\">\n");
else
// start next level
buf.append("<ul style=\"display:none\">\n");
oldLevel++;
}
while (oldLevel > level) {
oldLevel--;
if (oldLevel == 1)
// finish last level
buf.append("</ul>\n");
else
// finish next level
buf.append("</ul></li>\n");
}
// Print Node
buf.append(printNode(nd, wsc.ctx));
//Modified by Rob Klein 4/29/07
if (nd.isOnBar())
buffav.append(printNode(nd, wsc.ctx));
}
// Final
while (oldLevel > 0) {
oldLevel--;
if (oldLevel == 1)
// finish last level
buf.append("</ul>\n");
else
// finish next level
buf.append("</ul></li>\n");
}
//Modified by Rob Klein 4/29/07
// Set Favorites
buf.append("<ul><li class=\"menuSummary\" id=\"218\" onClick=\"changeMenu(event);\">Favorites<ul style=\"display:none\">\n");
buf.append(buffav);
buf.append("</ul></li></ul>\n");
td td = new td().setColSpan(2).setNoWrap(true);
td.setClass("menuCenter");
td.addElement(buf.toString());
table.addElement(new tr().addElement(td));
// Expand/Collapse Info
td = new td().setColSpan(2);
td.setClass("menuFooter");
// Modified by Rob Klein 4/29/07
/**td.addElement(new a("javascript:expandTree('main');", "Expand Menu"));
td.addElement(" | ");
td.addElement( new a("javascript:collapseTree('main');", "Contract Menu"));
table.addElement(new tr().addElement(td));
**/
// Exit Info
td = new td().setColSpan(2);
td.setClass("menuFooter");
String url = request.getRequestURI() + "?Exit=true";
td.addElement(new a(url, Msg.getMsg(wsc.ctx, "Exit")));
table.addElement(new tr().addElement(td));
// System.out.println(doc);
return doc;
}
Aggregations