home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
CalcColumnFrame1.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
4KB
|
107 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.
*/
package borland.samples.tutorial.dataset.calccolumn;
import java.awt.*;
import java.awt.event.*;
import borland.jbcl.control.*;
import borland.jbcl.layout.*;
import borland.sql.dataset.*;
import borland.jbcl.dataset.*;
import borland.jbcl.util.*; // add this import statement
import java.math.BigDecimal;
import java.lang.*;
public class CalcColumnFrame1 extends DecoratedFrame {
BorderLayout borderLayout1 = new BorderLayout();
BevelPanel bevelPanel1 = new BevelPanel();
NavigatorControl navigatorControl1 = new NavigatorControl();
Database database1 = new Database();
QueryDataSet queryDataSet1 = new QueryDataSet();
GridControl gridControl1 = new GridControl();
Column column1 = new Column();
GridBagLayout gridBagLayout1 = new GridBagLayout();
//Construct the frame
public CalcColumnFrame1() {
try {
jbInit();
}
catch (Exception e) {
borland.jbcl.util.Diagnostic.printStackTrace(e);
};
}
//Component initialization
private void jbInit() throws Exception{
this.setLayout(borderLayout1);
this.setSize(new Dimension(483, 299));
this.setTitle("Calculated Columns Example");
navigatorControl1.setDataSet(queryDataSet1);
bevelPanel1.setLayout(gridBagLayout1);
database1.setConnection(new borland.sql.dataset.ConnectionDescriptor("jdbc:odbc:dataset tutorial", "sysdba", "masterkey", false, "sun.jdbc.odbc.JdbcOdbcDriver;borland.interclient.Driver"));
queryDataSet1.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "select * from employee", null, true, Load.ALL));
queryDataSet1.addCalcFieldsListener(new CalcColumnFrame1_queryDataSet1_calcFieldsAdapter(this));
gridControl1.setDataSet(queryDataSet1);
column1.setCalcType(borland.jbcl.dataset.CalcType.CALC);
column1.setCaption("NEW_SALARY");
column1.setColumnName("NEW_SALARY");
column1.setDataType(borland.jbcl.util.Variant.BIGDECIMAL);
column1.setDisplayMask("");
column1.setEditMask("");
column1.setExportDisplayMask("");
this.add(bevelPanel1, BorderLayout.CENTER);
bevelPanel1.add(navigatorControl1, new GridBagConstraints2(0, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), -9, 9));
bevelPanel1.add(gridControl1, new GridBagConstraints2(0, 1, 2, 1, 1.0, 1.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
queryDataSet1.setColumns(new Column[] {column1});
}
// Override getPreferredSize() to set initial frame size
public Dimension getPreferredSize()
{
return new Dimension(480, 300);
}
void queryDataSet1_calcFields(ReadRow readRow, DataRow dataRow, boolean boolean1)
throws DataSetException
{
dataRow.setBigDecimal("New_Salary", readRow.getBigDecimal("SALARY").multiply(new BigDecimal(1.1)));
}
}
class CalcColumnFrame1_queryDataSet1_calcFieldsAdapter implements borland.jbcl.dataset.CalcFieldsListener {
CalcColumnFrame1 adaptee;
CalcColumnFrame1_queryDataSet1_calcFieldsAdapter(CalcColumnFrame1 adaptee) {
this.adaptee = adaptee;
}
public void calcFields(ReadRow readRow, DataRow dataRow, boolean boolean1)
throws DataSetException
{
adaptee.queryDataSet1_calcFields(readRow, dataRow, boolean1);
}
}