📄 findmissingrequired.java
字号:
/**
* Copyright (c) 1996-2004 Borland Software Corporation. All Rights Reserved.
*
* This SOURCE CODE FILE, which has been provided by Borland Software as part
* of a Borland Software product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of Borland Software.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND SOFTWARE, ITS
* RELATED COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY
* CLAIMS OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR
* DISTRIBUTION OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES
* ARISING OUT OF OR RESULTING FROM THE USE, MODIFICATION, OR
* DISTRIBUTION OF PROGRAMS OR FILES CREATED FROM, BASED ON, AND/OR
* DERIVED FROM THIS SOURCE CODE FILE.
*/
//------------------------------------------------------------------------------
// Copyright (c) 1996-2004 Borland Software Corporation. All Rights Reserved.
//------------------------------------------------------------------------------
package com.borland.samples.creditapproval.client;
import java.awt.*;
import com.borland.dx.dataset.*;
/**
* FindMissingRequired provides a couple of useful static methods:
*<UL>
*<LI>missingColumn - returns the first required Column of a given DataSet which
* has not been assigned a value.
*<LI>findColumnTextField - given an Container and Column name, returns the
* data-aware text-entry component bound to that column within the container.
*</UL>
*/
public class FindMissingRequired {
/**
* Returns the first required Column of the specified DataSet which is null.
* If all required columns have values, returns null.
* @param dataSet DataSet
* @return Column
*/
public static Column missingColumn(DataSet dataSet) {
int columnCount;
String missingColumn = "";
Column column;
columnCount = dataSet.getColumnCount();
for (int loop = 0; loop < columnCount; loop++) {
try {
column = dataSet.getColumn(loop);
if (column.isRequired() && (dataSet.isNull(loop) || dataSet.isAssignedNull(loop))) {
return column;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
/**
* Returns the data-aware text-entry component bound to the given Column name within
* the given container or null if one cannot be found.
* @param columnName String
* @param container Container
* @return Component
*/
public static Component findColumnTextField(Container container, String columnName) {
int controlCount = container.getComponentCount();
String associatedColumnName = null;
Component component;
for (int loop = 0; loop < controlCount; loop++) {
component = container.getComponent(loop);
// If the control is capable of DB Access,
// compare its column name to the search columnName
if (component instanceof ColumnAware) {
associatedColumnName = ((ColumnAware) component).getColumnName();
if (associatedColumnName != null &&
associatedColumnName.equalsIgnoreCase(columnName)) {
return component;
}
}
else { // Recurse Containers
if (component instanceof Container) {
Component nested = FindMissingRequired.findColumnTextField((Container) component, columnName);
if (nested != null) {
return nested;
}
}
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -