home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 3.9 KB | 109 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * 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, 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.
- */
- //--------------------------------------------------------------------------------------------------
- // CORBA Reference Application
- // Copyright (c) 1997 by Borland International, All Rights Reserved
- //
- // Used to find columns that are required and are currently set to null.
- //
- // The functionality in this class could be incorporated into the
- // DataSet control OR a decendant of the DataSet.
- //--------------------------------------------------------------------------------------------------
-
- package borland.reference.creditapproval.client;
-
- import borland.jbcl.dataset.*;
- import java.awt.*;
- import borland.jbcl.control.*;
- import borland.jbcl.view.*;
-
-
- /**
- * FindMissingRequired looks at every column in the current row to make sure
- * that all required columns are not null.
- */
- public class FindMissingRequired {
-
- public FindMissingRequired() {
- }
-
- /**
- * Return the name of a null-required column. If all required columns have
- * values, return an empty string.
- */
- 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) {
- System.err.println(e);
- }
- }
- return null;
- }
-
- /**
- * Finds the Control associated with the specified column and
- * returns its reference.
- */
- 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 );
-
- // Recurse Containers
-
- if (component instanceof Container && !(component instanceof FieldView) ) {
- Component nested = FindMissingRequired.findColumnTextField( (Container ) component, columnName );
- if (nested != null ) return nested;
- else continue;
- }
- // If the control is capable of DB Access,
- // compare its column name to the search columnName
- else if (component instanceof TextFieldControl)
- associatedColumnName = ((TextFieldControl) component).getColumnName();
- else if (component instanceof TextAreaControl)
- associatedColumnName = ((TextAreaControl) component).getColumnName();
- else if (component instanceof ListControl)
- associatedColumnName = ((ListControl) component).getColumnName();
- else if (component instanceof FieldControl)
- associatedColumnName = ((FieldControl) component).getColumnName();
- else if (component instanceof ChoiceControl)
- associatedColumnName = ((ChoiceControl) component).getColumnName();
- else continue;
-
- if( associatedColumnName.equalsIgnoreCase(columnName)) return component;
- }
- return null;
- }
- }
-
-