home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
AggCalc_Frame.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
4KB
|
96 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.aggcalc;
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.*;
public class AggCalc_Frame extends DecoratedFrame {
BorderLayout borderLayout1 = new BorderLayout();
BevelPanel bevelPanel1 = new BevelPanel();
Database database1 = new Database();
QueryDataSet queryDataSet1 = new QueryDataSet();
GridControl gridControl1 = new GridControl();
TextFieldControl textFieldControl1 = new TextFieldControl();
Column column1 = new Column();
LabelControl labelControl1 = new LabelControl();
Column column2 = new Column();
Column column3 = new Column();
BorderLayout borderLayout2 = new BorderLayout();
BevelPanel bevelPanel2 = new BevelPanel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
Column column4 = new Column();
//Construct the frame
public AggCalc_Frame() {
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(540, 359));
this.setTitle("Aggregate Calculated Column");
bevelPanel1.setLayout(borderLayout2);
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 cust_no, PO_NUMBER, SHIP_DATE , TOTAL_VALUE from sales", null, true, Load.ALL));
gridControl1.setDataSet(queryDataSet1);
gridControl1.setPreferredSize(new Dimension(400, 500));
textFieldControl1.setColumnName("GROUP_TOTAL");
textFieldControl1.setDataSet(queryDataSet1);
this.add(bevelPanel1, BorderLayout.CENTER);
bevelPanel1.add(gridControl1, BorderLayout.NORTH);
this.add(bevelPanel2, BorderLayout.SOUTH);
bevelPanel2.add(labelControl1, new GridBagConstraints2(0, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
bevelPanel2.add(textFieldControl1, new GridBagConstraints2(1, 0, 1, 1, 2.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
column1.setCalcType(borland.jbcl.dataset.CalcType.AGGREGATE);
column1.setCaption("GROUP_TOTAL");
column1.setColumnName("GROUP_TOTAL");
column1.setDataType(borland.jbcl.util.Variant.BIGDECIMAL);
column1.setAgg(new AggDescriptor(new String[] { "cust_no" }, "TOTAL_VALUE",
new SumAggOperator()));
labelControl1.setText("Customer Total Sales:");
column2.setColumnName("PO_NUMBER");
column2.setDataType(borland.jbcl.util.Variant.STRING);
column3.setColumnName("CUST_NO");
column3.setDataType(borland.jbcl.util.Variant.INT);
column4.setColumnName("SHIP_DATE");
column4.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
bevelPanel2.setLayout(gridBagLayout1);
queryDataSet1.setColumns(new Column[] {column1, column3, column2, column4});
}
}