home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 10.0 KB | 270 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.
- */
-
- //Title: Cliffhanger Adventure Gear
- //Version:
- //Copyright: Copyright (c) 1997 Borland International, Inc.
- //Author: Application Methods, Inc.
- //Description: Cliffhanger Adventure Gear order entry system
-
- package borland.reference.cliffhanger;
-
- import java.awt.*;
- import java.awt.event.*;
- import borland.jbcl.layout.*;
- import borland.jbcl.control.*;
- import borland.jbcl.dataset.*;
- import java.util.*;
-
- /**
- * FindFrame is the DecoratedFrame class that is used as a base class from
- * which the other Find forms are inherited. This find forms allows users
- * to lookup orders, customers, or products by searching on a value for
- * a single column in the respective dataset. A grid displays all the records
- * for the respective datasets, and the grid will try to find the closet
- * matching record as the user types in the search value.
- */
- public class FindFrame extends DecoratedFrame {
- private static FindFrame myFindFrame;
- BevelPanel bevelPanel1 = new BevelPanel();
- GridControl gridControl1 = new GridControl();
- ChoiceControl choiceControl1 = new ChoiceControl();
- LabelControl labelControl1 = new LabelControl();
- LabelControl labelControl2 = new LabelControl();
- BevelPanel bevelPanel2 = new BevelPanel();
- BevelPanel bevelPanel3 = new BevelPanel();
- ButtonControl btnClose = new ButtonControl();
- ButtonControl btnGoto = new ButtonControl();
- BorderLayout borderLayout2 = new BorderLayout();
- GridBagLayout gridBagLayout1 = new GridBagLayout();
- GridBagLayout gridBagLayout2 = new GridBagLayout();
- BorderLayout borderLayout3 = new BorderLayout();
- LocatorControl locatorControl1 = new LocatorControl();
- ResourceBundle res = Res.getBundle("borland.reference.cliffhanger.Res");
- BevelPanel bevelPanel4 = new BevelPanel();
- ImageControl imageControl1 = new ImageControl();
- GridBagLayout gridBagLayout3 = new GridBagLayout();
- StatusBar statusBar1 = new StatusBar();
-
- /**
- * The constructor is protected. Use the getFindFrame method to get
- * an instance of the class.
- */
- protected FindFrame() {
- try {
- jbInit();
- }
- catch (Exception e) {
- e.printStackTrace();
- };
- }
-
- /**
- * Method generated and maintained by JBuilder designer to initialize
- * control properties.
- */
- private void jbInit() throws Exception{
- this.setSize(new Dimension(500, 350));
- this.setTitle(res.getString("FF_Find"));
- this.addWindowListener(new FindFrame_this_windowAdapter(this));
- this.setExitOnClose(false);
- this.setLayout(borderLayout3);
- bevelPanel1.setLayout(borderLayout2);
- bevelPanel1.setBevelOuter(BevelPanel.FLAT);
- gridControl1.setDefaultColumnWidth(80);
- gridControl1.setFont(new Font("Dialog", 0, 12));
- gridControl1.setReadOnly(true);
- choiceControl1.addItemListener(new FindFrame_choiceControl1_itemAdapter(this));
- labelControl1.setText(res.getString("FF_Field"));
- labelControl2.setColumnName("");
- labelControl2.setText(res.getString("FF_Value"));
- bevelPanel2.setBevelInner(BevelPanel.FLAT);
- bevelPanel2.setBevelOuter(BevelPanel.FLAT);
- bevelPanel3.setBevelInner(BevelPanel.FLAT);
- bevelPanel3.setBevelOuter(BevelPanel.FLAT);
- locatorControl1.addKeyListener(new FindFrame_locatorControl1_keyAdapter(this));
- bevelPanel2.setLayout(gridBagLayout2);
- bevelPanel3.setLayout(gridBagLayout1);
- btnClose.setActionCommand("");
- btnClose.setLabel(res.getString("FF_Close"));
- btnClose.addActionListener(new FindFrame_btnClose_actionAdapter(this));
- btnGoto.setActionCommand("");
- btnGoto.setLabel(res.getString("FF_Go_To"));
- bevelPanel4.setBevelInner(BevelPanel.FLAT);
- imageControl1.setImageName(".\\graphics\\findBanner.jpg");
- statusBar1.setBevelOuter(BevelPanel.LOWERED);
- statusBar1.setFont(new Font("Dialog", 0, 10));
- bevelPanel4.setLayout(gridBagLayout3);
- btnGoto.addActionListener(new FindFrame_btnGoto_actionAdapter(this));
- this.add(bevelPanel1, BorderLayout.NORTH);
- bevelPanel1.add(bevelPanel2, BorderLayout.CENTER);
- bevelPanel2.add(choiceControl1, new GridBagConstraints2(1, 0, 2, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
- bevelPanel2.add(labelControl1, new GridBagConstraints2(0, 0, 1, 1, 10.0, 50.0
- ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 10, 1, 0), 0, 0));
- bevelPanel2.add(labelControl2, new GridBagConstraints2(0, 1, 1, 1, 10.0, 50.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 0), 0, 0));
- bevelPanel2.add(locatorControl1, new GridBagConstraints2(1, 1, 2, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 206, 0));
- bevelPanel1.add(bevelPanel3, BorderLayout.EAST);
- bevelPanel3.add(btnClose, new GridBagConstraints2(0, 0, 1, 1, 100.0, 100.0
- ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 10, 4, 4), 50, 0));
- bevelPanel3.add(btnGoto, new GridBagConstraints2(0, 1, 1, 1, 100.0, 100.0
- ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 10, 4, 4), 0, 0));
- bevelPanel1.add(bevelPanel4, BorderLayout.NORTH);
- bevelPanel4.add(imageControl1, new GridBagConstraints2(0, 0, 1, 1, 1.0, 1.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, -65));
- this.add(gridControl1, BorderLayout.CENTER);
- this.add(statusBar1, BorderLayout.SOUTH);
- }
-
- /**
- * Class method to access the singleton instance of the class
- */
- public static FindFrame getFindFrame() {
- if (myFindFrame == null)
- myFindFrame = new FindFrame();
-
- return myFindFrame;
- }
-
- /**
- * When the Go To button is clicked, the concrete Find forms should
- * override this event handler to show the appropriate form for the
- * record selected.
- */
- void btnGoto_actionPerformed(ActionEvent e) {
- }
-
- /**
- * The itemStateChanged event is triggered when the user selects a new
- * item off the choiceControl's drop down list of possible fields to
- * search on. Reset the text property of the locatorControl to be ready
- * for a new search value.
- */
- void choiceControl1_itemStateChanged(ItemEvent e) {
- locatorControl1.setText("");
- }
-
- /**
- * When the user types in the locatorControl, make sure that the ColumnName
- * property of the locatorControl is set to the column name selected in the
- * ChoiceControl.
- */
- void locatorControl1_keyPressed(KeyEvent e) {
- // Set the columnName property of the locatorControl
- // if it is not set.
- try {
- if ((locatorControl1.getColumnName() == null) ||
- (locatorControl1.getDataSet().getColumn(locatorControl1.getColumnName()).getCaption().compareTo(choiceControl1.getSelectedItem()) != 0)) {
- Column [] columns = locatorControl1.getDataSet().getColumns();
- for (int index = 0; index < columns.length; index++) {
- if (columns[index].getCaption().compareTo(choiceControl1.getSelectedItem()) == 0) {
- locatorControl1.setColumnName(columns[index].getColumnName());
- break;
- }
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * When Close button is clicked, call this frame's windowClosing
- * event handler to properly handle all dataset pending updates.
- */
- void btnClose_actionPerformed(ActionEvent e) {
- // Close the FindFrame
- this.this_windowClosing(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
- }
-
- /**
- * When closing the window, set visible property to false, and dispose of the
- * frame.
- */
- void this_windowClosing(WindowEvent e) {
- setVisible(false);
- dispose();
- }
-
- }
-
- class FindFrame_btnGoto_actionAdapter implements java.awt.event.ActionListener{
- FindFrame adaptee;
-
- FindFrame_btnGoto_actionAdapter(FindFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.btnGoto_actionPerformed(e);
- }
- }
-
- class FindFrame_choiceControl1_itemAdapter implements java.awt.event.ItemListener{
- FindFrame adaptee;
-
- FindFrame_choiceControl1_itemAdapter(FindFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void itemStateChanged(ItemEvent e) {
- adaptee.choiceControl1_itemStateChanged(e);
- }
- }
-
- class FindFrame_locatorControl1_keyAdapter extends java.awt.event.KeyAdapter {
- FindFrame adaptee;
-
- FindFrame_locatorControl1_keyAdapter(FindFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void keyPressed(KeyEvent e) {
- adaptee.locatorControl1_keyPressed(e);
- }
- }
-
- class FindFrame_this_windowAdapter extends java.awt.event.WindowAdapter {
- FindFrame adaptee;
-
- FindFrame_this_windowAdapter(FindFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void windowClosing(WindowEvent e) {
- adaptee.this_windowClosing(e);
- }
- }
-
- class FindFrame_btnClose_actionAdapter implements java.awt.event.ActionListener{
- FindFrame adaptee;
-
- FindFrame_btnClose_actionAdapter(FindFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.btnClose_actionPerformed(e);
- }
- }
-
-