IDEMPIERE-2911 NF3.0 Tree On Any Table not working correctly in subtab
This commit is contained in:
parent
bce0ae0611
commit
b32038f30b
|
@ -0,0 +1,51 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- IDEMPIERE-2911
|
||||
-- Dec 28, 2018, 10:15:03 PM CET
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,AD_Val_Rule_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Reference_Value_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (213823,0,'Parent Column','The link column on the parent tab.',288,100,'Parent_Column_ID',22,'N','N','N','N','N',0,'N',18,251,0,0,'Y',TO_DATE('2018-12-28 22:15:03','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-12-28 22:15:03','YYYY-MM-DD HH24:MI:SS'),100,53874,'Y','N','D','N','N','N','Y','6ba6d93a-99c2-4b97-b8eb-df3739282a99','Y',0,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:15:05 PM CET
|
||||
UPDATE AD_Column SET FKConstraintName='ParentColumn_ADTree', FKConstraintType='N',Updated=TO_DATE('2018-12-28 22:15:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213823
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:15:05 PM CET
|
||||
ALTER TABLE AD_Tree ADD Parent_Column_ID NUMBER(10) DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:15:05 PM CET
|
||||
ALTER TABLE AD_Tree ADD CONSTRAINT ParentColumn_ADTree FOREIGN KEY (Parent_Column_ID) REFERENCES ad_column(ad_column_id) DEFERRABLE INITIALLY DEFERRED
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:02 PM CET
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (205899,'Parent Column','The link column on the parent tab.',243,213823,'Y',22,140,'N','N','N','N',0,0,'Y',TO_DATE('2018-12-28 22:16:01','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-12-28 22:16:01','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','37ab9f61-295a-4c3a-9fc0-e88e99e50e61','Y',130,2)
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205899
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5228
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12421
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204379
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8371
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:17:22 PM CET
|
||||
UPDATE AD_Field SET DisplayLogic='@TreeType@=''TL''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-12-28 22:17:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205899
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201812282333_IDEMPIERE-2911.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
-- IDEMPIERE-2911
|
||||
-- Dec 28, 2018, 10:15:03 PM CET
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,AD_Val_Rule_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Reference_Value_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (213823,0,'Parent Column','The link column on the parent tab.',288,100,'Parent_Column_ID',22,'N','N','N','N','N',0,'N',18,251,0,0,'Y',TO_TIMESTAMP('2018-12-28 22:15:03','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-12-28 22:15:03','YYYY-MM-DD HH24:MI:SS'),100,53874,'Y','N','D','N','N','N','Y','6ba6d93a-99c2-4b97-b8eb-df3739282a99','Y',0,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:15:05 PM CET
|
||||
UPDATE AD_Column SET FKConstraintName='ParentColumn_ADTree', FKConstraintType='N',Updated=TO_TIMESTAMP('2018-12-28 22:15:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213823
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:15:05 PM CET
|
||||
ALTER TABLE AD_Tree ADD COLUMN Parent_Column_ID NUMERIC(10) DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:15:05 PM CET
|
||||
ALTER TABLE AD_Tree ADD CONSTRAINT ParentColumn_ADTree FOREIGN KEY (Parent_Column_ID) REFERENCES ad_column(ad_column_id) DEFERRABLE INITIALLY DEFERRED
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:02 PM CET
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (205899,'Parent Column','The link column on the parent tab.',243,213823,'Y',22,140,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2018-12-28 22:16:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-12-28 22:16:01','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','37ab9f61-295a-4c3a-9fc0-e88e99e50e61','Y',130,2)
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205899
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5228
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12421
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204379
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:16:56 PM CET
|
||||
UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-12-28 22:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8371
|
||||
;
|
||||
|
||||
-- Dec 28, 2018, 10:17:22 PM CET
|
||||
UPDATE AD_Field SET DisplayLogic='@TreeType@=''TL''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-12-28 22:17:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205899
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201812282333_IDEMPIERE-2911.sql') FROM dual
|
||||
;
|
||||
|
|
@ -215,6 +215,21 @@ public interface I_AD_Tree
|
|||
*/
|
||||
public String getName();
|
||||
|
||||
/** Column name Parent_Column_ID */
|
||||
public static final String COLUMNNAME_Parent_Column_ID = "Parent_Column_ID";
|
||||
|
||||
/** Set Parent Column.
|
||||
* The link column on the parent tab.
|
||||
*/
|
||||
public void setParent_Column_ID (int Parent_Column_ID);
|
||||
|
||||
/** Get Parent Column.
|
||||
* The link column on the parent tab.
|
||||
*/
|
||||
public int getParent_Column_ID();
|
||||
|
||||
public org.compiere.model.I_AD_Column getParent_Column() throws RuntimeException;
|
||||
|
||||
/** Column name Processing */
|
||||
public static final String COLUMNNAME_Processing = "Processing";
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.compiere.util.CLogMgt;
|
|||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* Builds Tree.
|
||||
|
@ -48,7 +49,7 @@ public class MTree extends MTree_Base
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6412057411585787707L;
|
||||
private static final long serialVersionUID = -212066085945645584L;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
|
@ -74,11 +75,23 @@ public class MTree extends MTree_Base
|
|||
public MTree (Properties ctx, int AD_Tree_ID,
|
||||
boolean editable, boolean clientTree, String trxName)
|
||||
{
|
||||
this (ctx, AD_Tree_ID, editable, clientTree, false, trxName);
|
||||
this (ctx, AD_Tree_ID, editable, clientTree, false, trxName, null, 0);
|
||||
} // MTree
|
||||
|
||||
public MTree (Properties ctx, int AD_Tree_ID,
|
||||
boolean editable, boolean clientTree, String trxName, String linkColName, int linkID)
|
||||
{
|
||||
this (ctx, AD_Tree_ID, editable, clientTree, false, trxName, linkColName, linkID);
|
||||
} // MTree
|
||||
|
||||
public MTree (Properties ctx, int AD_Tree_ID,
|
||||
boolean editable, boolean clientTree, boolean allNodes, String trxName)
|
||||
{
|
||||
this (ctx, AD_Tree_ID, editable, clientTree, allNodes, trxName, null, 0);
|
||||
} // MTree
|
||||
|
||||
public MTree (Properties ctx, int AD_Tree_ID,
|
||||
boolean editable, boolean clientTree, boolean allNodes, String trxName, String linkColName, int linkID)
|
||||
{
|
||||
this (ctx, AD_Tree_ID, trxName);
|
||||
m_editable = editable;
|
||||
|
@ -93,7 +106,7 @@ public class MTree extends MTree_Base
|
|||
+ ", Editable=" + editable
|
||||
+ ", OnClient=" + clientTree);
|
||||
//
|
||||
loadNodes(AD_User_ID);
|
||||
loadNodes(AD_User_ID, linkColName, linkID);
|
||||
} // MTree
|
||||
|
||||
/** Is Tree editable */
|
||||
|
@ -170,7 +183,7 @@ public class MTree extends MTree_Base
|
|||
String query = "SELECT tr.AD_Tree_ID "
|
||||
+ "FROM AD_Tree tr "
|
||||
+ "JOIN AD_Table t ON (tr.AD_Table_ID=t.AD_Table_ID) "
|
||||
+ "WHERE tr.AD_Client_ID=? AND tr.TreeType=? AND tr.IsActive='Y' AND tr.IsAllNodes='Y' AND t.TableName = ? "
|
||||
+ "WHERE tr.AD_Client_ID=? AND tr.TreeType=? AND tr.IsActive='Y' AND t.TableName = ? "
|
||||
+ "ORDER BY tr.AD_Tree_ID";
|
||||
int treeID = DB.getSQLValueEx(null, query, Env.getAD_Client_ID(Env.getCtx()), TREETYPE_CustomTable, tableName);
|
||||
|
||||
|
@ -217,9 +230,11 @@ public class MTree extends MTree_Base
|
|||
|
||||
/*************************************************************************
|
||||
* Load Nodes and Bar
|
||||
* @param AD_User_ID user for tree bar
|
||||
* @param AD_User_ID user for tree bar
|
||||
* @param linkColName
|
||||
* @param linkID
|
||||
*/
|
||||
private void loadNodes (int AD_User_ID)
|
||||
private void loadNodes (int AD_User_ID, String linkColName, int linkID)
|
||||
{
|
||||
// SQL for TreeNodes
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
@ -252,6 +267,8 @@ public class MTree extends MTree_Base
|
|||
+ "WHERE tn.AD_Tree_ID=?"); // #2
|
||||
if (!m_editable)
|
||||
sql.append(" AND tn.IsActive='Y'");
|
||||
if (!Util.isEmpty(linkColName))
|
||||
sql.append(" AND st.").append(linkColName).append("=").append(linkID);
|
||||
sql.append(" ORDER BY COALESCE(tn.Parent_ID, -1), tn.SeqNo");
|
||||
//do not check access if allNodes
|
||||
if (AD_User_ID != -1)
|
||||
|
|
|
@ -345,6 +345,11 @@ public class MTree_Base extends X_AD_Tree
|
|||
if (!isActive() || !isAllNodes())
|
||||
setIsDefault(false);
|
||||
|
||||
if (! TREETYPE_CustomTable.equals(getTreeType())) {
|
||||
setAD_Table_ID(-1);
|
||||
setParent_Column_ID(-1);
|
||||
}
|
||||
|
||||
String tableName = getSourceTableName(true);
|
||||
MTable table = MTable.get(getCtx(), tableName);
|
||||
if (table.getColumnIndex("IsSummary") < 0) {
|
||||
|
|
|
@ -67,6 +67,7 @@ import org.compiere.util.Msg;
|
|||
import org.compiere.util.SecureEngine;
|
||||
import org.compiere.util.Trace;
|
||||
import org.compiere.util.Trx;
|
||||
import org.compiere.util.Util;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
import org.osgi.service.event.Event;
|
||||
import org.w3c.dom.Document;
|
||||
|
@ -108,7 +109,7 @@ public abstract class PO
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6777678451696979575L;
|
||||
private static final long serialVersionUID = -1743619574547406959L;
|
||||
|
||||
public static final String LOCAL_TRX_PREFIX = "POSave";
|
||||
|
||||
|
@ -4013,7 +4014,14 @@ public abstract class PO
|
|||
if (I_C_ElementValue.Table_Name.equals(sourceTableName)) {
|
||||
newParentID = retrieveIdOfElementValue(value, getAD_Client_ID(), ((I_C_ElementValue)this).getC_Element().getC_Element_ID(), get_TrxName());
|
||||
} else {
|
||||
newParentID = retrieveIdOfParentValue(value, sourceTableName, getAD_Client_ID(), get_TrxName());
|
||||
int linkColId = tree.getParent_Column_ID();
|
||||
String linkColName = null;
|
||||
int linkID = 0;
|
||||
if (linkColId > 0) {
|
||||
linkColName = MColumn.getColumnName(Env.getCtx(), linkColId);
|
||||
linkID = (Integer)this.get_Value(linkColName);
|
||||
}
|
||||
newParentID = retrieveIdOfParentValue(value, sourceTableName, linkColName, linkID, getAD_Client_ID(), get_TrxName());
|
||||
}
|
||||
int seqNo = DB.getSQLValueEx(get_TrxName(), selMinSeqNo, newParentID, tree.getAD_Tree_ID(), value);
|
||||
if (seqNo == -1)
|
||||
|
@ -4040,9 +4048,17 @@ public abstract class PO
|
|||
}
|
||||
|
||||
/** Returns the summary node with the corresponding value */
|
||||
public static int retrieveIdOfParentValue(String value, String tableName, int clientID, String trxName)
|
||||
public static int retrieveIdOfParentValue(String value, String tableName, int clientID, String trxName) {
|
||||
return retrieveIdOfParentValue(value, tableName, null, 0, clientID, trxName);
|
||||
}
|
||||
|
||||
public static int retrieveIdOfParentValue(String value, String tableName, String linkCol, int linkID, int clientID, String trxName)
|
||||
{
|
||||
String sql = "SELECT " + tableName + "_ID FROM " + tableName + " WHERE IsSummary='Y' AND AD_Client_ID=? AND Value=?";
|
||||
String sql = "SELECT " + tableName + "_ID FROM " + tableName + " WHERE IsSummary='Y'";
|
||||
if (!Util.isEmpty(linkCol)) {
|
||||
sql = sql + " AND " + linkCol + "=" + linkID;
|
||||
}
|
||||
sql = sql + " AND AD_Client_ID=? AND Value=?";
|
||||
int pos = value.length()-1;
|
||||
while (pos > 0) {
|
||||
String testParentValue = value.substring(0, pos);
|
||||
|
|
|
@ -30,7 +30,7 @@ public class X_AD_Tree extends PO implements I_AD_Tree, I_Persistent
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20181226L;
|
||||
private static final long serialVersionUID = 20181228L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_Tree (Properties ctx, int AD_Tree_ID, String trxName)
|
||||
|
@ -305,6 +305,34 @@ public class X_AD_Tree extends PO implements I_AD_Tree, I_Persistent
|
|||
return new KeyNamePair(get_ID(), getName());
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_Column getParent_Column() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_Column)MTable.get(getCtx(), org.compiere.model.I_AD_Column.Table_Name)
|
||||
.getPO(getParent_Column_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Parent Column.
|
||||
@param Parent_Column_ID
|
||||
The link column on the parent tab.
|
||||
*/
|
||||
public void setParent_Column_ID (int Parent_Column_ID)
|
||||
{
|
||||
if (Parent_Column_ID < 1)
|
||||
set_Value (COLUMNNAME_Parent_Column_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_Parent_Column_ID, Integer.valueOf(Parent_Column_ID));
|
||||
}
|
||||
|
||||
/** Get Parent Column.
|
||||
@return The link column on the parent tab.
|
||||
*/
|
||||
public int getParent_Column_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_Parent_Column_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Process Now.
|
||||
@param Processing Process Now */
|
||||
public void setProcessing (boolean Processing)
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.compiere.model.GridField;
|
|||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.GridTable;
|
||||
import org.compiere.model.GridWindow;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MTree;
|
||||
import org.compiere.model.MTreeNode;
|
||||
import org.compiere.swing.CPanel;
|
||||
|
@ -658,8 +659,15 @@ public class GridController extends CPanel
|
|||
if (AD_Tree_ID == 0)
|
||||
AD_Tree_ID = MTree.getDefaultAD_Tree_ID (
|
||||
Env.getAD_Client_ID(Env.getCtx()), m_mTab.getKeyColumnName());
|
||||
int linkColId = MTree.get(Env.getCtx(), AD_Tree_ID, null).getParent_Column_ID();
|
||||
String linkColName = null;
|
||||
int linkID = 0;
|
||||
if (linkColId > 0) {
|
||||
linkColName = MColumn.getColumnName(Env.getCtx(), linkColId);
|
||||
linkID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, linkColName, true);
|
||||
}
|
||||
if (m_tree != null)
|
||||
m_tree.initTree (AD_Tree_ID);
|
||||
m_tree.initTree (AD_Tree_ID, linkColName, linkID);
|
||||
}
|
||||
|
||||
activateChilds();
|
||||
|
|
|
@ -173,7 +173,7 @@ public final class VTreePanel extends CPanel
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7188402231414573844L;
|
||||
private static final long serialVersionUID = 8238886431744822217L;
|
||||
|
||||
private static final String PREFIX_DOCUMENT_SEARCH = "/";
|
||||
|
||||
|
@ -242,13 +242,22 @@ public final class VTreePanel extends CPanel
|
|||
* @return true if loaded ok
|
||||
*/
|
||||
public boolean initTree (int AD_Tree_ID)
|
||||
{
|
||||
return initTree (AD_Tree_ID, null, 0);
|
||||
}
|
||||
|
||||
public boolean initTree (int AD_Tree_ID, String linkColName, int linkID)
|
||||
{
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("AD_Tree_ID=" + AD_Tree_ID);
|
||||
//
|
||||
m_AD_Tree_ID = AD_Tree_ID;
|
||||
|
||||
// Get Tree
|
||||
MTree vTree = new MTree (Env.getCtx(), AD_Tree_ID, m_editable, true, null);
|
||||
MTree vTree = null;
|
||||
if (linkColName != null)
|
||||
vTree = new MTree (Env.getCtx(), AD_Tree_ID, m_editable, true, null, linkColName, linkID);
|
||||
else
|
||||
vTree = new MTree (Env.getCtx(), AD_Tree_ID, m_editable, true, null);
|
||||
m_root = vTree.getRoot();
|
||||
m_root.setName(Msg.getMsg(Env.getCtx(), vTree.getName() ) ); // translate name of menu.
|
||||
// m_root.setName(Msg.getMsg(Env.getCtx(), "Menu") ); // @Trifon; this is the hardcoded way.
|
||||
|
|
|
@ -67,6 +67,7 @@ import org.compiere.model.GridTab;
|
|||
import org.compiere.model.GridTable;
|
||||
import org.compiere.model.GridWindow;
|
||||
import org.compiere.model.I_AD_Preference;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MPreference;
|
||||
import org.compiere.model.MRole;
|
||||
|
@ -135,7 +136,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1639104320722589666L;
|
||||
private static final long serialVersionUID = 5117210424909609150L;
|
||||
|
||||
private static final String ON_SAVE_OPEN_PREFERENCE_EVENT = "onSaveOpenPreference";
|
||||
|
||||
|
@ -758,7 +759,14 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
treePanel.initTree(AD_Tree_ID, windowNo);
|
||||
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||
} else if (AD_Tree_ID_Default != 0) {
|
||||
treePanel.initTree(AD_Tree_ID_Default, windowNo);
|
||||
int linkColId = MTree.get(Env.getCtx(), AD_Tree_ID_Default, null).getParent_Column_ID();
|
||||
String linkColName = null;
|
||||
int linkID = 0;
|
||||
if (linkColId > 0) {
|
||||
linkColName = MColumn.getColumnName(Env.getCtx(), linkColId);
|
||||
linkID = Env.getContextAsInt(Env.getCtx(), windowNo, linkColName, true);
|
||||
}
|
||||
treePanel.initTree(AD_Tree_ID_Default, windowNo, linkColName, linkID);
|
||||
Events.echoEvent(ON_DEFER_SET_SELECTED_NODE, this, null);
|
||||
}
|
||||
}
|
||||
|
@ -1441,12 +1449,24 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
else
|
||||
{
|
||||
AD_Tree_ID = MTree.getDefaultAD_Tree_ID (Env.getAD_Client_ID(Env.getCtx()), gridTab.getKeyColumnName());
|
||||
treePanel.initTree(AD_Tree_ID, windowNo);
|
||||
treePanel.prepareForRefresh();
|
||||
int linkColId = MTree.get(Env.getCtx(), AD_Tree_ID, null).getParent_Column_ID();
|
||||
String linkColName = null;
|
||||
int linkID = 0;
|
||||
if (linkColId > 0) {
|
||||
linkColName = MColumn.getColumnName(Env.getCtx(), linkColId);
|
||||
linkID = Env.getContextAsInt(Env.getCtx(), windowNo, linkColName, true);
|
||||
}
|
||||
if (treePanel.initTree(AD_Tree_ID, windowNo, linkColName, linkID))
|
||||
echoDeferSetSelectedNodeEvent();
|
||||
else
|
||||
setSelectedNode(gridTab.getRecord_ID());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}else if(e.isInserting() && gridTab.getRecord_ID() < 0 && gridTab.getTabLevel() > 0 )
|
||||
} else if (e.isInserting() && gridTab.getRecord_ID() < 0 && gridTab.getTabLevel() > 0
|
||||
&& gridTab.getParentTab() != null && gridTab.getParentTab().getValue("AD_Tree_ID") != null)
|
||||
{
|
||||
int AD_Tree_ID = Integer.parseInt(gridTab.getParentTab().getValue("AD_Tree_ID").toString());
|
||||
treePanel.initTree(AD_Tree_ID, windowNo);
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ADTreePanel extends Panel implements EventListener<Event>
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 164816320839461191L;
|
||||
private static final long serialVersionUID = 2718257463734592729L;
|
||||
private static final String ON_EXPAND_MENU_EVENT = "onExpandMenu";
|
||||
private TreeSearchPanel pnlSearch;
|
||||
private Tree tree;
|
||||
|
@ -70,11 +70,16 @@ public class ADTreePanel extends Panel implements EventListener<Event>
|
|||
* @param windowNo
|
||||
*/
|
||||
public boolean initTree(int AD_Tree_ID, int windowNo)
|
||||
{
|
||||
return initTree(AD_Tree_ID, windowNo, null, 0);
|
||||
}
|
||||
|
||||
public boolean initTree(int AD_Tree_ID, int windowNo, String linkColName, int linkID)
|
||||
{
|
||||
if (this.AD_Tree_ID != AD_Tree_ID)
|
||||
{
|
||||
this.AD_Tree_ID = AD_Tree_ID;
|
||||
SimpleTreeModel.initADTree(tree, AD_Tree_ID, windowNo);
|
||||
SimpleTreeModel.initADTree(tree, AD_Tree_ID, windowNo, linkColName, linkID);
|
||||
MTree_Base tb = MTree_Base.get(Env.getCtx(), AD_Tree_ID, null);
|
||||
if (tb.isLoadAllNodesImmediately())
|
||||
TreeUtils.collapseTree(tree, true);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SimpleTreeModel extends org.zkoss.zul.DefaultTreeModel<Object> impl
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1591436379012706094L;
|
||||
private static final long serialVersionUID = 4945968834244672653L;
|
||||
|
||||
private static final CLogger logger = CLogger.getCLogger(SimpleTreeModel.class);
|
||||
|
||||
|
@ -69,6 +69,10 @@ public class SimpleTreeModel extends org.zkoss.zul.DefaultTreeModel<Object> impl
|
|||
return initADTree(tree, AD_Tree_ID, windowNo, true, null);
|
||||
}
|
||||
|
||||
public static SimpleTreeModel initADTree(Tree tree, int AD_Tree_ID, int windowNo, String linkColName, int linkID) {
|
||||
return initADTree(tree, AD_Tree_ID, windowNo, true, null, linkColName, linkID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tree
|
||||
* @param AD_Tree_ID
|
||||
|
@ -78,7 +82,11 @@ public class SimpleTreeModel extends org.zkoss.zul.DefaultTreeModel<Object> impl
|
|||
* @return SimpleTreeModel
|
||||
*/
|
||||
public static SimpleTreeModel initADTree(Tree tree, int AD_Tree_ID, int windowNo, boolean editable, String trxName) {
|
||||
MTree vTree = new MTree (Env.getCtx(), AD_Tree_ID, editable, true, trxName);
|
||||
return initADTree(tree, AD_Tree_ID, windowNo, editable, trxName, null, 0);
|
||||
}
|
||||
|
||||
public static SimpleTreeModel initADTree(Tree tree, int AD_Tree_ID, int windowNo, boolean editable, String trxName, String linkColName, int linkID) {
|
||||
MTree vTree = new MTree (Env.getCtx(), AD_Tree_ID, editable, true, trxName, linkColName, linkID);
|
||||
MTreeNode root = vTree.getRoot();
|
||||
SimpleTreeModel treeModel = SimpleTreeModel.createFrom(root);
|
||||
treeModel.setItemDraggable(true);
|
||||
|
|
Loading…
Reference in New Issue