use of org.compiere.model.MTreeNode 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.MTreeNode in project adempiere by adempiere.
the class MReportTree method getChildIDs.
// getWhereClause
/**
* Get Child IDs
* @param ID start node
* @return array if IDs
*/
public Integer[] getChildIDs(int ID) {
log.fine("(" + m_ElementType + ") ID=" + ID);
ArrayList<Integer> list = new ArrayList<Integer>();
//
MTreeNode node = m_tree.getRoot().findNode(ID);
log.finest("Root=" + node);
//
if (node != null && node.isSummary()) {
Enumeration en = node.preorderEnumeration();
while (en.hasMoreElements()) {
MTreeNode nn = (MTreeNode) en.nextElement();
if (!nn.isSummary()) {
list.add(new Integer(nn.getNode_ID()));
log.finest("- " + nn);
} else
log.finest("- skipped parent (" + nn + ")");
}
} else
// not found or not summary
list.add(new Integer(ID));
//
Integer[] retValue = new Integer[list.size()];
list.toArray(retValue);
return retValue;
}
use of org.compiere.model.MTreeNode 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.MTreeNode in project adempiere by adempiere.
the class VTreePanel method getParentToolBar.
// barAdd
/**
* Returns the top level parent JToolBar for the given MTreenode. If the parent is not on
* the CPanel yet a new one is created and added.
* @param nd
* @return top level parent JToolBar for the given MTreenode
*/
private JToolBar getParentToolBar(MTreeNode nd) {
int topParentId = getTopParentId(nd);
JToolBar parent = toolbarMap.get(topParentId);
if (parent == null) {
Enumeration<?> enTop = m_root.children();
while (enTop.hasMoreElements()) {
MTreeNode ndTop = (MTreeNode) enTop.nextElement();
if (ndTop.getNode_ID() == topParentId) {
log.fine("add new category: " + ndTop);
parent = new JToolBar(JToolBar.VERTICAL);
toolbarMap.put(ndTop.getNode_ID(), parent);
toolbar.add(parent);
parent.setOpaque(false);
parent.setFloatable(false);
parent.setRollover(true);
parent.setBorder(BorderFactory.createEmptyBorder());
JXTaskPane barPart = new JXTaskPane();
//Begin - [FR 1953769]
barPart.setUI(new AdempiereTaskPaneUI());
barPart.getContentPane().setBackground(AdempierePLAF.getFormBackground());
//End - [FR 1953769]
barPart.setTitle(ndTop.toString().trim());
barPart.setAnimated(true);
barPart.setLayout(new BorderLayout());
barPart.add(parent, BorderLayout.NORTH);
bar.add(barPart);
return parent;
}
}
} else {
log.fine("parent found: " + parent);
}
return parent;
}
use of org.compiere.model.MTreeNode in project adempiere by adempiere.
the class VTreeCellRenderer method getTreeCellRendererComponent.
// VTreeCellRenderer
/**
* Get Tree Cell Renderer Component.
* Sets Icon, Name, Description for leaves
* @param tree tree
* @param value value
* @param Selected selected
* @param expanded expanded
* @param leaf leaf
* @param row row
* @param HasFocus focus
* @return renderer
*/
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean Selected, boolean expanded, boolean leaf, int row, boolean HasFocus) {
VTreeCellRenderer c = (VTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, Selected, expanded, leaf, row, HasFocus);
if (!leaf)
return c;
// We have a leaf
MTreeNode nd = (MTreeNode) value;
Icon icon = nd.getIcon();
if (icon != null)
c.setIcon(icon);
c.setText(nd.getName());
c.setToolTipText(nd.getDescription());
if (!Selected)
c.setForeground(nd.getColor());
return c;
}
Aggregations