+ * Callout's are used for cross field validation and setting values in other fields + * when returning a non empty (error message) string, an exception is raised + *
+ * When invoked, the Tab model has the new value! + * + * @param ctx Context + * @param WindowNo current Window No + * @param mTab Model Tab + * @param mField Model Field + * @param value The new value + * @param oldValue The old value + * @return Error message or "" + */ + public String start (Properties ctx, int WindowNo, + GridTab mTab, GridField mField, Object value, Object oldValue); + +} diff --git a/base/src/org/compiere/model/Callout.java b/base/src/org/compiere/model/Callout.java index 1709ed74df..3ddfcf7b20 100644 --- a/base/src/org/compiere/model/Callout.java +++ b/base/src/org/compiere/model/Callout.java @@ -27,7 +27,7 @@ import org.adempiere.base.IService; * @author Jorg Janke * @version $Id: Callout.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $ */ -public interface Callout extends IService +public interface Callout { /** * Start Callout. diff --git a/base/src/org/compiere/model/GridTab.java b/base/src/org/compiere/model/GridTab.java index 041ede129a..40ff01a1b3 100644 --- a/base/src/org/compiere/model/GridTab.java +++ b/base/src/org/compiere/model/GridTab.java @@ -38,6 +38,7 @@ import javax.script.ScriptEngine; import javax.swing.event.EventListenerList; import org.adempiere.base.Core; +import org.adempiere.base.IColumnCallout; import org.adempiere.base.Service; import org.compiere.util.CLogMgt; import org.compiere.util.CLogger; @@ -72,7 +73,7 @@ import org.compiere.util.ValueNamePair; * * @author Jorg Janke * @version $Id: GridTab.java,v 1.10 2006/10/02 05:18:39 jjanke Exp $ - * + * * @author Teo Sarca, SC ARHIPAC SERVICE SRL *
@@ -120,7 +121,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable { this(vo, w, false); } - + /** * Create Tab (Model) from Value Object. *
@@ -196,13 +197,13 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
/** Logger */
protected CLogger log = CLogger.getCLogger(getClass());
-
+
private boolean m_parentNeedSave = false;
private long m_lastDataStatusEventTime;
private DataStatusEvent m_lastDataStatusEvent;
-
+
// Context property names:
public static final String CTX_KeyColumnName = "_TabInfo_KeyColumnName";
public static final String CTX_LinkColumnName = "_TabInfo_LinkColumnName";
@@ -213,7 +214,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
public static final String CTX_AD_Table_ID = "_TabInfo_AD_Table_ID";
public static final String CTX_FindSQL = "_TabInfo_FindSQL";
public static final String CTX_SQL = "_TabInfo_SQL";
-
+
/**************************************************************************
@@ -258,7 +259,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
return m_loadComplete;
}
-
+
/**
* Initialize Tab with record from AD_Tab_v
* @param async async
@@ -268,7 +269,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
log.fine("#" + m_vo.TabNo + " - Async=" + async + " - Where=" + m_vo.WhereClause);
if (isLoadComplete()) return true;
-
+
if (m_loader != null && m_loader.isAlive())
{
waitLoadCompete();
@@ -289,9 +290,9 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
} // initTab
protected boolean loadTab()
- {
+ {
m_extendedWhere = m_vo.WhereClause;
-
+
// Get Field Data
if (!loadFields())
{
@@ -305,7 +306,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
m_loadComplete = true;
return true;
}
-
+
/**
* Dispose - clean up resources
*/
@@ -412,7 +413,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
}
} // for all fields
- if (! m_mTable.getTableName().equals(X_AD_PInstance_Log.Table_Name)) { // globalqss, bug 1662433
+ if (! m_mTable.getTableName().equals(X_AD_PInstance_Log.Table_Name)) { // globalqss, bug 1662433
// Add Standard Fields
if (m_mTable.getField("Created") == null)
{
@@ -609,7 +610,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
public void query (boolean onlyCurrentRows, int onlyCurrentDays, int maxRows)
{
if (!m_loadComplete) initTab(false);
-
+
log.fine("#" + m_vo.TabNo
+ " - Only Current Rows=" + onlyCurrentRows
+ ", Days=" + onlyCurrentDays + ", Detail=" + isDetail());
@@ -645,7 +646,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
String value = null;
if ( m_parentColumnName.length() > 0 )
- {
+ {
// explicit parent link defined
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, getParentTabNo(), m_parentColumnName, true);
if (value == null || value.length() == 0)
@@ -654,8 +655,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, getParentTabNo(), lc, true);
if (value == null || value.length() == 0)
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true); // back compatibility
- }
-
+ }
+
// Same link value?
if (refresh)
refresh = m_linkValue.equals(value);
@@ -933,25 +934,25 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
if (hasChangedCurrentTabAndParents())
return false;
-
+
boolean retValue = (m_mTable.dataSave(manualCmd) == GridTable.SAVE_OK);
if (manualCmd)
{
setCurrentRow(m_currentRow, false);
- if (m_lastDataStatusEvent != null && m_lastDataStatusEvent.getCurrentRow() == m_currentRow
- && ((m_lastDataStatusEvent.Record_ID != null && m_lastDataStatusEvent.Record_ID instanceof Integer
+ if (m_lastDataStatusEvent != null && m_lastDataStatusEvent.getCurrentRow() == m_currentRow
+ && ((m_lastDataStatusEvent.Record_ID != null && m_lastDataStatusEvent.Record_ID instanceof Integer
&& (Integer) m_lastDataStatusEvent.Record_ID == 0) || m_lastDataStatusEvent.Record_ID == null))
{
updateDataStatusEventProperties(m_lastDataStatusEvent);
}
}
fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_SAVE));
-
+
if (retValue) {
// refresh parent tabs
refreshParents();
}
-
+
return retValue;
}
catch (Exception e)
@@ -1052,7 +1053,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
log.fine("#" + m_vo.TabNo);
m_mTable.dataIgnore();
setCurrentRow(m_currentRow, false); // re-load data
-
+
fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_IGNORE));
log.fine("#" + m_vo.TabNo + "- fini");
} // dataIgnore
@@ -1085,11 +1086,11 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
}
log.finest("Processed=" + processed);
}
-
+
//hengsin, dont create new when parent is empty
if (isDetail() && m_parentNeedSave)
return false;
-
+
/**
* temporary set currentrow to point to the new row to ensure even cause by m_mTable.dataNew
* is handle properly.
@@ -1101,7 +1102,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
if (!retValue)
return retValue;
setCurrentRow(m_currentRow + 1, true);
-
+
// process all Callouts (no dependency check - assumed that settings are valid)
for (int i = 0; i < getFieldCount(); i++)
processCallout(getField(i));
@@ -1112,7 +1113,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
getField(i).validateValue();
}
m_mTable.setChanged(false);
-
+
fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_NEW));
return retValue;
} // dataNew
@@ -1193,7 +1194,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
return m_keyColumnName;
} // getKeyColumnName
-
+
/**
* Set Name of the Key Column
* @param keyColumnName
@@ -1226,9 +1227,9 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
m_parentColumnName = DB.getSQLValueString(null, sql, m_vo.Parent_Column_ID );
if ( m_parentColumnName == null )
m_parentColumnName = "";
-
-
-
+
+
+
if (linkColumnName != null)
m_linkColumnName = linkColumnName;
else
@@ -1344,7 +1345,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
*/
public boolean isDetail()
{
- // First Tab Level is not a detail
+ // First Tab Level is not a detail
if (m_vo.TabLevel == 0)
return false;
// We have IsParent columns and/or a link column
@@ -1406,7 +1407,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
if (m_vo.IsReadOnly)
return true;
-
+
//hengsin, make detail readonly when parent is empty
if (m_parentNeedSave) return true;
@@ -1790,7 +1791,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
-
+
if (filled)
return mf.format (arguments);
return " ";
@@ -1857,7 +1858,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
-
+
if (filled)
return mf.format (arguments);
return " ";
@@ -1935,7 +1936,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
if (colFax != null && (colFax.getVFormat() == null || colFax.getVFormat().length() == 0))
fFax.setVFormat(phone_frm);
}
-
+
} // loadDependentInfo
@@ -2202,11 +2203,11 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
}
else // Redistribute Info with current row info
fireDataStatusChanged(m_DataStatusEvent);
-
+
//reset
m_lastDataStatusEventTime = System.currentTimeMillis();
m_lastDataStatusEvent = m_DataStatusEvent;
- m_DataStatusEvent = null;
+ m_DataStatusEvent = null;
// log.fine("dataStatusChanged #" + m_vo.TabNo + "- fini", e.toString());
} // dataStatusChanged
@@ -2325,9 +2326,9 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
// Row range check
int newRow = verifyRow(targetRow);
-
+
// Check, if we have old uncommitted data
- if (m_mTable.dataSave(newRow, false) == false)
+ if (m_mTable.dataSave(newRow, false) == false)
return m_currentRow;
//remove/ignore new and unchange row
@@ -2337,7 +2338,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
newRow--;
dataIgnore();
}
-
+
// new position
return setCurrentRow(newRow, true);
} // navigate
@@ -2427,7 +2428,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
// Object value = null;
// if (mField.isKey() || mField.isParent() || mField.getColumnName().equals(m_linkColumnName))
// value = mField.getDefault();
-
+
// CarlosRuiz - globalqss [ 1881480 ] Navigation problem between tabs
// the implementation of linking with window context variables is very weak
// you must be careful when defining a column in a detail tab with a field
@@ -2453,7 +2454,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
m_DataStatusEvent = m_lastDataStatusEvent;
}
-
+
// inform APanel/.. -> dataStatus with row updated
if (m_DataStatusEvent == null)
m_DataStatusEvent = new DataStatusEvent(this, getRowCount(),
@@ -2465,10 +2466,10 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
if (status == null || status.length() == 0)
m_DataStatusEvent.setInfo(DEFAULT_STATUS_MESSAGE, null, false,false);
fireDataStatusChanged(m_DataStatusEvent);
-
+
//reset
m_DataStatusEvent = null;
-
+
return m_currentRow;
} // setCurrentRow
@@ -2565,10 +2566,10 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
return "NoField";
log.fine(field.getColumnName() + "=" + value + " - Row=" + m_currentRow);
-
+
if (DisplayType.isID(field.getDisplayType()) && value instanceof Integer && ((Integer)value).intValue() < 0)
value = null;
-
+
int col = m_mTable.findColumn(field.getColumnName());
m_mTable.setValueAt(value, m_currentRow, col, false);
//
@@ -2643,12 +2644,12 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
} // for all dependent fields
} // processDependencies
-
+
private List