XFormsCell.prototype = new XFormsAttribute;
function XFormsCell (strParentId, nCol, strId, nRow, strTag)
{
if (!strParentId)
{
return;
}
XFormsAttribute.call(this, strParentId, strId, strTag);
this.col = nCol;
this.row = nRow;
this.rowstatus = GRS_NEW;
this.colstatus = true;
this.mergeType = CMS_NORMAL;
this.mergeParentId = null;
this.m_nRowSpan = 1;
this.m_nColSpan = 1;
this.m_fixedInputType = CIT_OUTPUT;// fixedbox의 상태
this.m_fixedCheckStatus = false; //fixedbox의 check상태
this.m_fixedNoCheckAll = false;
this.m_xnNodeElement;
this.m_heControl;
this.m_heDataControl = null;
this.m_objOldCellStyle = new Hashtable();
this.m_objCellStyle = new Hashtable();
this.m_bIsSubTotal = false;
this.editing = false;
this.down = false;
this.disable = false;
this.hover = false;
this.selected = false;
this.isReadOnly = false;
// treeview property
this.expanded = 0;
this.checked = 0;
this.m_nChildNumber = -1;
this.m_strRecursion = "";
this.index = -1;
};
XFormsCell.prototype.init = function ()
{
this.m_heControl = document.getElementById("HE_" + this.id);
var heTempControl = document.getElementById(this.id + "_data");
if (heTempControl)
{
this.m_heDataControl = heTempControl;
heTempControl=null;
}
var objElement = this.getElement();
if ("xforms:col" != objElement.elementName && "xforms:gridfixedcell" != objElement.elementName)
{
for (var strAttribute in objElement.attribute)
{
if (STYLE_LIST[strAttribute])
{
this.setAttribute(strAttribute, objElement.attribute[strAttribute]);
}
}
this.applyDefaultStyle();
}
};
XFormsCell.prototype.unInit = function ()
{
this.m_heControl = null;
this.m_heDataControl = null;
};
XFormsCell.prototype.applyDefaultStyle = function ()
{
XFormsAttribute.prototype.applyDefaultStyle.call(this);
if (null != this.m_heControl)
{
this.m_heControl.style.borderLeft = "";
this.m_heControl.style.borderTop = "";
}
};
XFormsCell.prototype.getInputType = function ()
{
if (null != this.m_objElement)
{
return this.m_objElement.getInputType();
}
return CIT_OUTPUT;
};
XFormsCell.prototype.getMergeType = function ()
{
return this.mergeType;
};
XFormsCell.prototype.getHtmlElement = function ()
{
return this.m_heControl;
};
XFormsCell.prototype.setHtmlElement = function (heElement)
{
this.m_heControl = heElement;
};
XFormsCell.prototype.getNodeElement = function ()
{
return this.m_xnNodeElement;
};
XFormsCell.prototype.setNodeElement = function (xnNode)
{
this.m_xnNodeElement = xnNode;
};
XFormsCell.prototype.getText = function ()
{
if (this.m_xnNodeElement)
{
return XmlLib.getTextValue(this.m_xnNodeElement);
}
else
{
var strText = XFormsCaption.prototype.getText.call(this);
if (strText)
{
return strText;
}
}
return "";
};
XFormsCell.prototype.getIsReadOnly = function ()
{
return this.isReadOnly || this.disable;
};
XFormsCell.prototype.setText = function (strValue)
{
if (this.m_xnNodeElement)
{
XmlLib.setTextValue(this.m_xnNodeElement, strValue);
}
else
{
XFormsElementBase.prototype.setText.call(this, strValue);
}
};
XFormsCell.prototype.setFixedWindowText = function (strValue)
{
if (null == this.m_heControl)
{
return;
}
var heFixedCell = this.m_heControl.lastChild;
if (heFixedCell)
{
if(this.parent.autoResize)
{
heFixedCell.innerHTML = strValue;
}
else
{
if ("NOBR" == heFixedCell.tagName)
{
heFixedCell.innerHTML = strValue;
}
else
{
heFixedCell.innerHTML = "" + strValue + "";
}
}
}
//메모리 환원
heFixedCell = null;
};
XFormsCell.prototype.getWindowText = function ()
{
if (is_ie)
{
return this.m_heControl.innerText;
}
else
{
return this.m_heControl.textContent;
}
};
XFormsCell.prototype.setWindowText = function (strValue, bIsSubTotal, strFormat)
{
var objCol = this.getElement();
if (this.m_heDataControl)
{
if (null == strValue)
{
strValue = "";
}
if (bIsSubTotal)
{
if (null == strValue)
{
strValue = "";
}
strValue = strValue.formatting(strFormat);
}
else
{
if (null == strValue)
{
strValue = "";
}
strFormat = this.m_objElement.getAttribute("format");
strValue = strValue.formatting(strFormat);
}
if (is_ie)
{
if (strValue == this.m_heDataControl.outerText)
// if (strValue == this.m_heDataControl.innerText)
{
return;
}
}
else
{
if (strValue == this.m_heDataControl.textContent)
{
return;
}
}
if (instance1.preserveWhitespace)
{
strValue = strValue.replace(/\s/g," ");
}
if ("" != strValue && (-1 != objCol.attribute["secretendposition"] || -1 != objCol.attribute["secretstartposition"]))
{
var nStartPo = -1 == objCol.attribute["secretstartposition"] ? 0 : objCol.attribute["secretstartposition"];
var nEndPo = -1 == objCol.attribute["secretendposition"] ? strValue.length : objCol.attribute["secretendposition"];
if (nEndPo > nStartPo)
{
var strMark = objCol.attribute["secretmark"];
var strTempValue = strValue.substr(0,nStartPo);
var strLastValue = strValue.substr(nEndPo, strValue.length);
for (var i=nStartPo; i < nEndPo; i++)
{
strTempValue += strMark;
}
strValue = strTempValue + strLastValue;
}
}
if(this.parent.autoResize)
{
this.m_heDataControl.innerHTML = strValue;
}
else
{
this.m_heDataControl.innerHTML = "" + strValue +"";
}
}
};
//datagrid refresh 후 checkbox는 노드의 값이 변경되어도 설정이 변경되지 않음
XFormsCell.prototype.setTextRefresh = function (strText)
{
var strToolTipText = strText;
if (null != strText)
{
var objCol = this.getElement();
if (CIT_CHECK == this.getInputType() || CIT_RADIO == this.getInputType())
{
if (objCol)
{
var bCheck = (strText == objCol.getTrueValue())? true : false;
var strValue = bCheck ? objCol.getTrueValue() : objCol.getFalseValue();
if (bCheck)
{
objCol.m_nBeforeSelectRow = this.row;
}
this.setBoolState(bCheck);
this.setWindowText(strText);
}
}
else if (CIT_COMBO == this.getInputType())
{
if (objCol)
{
if (objCol.m_bIsCellCombo && objCol.m_objCombo.isnodeset)
{
var strObjCellNodeSet = this.getAttribute("nodeset");
if (null != strObjCellNodeSet)
{
objCol.m_objCombo.nodeset = strObjCellNodeSet;
objCol.m_objCombo.reBuild();
}
else
{
if (null != objCol.m_strComboNodeSet & objCol.m_strComboNodeSet != objCol.m_objCombo.nodeset)
{
objCol.m_objCombo.nodeset = objCol.m_strComboNodeSet;
objCol.m_objCombo.reBuild();
}
}
}
strToolTipText = objCol.m_objCombo.getLableByValue(strText);
this.setWindowText(strToolTipText);
}
}
else
{
this.setWindowText(strText);
}
}
if ("label" == this.parent.m_strTooltip)
{
if (null != this.m_heControl)
{
this.m_heControl.title = strToolTipText;
}
}
else if ("true" == this.parent.m_strTooltip)
{
if (null != this.m_heControl)
{
this.m_heControl.title = strText;
}
}
};
XFormsCell.prototype.getSelect = function ()
{
return this.selected;
};
XFormsCell.prototype.setSelect = function (bSelect)
{
this.selected = bSelect;
if (this.parent instanceof XFormsDataGrid)
{
if (bSelect)
{
if ("transparent" != this.parent.focusColor)
{
HtmlLib.setStyle(this.m_heControl, "background-color", this.parent.focusColor);
if ("invert" == this.parent.selectFontColorStyle && "#3161C6" == this.parent.focusColor && "invert" == this.parent.selectImageStyle)
{
if (this.m_heDataControl)
{
var strRGB = "";
if (this.m_objCellStyle["color"])
{
strRGB = this.m_objCellStyle["color"];
}
else
{
strRGB = this.attribute["color"];
}
if (!strRGB)
{
strRGB = "#000000";
}
this.m_heDataControl.style.color = strRGB.invertRGB();
}
}
}
}
else
{
if ("transparent" != this.parent.focusColor)
{
if (this.m_objCellStyle["background-color"])
{
var strBGColor = this.m_objCellStyle["background-color"];
}
else
{
var strBGColor = this.attribute["background-color"];
}
if (!strBGColor)
{
strBGColor = "#FFFFFF";
}
HtmlLib.setStyle(this.m_heControl, "background-color", strBGColor);
if (this.m_heDataControl)
{
var strColor = "";
if (this.m_objCellStyle["color"])
{
strColor = this.m_objCellStyle["color"];
}
else
{
strColor = this.attribute["color"];
}
if (!strColor)
{
strColor = "#000000";
}
this.m_heDataControl.style.color = strColor;
}
}
}
}
else /*if (this.parent instanceof XFormsSelect)*/
{
var objElement = this.getElement();
if (null != objElement)
{
objElement.setSelect(bSelect);
}
}
};
XFormsCell.prototype.getDisabled = function ()
{
return this.disable;
};
XFormsCell.prototype.setDisabled = function (bDisable)
{
this.disable = bDisable;
};
XFormsCell.prototype.getBoolState = function ()
{
var strNodeValue = this.getText();
var strTrueValue = this.m_objElement.getTrueValue();
var strFalseValue = this.m_objElement.getFalseValue();
if (strNodeValue == strTrueValue)
{
this.boolstate = true;
}
else if (strNodeValue == strFalseValue)
{
this.boolstate = false;
}
return this.boolstate;
};
XFormsCell.prototype.setBoolState = function (bCheck, bUpdateNode, strTrue, strFalse)
{
this.boolstate = bCheck;
if (bUpdateNode)
{
this.setText(strValue);
}
var heCheck = this.m_heControl.firstChild;
if (heCheck)
{
if (CIT_CHECK == this.getInputType())
{
heCheck.src = this.boolstate ? this.m_objElement.getAttribute("checkimage") : this.m_objElement.getAttribute("uncheckimage");
}
else if (CIT_RADIO == this.getInputType())
{
heCheck.src = this.boolstate ? this.m_objElement.getAttribute("selectimage") : this.m_objElement.getAttribute("unselectimage");
}
}
};
XFormsCell.prototype.getStatus = function ()
{
return this.rowstatus;
};
XFormsCell.prototype.setStatus = function (nStatus)
{
this.rowstatus = nStatus;
};
XFormsCell.prototype.getColStatus = function ()
{
return this.colstatus;
};
XFormsCell.prototype.setColStatus = function (bStatus)
{
this.colstatus = bStatus;
};
XFormsCell.prototype.setEditingMode = function (bEditing)
{
this.editing = bEditing;
};
XFormsCell.prototype.changeRowHeadUpdate = function (nStatus)
{
var heUpdate = this.m_heControl.firstChild;
if (null != heUpdate)
{
switch (nStatus)
{
case GRS_INSERT :
case GRS_INSERTANDNEW :
{
heUpdate.src = this.parent.m_strInsertFlagImage;
break;
}
case GRS_UPDATE :
{
heUpdate.src = this.parent.m_strUpdateFlagImage;
break;
}
case GRS_DELETE :
case GRS_DELETEANDUPDATE :
{
heUpdate.src = this.parent.m_strDeleteFlagImage;
break;
}
default :
{
heUpdate.src = this.parent.m_strNormalFlagImage;
break;
}
}
}
};
XFormsCell.prototype.getClientLeft = function (bCalcScroll)
{
var nClientLeft = 0;
var heOffsetParent = this.m_heControl;
while (null != heOffsetParent)
{
nClientLeft += heOffsetParent.offsetLeft;
if (heOffsetParent != this.m_heControl ) nClientLeft += heOffsetParent.clientLeft;
if (bCalcScroll && heOffsetParent != document.body) nClientLeft -= (is_android ? 0 : heOffsetParent.scrollLeft);
heOffsetParent = heOffsetParent.offsetParent;
}
return nClientLeft;
};
XFormsCell.prototype.getClientTop = function (bCalcScroll)
{
var nClientTop = 0;
var heOffsetParent = this.m_heControl;
while (null != heOffsetParent)
{
nClientTop += heOffsetParent.offsetTop;
if (heOffsetParent != this.m_heControl ) nClientTop += heOffsetParent.clientTop;
if (bCalcScroll && heOffsetParent != document.body) nClientTop -= (is_android ? 0 : heOffsetParent.scrollTop);
heOffsetParent = heOffsetParent.offsetParent;
}
return nClientTop;
};
XFormsCell.prototype.setFixedCheck = function (bCheck)
{
if (CIT_CHECK == this.m_objElement.getInputType())
{
var strValue = bCheck ? this.m_objElement.getTrueValue() : this.m_objElement.getFalseValue();
this.setBoolState(bCheck);
this.setText(strValue);
}
};
XFormsCell.prototype.setFixedInputType = function (nStatus)
{
this.m_fixedInputType = nStatus;
};
XFormsCell.prototype.getFixedInputType = function ()
{
return this.m_fixedInputType;
};
XFormsCell.prototype.getLabel = function ()
{
return this.m_heControl.getAttribute("label");
};
XFormsCell.prototype.setLabel = function (strLabel)
{
return this.m_heControl.setAttribute("label", strLabel);
};
XFormsCell.prototype.setLabelChange = function (strLabel)
{
return this.m_heControl.innerHTML = strLabel;
};
XFormsCell.prototype.getValue = function ()
{
if (null != this.m_heControl)
{
return this.m_heControl.getAttribute("value");
}
else
{
return "";
}
};
XFormsCell.prototype.setAttribute = function (strName, objValue)
{
XFormsAttribute.prototype.setAttribute.call(this, strName, objValue);
switch (strName)
{
case "color":
{
if (this.m_heDataControl)
{
HtmlLib.setStyle(this.m_heDataControl,strName,objValue);
}
}
}
};
XFormsCell.prototype.setValue = function (strValue)
{
return this.m_heControl.setAttribute("value", strValue);
};
XFormsCell.prototype.setMergeType = function (bStatus)
{
if (bStatus)
{
this.mergeType = CMS_NORMAL;
}
else
{
this.mergeType = CMS_LOCK;
}
};
XFormsCell.prototype.setIndex = function (nIndex)
{
this.index = nIndex;
};
XFormsCell.prototype.getState = function ()
{
var nState = FCS_NORMAL;
if (this.disable)
{
nState |= FCS_DISABLE;
}
if (this.m_bHover)
{
nState |= FCS_HOVER;
}
if (this.selected)
{
nState |= FCS_SELECT;
}
if (this.m_bFocus)
{
nState |= FCS_FOCUS;
}
if (this.down)
{
nState |= FCS_DOWN;
}
return nState;
};
XFormsCell.prototype.setExpand = function (nExpand)
{
// expand설정
this.expanded = nExpand;
};
XFormsCell.prototype.getExpand = function ()
{
return this.expanded;
};
XFormsCell.prototype.haschilditem = function ()
{
return this.m_nChildNumber;
};
XFormsCell.prototype.setChecked = function (nChecked)
{
if (this.checked != nChecked)
{
this.checked = nChecked;
var heCheck = document.getElementById("HE_" + this.id + "_check");
if (null == heCheck)
{
return;
}
// IMG Tag를 가져온다.
var heCheckIMG = null;
for (var i=0; i