/*
根据field获取gridcompColumn对象
508771
function(field){
			for (var i = 0; i < this.gridCompColumnArr.length; i++) {
				if (this.gridCompColumnArr[i].options.field == field) {
					return this.gridCompColumnArr[i];
				}
			}
			return null;
		}
68002
public function getCMSFields()
    {
        // Create Field Tab Set:
        
        $fields = FieldList::create(TabSet::create('Root'));
        
        // Define Placeholder:
        
        $placeholder = _t(__CLASS__ . '.DROPDOWNSELECT', 'Select');
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                DropdownField::create(
                    'PageClass',
                    $this->fieldLabel('PageClass'),
                    $this->getPageClassOptions()
                )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder),
                DropdownField::create(
                    'MyTemplateID',
                    $this->fieldLabel('MyTemplateID'),
                    Template::get()->map()
                )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder),
                DropdownField::create(
                    'MyLayoutID',
                    $this->fieldLabel('MyLayoutID'),
                    Layout::get()->map()
                )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder)
            ]
        );
        
        // Create Grid Field Config:
        
        $spansConfig = GridFieldConfig_RecordEditor::create();
        
        // Obtain Edit Form Component:
        
        $editComponent = $spansConfig->getComponentByType(GridFieldDetailForm::class);
        
        // Define Edit Form Callback:
        
        $editComponent->setItemEditFormCallback(function ($form, $itemRequest) {
            
            // Define Column Options:
            
            $form->Fields()->dataFieldByName('ColumnID')->setSource($this->getColumnOptions());
            
        });
        
        // Create Column Spans Grid Field:
        
        $spans = GridField::create(
            'ColumnSpans',
            $this->fieldLabel('Spans'),
            $this->ColumnSpans(),
            $spansConfig
        );
        
        // Create Column Spans Tab:
        
        $fields->findOrMakeTab('Root.ColumnSpans', $this->owner->fieldLabel('Spans'));
        
        // Add Grid Field to Column Spans Tab:
        
        $fields->addFieldToTab('Root.ColumnSpans', $spans);
        
        // Extend Field Objects:
        
        $this->extend('updateCMSFields', $fields);
        
        // Answer Field Objects:
        
        return $fields;
    }
1340208
public void handleFormula(final FieldAccessor field, final Configuration config, final Cell cell, final Object targetBean) {
        
        ArgUtils.notNull(field, "field");
        ArgUtils.notNull(config, "config");
        ArgUtils.notNull(cell, "cell");
        
        final String evaluatedFormula = createFormulaValue(config, cell, targetBean);
        if(Utils.isEmpty(evaluatedFormula)) {
            cell.setCellType(CellType.BLANK);
            return;
        }
        
        try {
            cell.setCellFormula(evaluatedFormula);
            cell.setCellType(CellType.FORMULA);
            
        } catch(FormulaParseException e) {
            // 数式の解析に失敗した場合
            String message = MessageBuilder.create("cell.failParseFormula")
                    .var("property", field.getNameWithClass())
                    .var("cellAddress", CellPosition.of(cell).toString())
                    .var("formula", evaluatedFormula)
                    .format();
            
            throw new ConversionException(message, e, field.getType());
        }
        
    }
872938
function ERDColumn() {
        ERDElement.apply(this, arguments);

        /** @member {string} */
        this.type = '';

        /** @member {string} */
        this.length = '';

        /** @member {boolean} */
        this.primaryKey = false;

        /** @member {boolean} */
        this.foreignKey = false;

        /** @member {ERDColumn} */
        this.referenceTo = null;

        /** @member {boolean} */
        this.nullable = false;

        /** @member {boolean} */
        this.unique = false;
    }
511536
private static Pair<String, String> getColumnName(Field field) {
        String fieldName = field.getName();
        Column column    = field.getAnnotation(Column.class);
        if (null != column && StringUtils.isNotBlank(column.name())) {
            fieldName = column.name();
        }
        String columnName = NameUtils.getUnderlineName(fieldName);
        return new Pair<>(columnName, fieldName);
    }
1016636
@SneakyThrows
    private void processExcelCellAnnotation(Field field, Object bean) {
        val ann = field.getAnnotation(ExcelCell.class);
        if (ann == null) return;

        Object fv = Fields.invokeField(field, bean);

        if (ann.sheetName()) {
            if (StringUtils.isNotEmpty(ann.replace())) { // 有内容需要替换
                fv = sheet.getSheetName().replace(ann.replace(), Str.nullThen(fv, ""));
            }

            val wb = sheet.getWorkbook();
            val oldSheetName = sheet.getSheetName();
            val newSheetName = "" + fv;
            wb.setSheetName(wb.getSheetIndex(sheet), newSheetName);

            PoiUtil.fixChartSheetNameRef(sheet, oldSheetName, newSheetName);
        } else {
            val cell = PoiUtil.findCell(sheet, ann.value(), StringUtils.defaultIfEmpty(ann.searchKey(), "{" + field.getName() + "}"));
            if (cell == null) {
                log.warn("unable to find cell for {} in field {}", ann, field);
                return;
            }

            if (StringUtils.isNotEmpty(ann.replace())) { // 有内容需要替换
                val old = PoiUtil.getCellStringValue(cell);
                fv = old.replace(ann.replace(), Str.nullThen(fv, ""));
            }

            applyTemplateCellStyle(field, bean, ann, cell);

            val strCellValue = PoiUtil.writeCellValue(cell, fv);
            fixMaxRowHeightRatio(cell.getRow(), ann.maxLineLen(), strCellValue);
        }
    }
550719
function(gridCompColumn,i,begin,length, isFixedColumn){
			var oThis = this,renderType = gridCompColumn.options.renderType,
				sumCol = gridCompColumn.options.sumCol,
				sumRenderType = gridCompColumn.options.sumRenderType,
				dataType = gridCompColumn.options.dataType,
				precision = gridCompColumn.options.precision,
				format = gridCompColumn.options.format,field = gridCompColumn.options.field,
				end = begin,idSuffix = isFixedColumn === true ? '_content_fixed_tbody' : '_content_tbody',
				idStr = isFixedColumn === true? 'fixed_' : '';
			if(length >0){
				end = parseInt(begin + length - 1);
			}
			this.realtimeTableRows = document.getElementById(oThis.options.id + idSuffix).children;
			// 记录role不是row的行
			var notRowIndex = -1;
			for(var k = 0;k < oThis.realtimeTableRows.length;k++) {
				if(oThis.realtimeTableRows[k].getAttribute("role") != "row") {
					notRowIndex = k
				}
			}
			$.each(oThis.dataSourceObj.rows, function(j) {
				if((begin >= 0 && j >= begin && j <= end) || isNaN(begin)){
					var trIndex = j;
					if(notRowIndex != -1 && j >= notRowIndex) {
						trIndex++;
					}
					var tr = oThis.realtimeTableRows[trIndex],td = tr.children[i];
					if(td){
						if(td.children[0].innerHTML.indexOf('u-grid-content-tree-span')   !=  -1){
							var span =  td.children[0].children[1];
						}else{
							var span =  td.children[0];
						}
						if(span){
							var v = $(this.value).attr(field);
							if(typeof renderType == 'function' || dataType == 'Date' || dataType == 'Datetime' || dataType == 'Int' || dataType == 'Float'){
								span.innerHTML = '';
								if(typeof renderType == 'function'){
									v = oThis.getString(v,'');
									var obj = {};
									obj.value = v;
									obj.element = span;
									obj.gridObj = oThis;
									obj.row = this;
									obj.gridCompColumn = gridCompColumn;
									obj.rowIndex = j;
									renderType.call(oThis,obj);
								}else if(dataType == 'Date' || dataType == 'Datetime'){
									if(v == null || v == undefined || v == 'null' || v == 'undefined' || v == ""){
										v = "";
									}
									if (dataType == 'Date'){
										v = u.dateRender(v);
									}else{
										v = u.dateTimeRender(v);
									}
									span.innerHTML = v;
									td.title = v;
								}else if(dataType == 'Int'){
									v = parseInt(v);
									span.innerHTML = v;
									td.title = v;
								}else if(dataType == 'Float'){
									if(precision){
										var o = {};
										o.value = v;
										o.precision = precision;
										v = oThis.DicimalFormater(o);
									}else{
										v = parseFloat(v);
									}
									span.innerHTML = v;
									td.title = v;
								}else{ //此处逻辑放到渲染处，减少render执行次数。
									v = oThis.getString(v,'');
									var v1 = v.replace(/\</g,'\<');
									v1 = v1.replace(/\>/g,'\>');
									td.title = v;
									v = v.replace(/\</g,'&lt;');
									v = v.replace(/\>/g,'&gt;');

									span.innerHTML = v;
								}
							}else{
								v = oThis.getString(v,'');
								var v1 = v.replace(/\</g,'\<');
								v1 = v1.replace(/\>/g,'\>');
								td.title = v;
								v = v.replace(/\</g,'&lt;');
								v = v.replace(/\>/g,'&gt;');

								span.innerHTML = v;
							}
						}

					}
				}
			});
			this.renderTypeSumRow(gridCompColumn,i,begin,length, isFixedColumn);
		}
72522
public void fieldToData(ComponentCache componentCache, int iRowIndex, int iColumnIndex)
    {
        if (componentCache.m_rgcompoments[iColumnIndex] != null)
        {
            Object object = this.getModel().getValueAt(iRowIndex, iColumnIndex);
            String string = "";
            if (object != null)
                string = object.toString();
            if (componentCache.m_rgcompoments[iColumnIndex] instanceof JTextComponent)
                ((JTextComponent)componentCache.m_rgcompoments[iColumnIndex]).setText(string);
            else if (componentCache.m_rgcompoments[iColumnIndex] instanceof JCheckBox)
            {
                boolean bIsSelected = false;
                if (string != null) if (string.equals("1"))
                    bIsSelected = true;
                ((JCheckBox)componentCache.m_rgcompoments[iColumnIndex]).setSelected(bIsSelected);
            }
        }
    }
1308129
function(field,renderType){
			var gridCompColumn = this.getColumnByField(field);
			gridCompColumn.options.renderType = renderType;
			var index = this.getIndexOfColumn(gridCompColumn);
			this.renderTypeByColumn(gridCompColumn,index);
		}
606630
public function findByField($field, $value = null, $columns = ['*'])
    {
        return parent::findByField(
            $this->getColumnName($field),
            $value,
            $this->getColumnsNames($columns)
        );
    }
1358701
function () {
		var columns = this.columns,
			col = columns.length, 
			row,
			val,
			floatVal,
			trimVal,
			dateVal;
			
		while (col--) {
			row = columns[col].length;
			while (row--) {
				val = columns[col][row];
				floatVal = parseFloat(val);
				trimVal = this.trim(val);

				/*jslint eqeq: true*/
				if (trimVal == floatVal) { // is numeric
				/*jslint eqeq: false*/
					columns[col][row] = floatVal;
					
					// If the number is greater than milliseconds in a year, assume datetime
					if (floatVal > 365 * 24 * 3600 * 1000) {
						columns[col].isDatetime = true;
					} else {
						columns[col].isNumeric = true;
					}					
				
				} else { // string, continue to determine if it is a date string or really a string
					dateVal = this.parseDate(val);
					
					if (col === 0 && typeof dateVal === 'number' && !isNaN(dateVal)) { // is date
						columns[col][row] = dateVal;
						columns[col].isDatetime = true;
					
					} else { // string
						columns[col][row] = trimVal === '' ? null : trimVal;
					}
				}
				
			}
		}
	}
578186
@Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
        if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
            field.addJavaDocLine("/**");
            StringBuilder sb = new StringBuilder();
            sb.append(" * ");
            sb.append(introspectedColumn.getRemarks());
            field.addJavaDocLine(sb.toString());
            field.addJavaDocLine(" */");
        }
        //添加注解
        if (field.isTransient()) {
            //@Column
            field.addAnnotation("@Transient");
        }
        for (IntrospectedColumn column : introspectedTable.getPrimaryKeyColumns()) {
            if (introspectedColumn == column) {
                field.addAnnotation("@Id");
                break;
            }
        }
        String column = introspectedColumn.getActualColumnName();
        if (StringUtility.stringContainsSpace(column) || introspectedTable.getTableConfiguration().isAllColumnDelimitingEnabled()) {
            column = introspectedColumn.getContext().getBeginningDelimiter()
                    + column
                    + introspectedColumn.getContext().getEndingDelimiter();
        }
        if (!column.equals(introspectedColumn.getJavaProperty())) {
            //@Column
            field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
        } else if (StringUtility.stringHasValue(beginningDelimiter) || StringUtility.stringHasValue(endingDelimiter)) {
            field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
        } else if (forceAnnotation) {
            field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
        }
        if (introspectedColumn.isIdentity()) {
            if ("JDBC".equals(introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement())) {
                field.addAnnotation("@GeneratedValue(generator = \"JDBC\")");
            } else {
                field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY)");
            }
        } else if (introspectedColumn.isSequenceColumn()) {
            //在 Oracle 中，如果需要是 SEQ_TABLENAME，那么可以配置为 select SEQ_{1} from dual
            String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
            String sql = MessageFormat.format(introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement(), tableName, tableName.toUpperCase());
            field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY, generator = \"" + sql + "\")");
        }
        // region swagger注解
        if (this.needsSwagger) {
            String remarks = introspectedColumn.getRemarks();
            if (remarks == null) {
                remarks = "";
            }
            String swaggerAnnotation = "@ApiModelProperty(value = \"%s\" da )";
            field.addAnnotation("@ApiModelProperty(\"" + remarks.replaceAll("\r", "").replaceAll("\n", "") + "\")");
        }
        // endregion
    }
1292558
function re_treeSortRows(field, sortType) {
    var oThis = this;
    var spliceHasParentRows = new Array();
    this.rows = new Array();
    this.hasParentRows = new Array();
    this.nothasParentRows = new Array();
    if (this.options.values) {
        $.each(this.options.values, function (i) {
            var rowObj = {};
            var $this = $(this);
            var keyField = oThis.gridComp.options.keyField;
            var parentKeyField = oThis.gridComp.options.parentKeyField;
            var keyValue = oThis.gridComp.getString($this.attr(keyField), '');
            var parentKeyValue = oThis.gridComp.getString($this.attr(parentKeyField), '');
            rowObj.valueIndex = i;
            rowObj.value = this;
            rowObj.keyValue = keyValue;
            rowObj.parentKeyValue = parentKeyValue;
            if (parentKeyValue == '') {
                oThis.nothasParentRows.push(rowObj);
            } else {
                oThis.hasParentRows.push(rowObj);
            }
            oThis.rows.push(rowObj);
        });
        // 判断存在父项的数据的父项是否真正存在
        $.each(this.hasParentRows, function (i) {
            var parentKeyValue = this.parentKeyValue;
            var hasParent = false;
            $.each(oThis.rows, function () {
                if (this.keyValue == parentKeyValue) {
                    hasParent = true;
                }
            });
            if (!hasParent) {
                spliceHasParentRows.push(this);
                oThis.nothasParentRows.push(this);
            }
        });
        $.each(spliceHasParentRows, function () {
            var index = oThis.hasParentRows.indexOf(this);
            oThis.hasParentRows.splice(index, 1);
        });
        oThis.rows = new Array();
        var level = 0;
        // 遍历nothasParentRows，将子项加入rows
        $.each(this.nothasParentRows, function (i) {
            this.level = level;
            oThis.rows.push(this);
            oThis.pushChildRows(this, level);
        });
    }
}
967838
public static <F extends PField> MappedField<F> withColumn(F field) {
        return new MappedField<>(field.getName(), field);
    }
224008
public function getCMSFields()
    {
        // PHP 5.3 only
        $self = $this;
        $this->beforeUpdateCMSFields(function (FieldList $fields) use ($self) {
            $fields->removeFieldsFromTab(
                'Root.Main',
                array('KeyValuePairs', 'SortBy', 'SortByDirection')
            );
            // Don't put the GridField for documents in until the set has been created
            if (!$self->isInDB()) {
                $fields->addFieldToTab(
                    'Root.Main',
                    LiteralField::create(
                        'GridFieldNotice',
                        '<p class="message warning">' . _t(
                            'DMSDocumentSet.GRIDFIELD_NOTICE',
                            'Managing documents will be available once you have created this document set.'
                        ) . '</p>'
                    ),
                    'Title'
                );
            } else {
                $fields->removeByName('DocumentSetSort');
                // Document listing
                $gridFieldConfig = GridFieldConfig::create()
                    ->addComponents(
                        new GridFieldButtonRow('before'),
                        new GridFieldToolbarHeader(),
                        new GridFieldFilterHeader(),
                        new GridFieldSortableHeader(),
                        new GridFieldDataColumns(),
                        new DMSGridFieldEditButton(),
                        // Special delete dialog to handle custom behaviour of unlinking and deleting
                        new GridFieldDeleteAction(true),
                        new GridFieldDetailForm()
                    );

                if (class_exists('GridFieldPaginatorWithShowAll')) {
                    $paginatorComponent = new GridFieldPaginatorWithShowAll(15);
                } else {
                    $paginatorComponent = new GridFieldPaginator(15);
                }
                $gridFieldConfig->addComponent($paginatorComponent);

                if (class_exists('GridFieldSortableRows')) {
                    $gridFieldConfig->addComponent(new GridFieldSortableRows('DocumentSort'));
                } elseif (class_exists('GridFieldOrderableRows')) {
                    $gridFieldConfig->addComponent(new GridFieldOrderableRows('DocumentSort'));
                }

                // Don't show which page this is if we're already editing within a page context
                if (Controller::curr() instanceof CMSPageEditController) {
                    $fields->removeByName('PageID');
                } else {
                    $fields->fieldByName('Root.Main.PageID')->setTitle(_t('DMSDocumentSet.SHOWONPAGE', 'Show on page'));
                }

                // Don't show which page this is if we're already editing within a page context
                if (Controller::curr() instanceof CMSPageEditController) {
                    $fields->removeByName('PageID');
                } else {
                    $fields->fieldByName('Root.Main.PageID')->setTitle(_t('DMSDocumentSet.SHOWONPAGE', 'Show on page'));
                }

                $gridFieldConfig->getComponentByType('GridFieldDataColumns')
                    ->setDisplayFields($self->getDocumentDisplayFields())
                    ->setFieldCasting(array('LastEdited' => 'Datetime->Ago'))
                    ->setFieldFormatting(
                        array(
                            'FilenameWithoutID' => '<a target=\'_blank\' class=\'file-url\''
                                . ' href=\'$Link\'>$FilenameWithoutID</a>',
                            'ManuallyAdded' => function ($value) {
                                if ($value) {
                                    return _t('DMSDocumentSet.MANUAL', 'Manually');
                                }
                                return _t('DMSDocumentSet.QUERYBUILDER', 'Query Builder');
                            }
                        )
                    );

                // Override delete functionality with this class
                $gridFieldConfig->getComponentByType('GridFieldDetailForm')
                    ->setItemRequestClass('DMSGridFieldDetailForm_ItemRequest');
                $gridField = GridField::create(
                    'Documents',
                    false,
                    $self->Documents(),
                    $gridFieldConfig
                );
                $gridField->setModelClass('DMSDocument');
                $gridField->addExtraClass('documents');

                $gridFieldConfig->addComponent(
                    $addNewButton = new DMSGridFieldAddNewButton('buttons-before-left'),
                    'GridFieldExportButton'
                );
                $addNewButton->setDocumentSetId($self->ID);

                $fields->removeByName('Documents');
                $fields->addFieldsToTab(
                    'Root.Main',
                    array(
                        $gridField,
                        HiddenField::create('DMSShortcodeHandlerKey', false, DMS::inst()->getShortcodeHandlerKey())
                    )
                );
                $self->addQueryFields($fields);
            }
        });
        $this->addRequirements();
        return parent::getCMSFields();
    }
1191810
private static void doFieldMapping(BeanMappingParam param, BeanMappingField beanField, BatchObjectHolder holder) {
        // 定义valueContext
        ValueProcessContext valueContext = new ValueProcessContext(param, param.getConfig(), beanField, holder,
                                                                   param.getCustomValueContext());
        // 设置getExecutor
        GetExecutor getExecutor = beanField.getGetExecutor();// 优先从beanField里取
        if (getExecutor == null && StringUtils.isNotEmpty(beanField.getSrcField().getName())) {// 如果不为空,可能存在script
            Class locatorClass = beanField.getSrcField().getLocatorClass();// 从locatorClass中获取
            if (locatorClass == null) {
                locatorClass = param.getSrcRef().getClass();
                beanField.getSrcField().setLocatorClass(locatorClass);
            }
            getExecutor = Uberspector.getInstance().getGetExecutor(locatorClass, beanField.getSrcField().getName());
            beanField.setGetExecutor(getExecutor);
        }
        // 设置setExecutor
        SetExecutor setExecutor = beanField.getSetExecutor();// 优先从beanField里取
        if (setExecutor == null && StringUtils.isNotEmpty(beanField.getTargetField().getName())) {
            Class locatorClass = beanField.getTargetField().getLocatorClass();// 从locatorClass中获取
            if (locatorClass == null) {
                locatorClass = param.getTargetRef().getClass();
                beanField.getTargetField().setLocatorClass(locatorClass);
            }
            setExecutor = Uberspector.getInstance().getSetExecutor(locatorClass, beanField.getTargetField().getName(),
                                                                   beanField.getTargetField().getClazz());
            beanField.setSetExecutor(setExecutor);

        }

        // 获取get结果
        ValueProcessInvocation invocation = new ValueProcessInvocation(getExecutor, setExecutor, valueContext,
                                                                       param.getProcesses());
        Object getResult = invocation.getInitialValue();
        // 设置下srcClass
        Class getResultClass = (getResult != null) ? getResult.getClass() : null;
        if (getExecutor != null && beanField.getSrcField().getClazz() == null) {
            beanField.getSrcField().setClazz(
                                             Uberspector.getInstance().getGetClass(getExecutor,
                                                                                   param.getSrcRef().getClass(),
                                                                                   getResultClass));
        }

        // 设置下targetClass
        if (setExecutor != null && beanField.getTargetField().getClazz() == null) {
            beanField.getTargetField().setClazz(
                                                Uberspector.getInstance().getSetClass(setExecutor,
                                                                                      param.getTargetRef().getClass(),
                                                                                      getResultClass));
        }
        // 开始ValueProcess流程
        invocation.proceed(getResult);
    }
369357
public void addField(String label,Element field)
    {
        if (label==null)
            label="&nbsp;";
        else
            label="<b>"+label+":</b>";

        if (extendRow)
        {
            column.add(field);
            extendRow=false;
        }
        else
        {
            column.newRow();
            column.addCell(label);
            column.cell().right();
        
            if (fieldAttributes != null)
            {
                column.addCell(field,fieldAttributes);
                fieldAttributes = null;
            }
            else
                column.addCell(field);
        }
    }