home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / inprise / JSAMPLES.Z / CustomerInfoPanel_en_CA.java < prev    next >
Text File  |  1998-05-08  |  14KB  |  304 lines

  1. /*
  2.  * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
  3.  * 
  4.  * This SOURCE CODE FILE, which has been provided by Borland as part
  5.  * of a Borland product for use ONLY by licensed users of the product,
  6.  * includes CONFIDENTIAL and PROPRIETARY information of Borland.  
  7.  *
  8.  * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
  9.  * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
  10.  * THE PRODUCT.
  11.  *
  12.  * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
  13.  * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
  14.  * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
  15.  * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
  16.  * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
  17.  * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
  18.  * CODE FILE.
  19.  */
  20. package borland.samples.intl.gui.resources;
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.util.*;
  25. import borland.jbcl.layout.*;
  26. import borland.jbcl.control.*;
  27. import borland.jbcl.dataset.*;
  28.  
  29. import borland.samples.intl.application.*;
  30. import borland.samples.intl.beans.*;
  31. import borland.samples.intl.beans.event.*;
  32. import borland.samples.intl.gui.*;
  33.  
  34. /**
  35.  * CustomerInfoPanel for English Canadian address format.
  36.  */
  37. public class CustomerInfoPanel_en_CA extends Panel implements InterchangeableCustomerInfoPanel {
  38.   AppDataModule appDataModule = AppDataModule.getDataModule();
  39.  
  40.   FieldControl address1Field = new FieldControl();
  41.   FieldControl address2Field = new FieldControl();
  42.   FieldControl cityField = new FieldControl();
  43.   FieldControl countryField = new FieldControl();
  44.   FieldControl emailField = new FieldControl();
  45.   FieldControl faxField = new FieldControl();
  46.   FieldControl firstNameField = new FieldControl();
  47.   FieldControl lastNameField = new FieldControl();
  48.   FieldControl middleNameField = new FieldControl();
  49.   FieldControl phoneField = new FieldControl();
  50.   FieldControl postalCodeField = new FieldControl();
  51.   FieldControl provinceField = new FieldControl();
  52.  
  53.   LabelControl address1Label = new LabelControl();
  54.   LabelControl address2Label = new LabelControl();
  55.   LabelControl cityLabel = new LabelControl();
  56.   LabelControl countryLabel = new LabelControl();
  57.   LabelControl emailLabel = new LabelControl();
  58.   LabelControl faxLabel = new LabelControl();
  59.   LabelControl firstNameLabel = new LabelControl();
  60.   LabelControl lastNameLabel = new LabelControl();
  61.   LabelControl middleNameLabel = new LabelControl();
  62.   LabelControl phoneLabel = new LabelControl();
  63.   LabelControl postalCodeLabel = new LabelControl();
  64.   LabelControl provinceLabel = new LabelControl();
  65.  
  66.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  67.   GridBagLayout gridBagLayout2 = new GridBagLayout();
  68.   GridBagLayout gridBagLayout3 = new GridBagLayout();
  69.   GridBagLayout gridBagLayout4 = new GridBagLayout();
  70.   GridBagLayout gridBagLayout5 = new GridBagLayout();
  71.   GridBagLayout gridBagLayout6 = new GridBagLayout();
  72.  
  73.   BevelPanel bevelPanel1 = new BevelPanel();
  74.   BevelPanel bevelPanel2 = new BevelPanel();
  75.   BevelPanel bevelPanel3 = new BevelPanel();
  76.   BevelPanel bevelPanel4 = new BevelPanel();
  77.   BevelPanel bevelPanel5 = new BevelPanel();
  78.   BevelPanel bevelPanel6 = new BevelPanel();
  79.  
  80.   GridLayout gridLayout1 = new GridLayout();
  81.  
  82.   ResourceBundle textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes",
  83.                                                               LocaleChangeManager.getLocale());
  84.  
  85.   public CustomerInfoPanel_en_CA() {
  86.     try {
  87.       jbInit();
  88.     }
  89.     catch (Exception e) {
  90.       e.printStackTrace();
  91.     }
  92.   }
  93.  
  94.   public void jbInit() throws Exception{
  95.  
  96.     firstNameLabel.setAlignment(Label.RIGHT);
  97.     firstNameLabel.setText(textRes.getString("first_name"));
  98.  
  99.     firstNameField.setColumnName("first_name");
  100.     firstNameField.setDataSet(appDataModule.getCustomerDataSet());
  101.  
  102.     lastNameLabel.setAlignment(Label.RIGHT);
  103.     lastNameLabel.setText(textRes.getString("last_name"));
  104.  
  105.     lastNameField.setColumnName("last_name");
  106.     lastNameField.setDataSet(appDataModule.getCustomerDataSet());
  107.  
  108.     bevelPanel1.setBevelInner(BevelPanel.FLAT);
  109.     bevelPanel1.setLayout(gridBagLayout1);
  110.     bevelPanel1.add(firstNameLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  111.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  112.     bevelPanel1.add(firstNameField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  113.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  114.     bevelPanel1.add(lastNameLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  115.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  116.     bevelPanel1.add(lastNameField, new GridBagConstraints2(5, 0, 3, 1, 50.0, 0.0
  117.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  118.     this.add(bevelPanel1, null);
  119.  
  120.     address1Label.setAlignment(Label.RIGHT);
  121.     address1Label.setText(textRes.getString("address1"));
  122.  
  123.     address1Field.setColumnName("address1");
  124.     address1Field.setDataSet(appDataModule.getCustomerDataSet());
  125.  
  126.     bevelPanel2.setBevelInner(BevelPanel.FLAT);
  127.     bevelPanel2.setLayout(gridBagLayout2);
  128.     bevelPanel2.add(address1Label, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  129.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  130.     bevelPanel2.add(address1Field, new GridBagConstraints2(1, 0, 4, 1, 100.0, 0.0
  131.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  132.     this.add(bevelPanel2, null);
  133.  
  134.     cityLabel.setAlignment(Label.RIGHT);
  135.     cityLabel.setText(textRes.getString("city"));
  136.  
  137.     cityField.setColumnName("city");
  138.     cityField.setDataSet(appDataModule.getCustomerDataSet());
  139.  
  140.     provinceLabel.setAlignment(Label.RIGHT);
  141.     provinceLabel.setText(textRes.getString("province"));
  142.  
  143.     provinceField.setColumnName("province");
  144.     provinceField.setDataSet(appDataModule.getCustomerDataSet());
  145.  
  146.     postalCodeLabel.setAlignment(Label.RIGHT);
  147.     postalCodeLabel.setText(textRes.getString("postal_code"));
  148.  
  149.     postalCodeField.setColumnName("postal_code");
  150.     postalCodeField.setDataSet(appDataModule.getCustomerDataSet());
  151.  
  152.     bevelPanel3.setBevelInner(BevelPanel.FLAT);
  153.     bevelPanel3.setLayout(gridBagLayout3);
  154.     bevelPanel3.add(cityLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  155.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  156.     bevelPanel3.add(cityField, new GridBagConstraints2(1, 0, 3, 1, 45.0, 0.0
  157.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  158.     bevelPanel3.add(provinceLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  159.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  160.     bevelPanel3.add(provinceField, new GridBagConstraints2(5, 0, 3, 1, 45.0, 0.0
  161.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  162.     bevelPanel3.add(postalCodeLabel, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
  163.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  164.     bevelPanel3.add(postalCodeField, new GridBagConstraints2(9, 0, 2, 1, 10.0, 0.0
  165.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  166.     this.add(bevelPanel3, null);
  167.  
  168.     countryLabel.setAlignment(Label.RIGHT);
  169.     countryLabel.setText(textRes.getString("country"));
  170.  
  171.     countryField.setColumnName("country");
  172.     countryField.setDataSet(appDataModule.getCustomerDataSet());
  173.  
  174.     bevelPanel4.setBevelInner(BevelPanel.FLAT);
  175.     bevelPanel4.setLayout(gridBagLayout4);
  176.     bevelPanel4.add(countryLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  177.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  178.     bevelPanel4.add(countryField, new GridBagConstraints2(1, 0, 4, 1, 100.0, 0.0
  179.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  180.     this.add(bevelPanel4, null);
  181.  
  182.     phoneLabel.setAlignment(Label.RIGHT);
  183.     phoneLabel.setText(textRes.getString("phone"));
  184.  
  185.     phoneField.setColumnName("phone");
  186.     phoneField.setDataSet(appDataModule.getCustomerDataSet());
  187.  
  188.     faxLabel.setAlignment(Label.RIGHT);
  189.     faxLabel.setText(textRes.getString("fax"));
  190.  
  191.     faxField.setColumnName("fax");
  192.     faxField.setDataSet(appDataModule.getCustomerDataSet());
  193.  
  194.     bevelPanel5.setBevelInner(BevelPanel.FLAT);
  195.     bevelPanel5.setLayout(gridBagLayout5);
  196.     bevelPanel5.add(phoneLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  197.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  198.     bevelPanel5.add(phoneField, new GridBagConstraints2(1, 0, 3, 1, 50.0, 0.0
  199.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  200.     bevelPanel5.add(faxLabel, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  201.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  202.     bevelPanel5.add(faxField, new GridBagConstraints2(5, 0, 3, 1, 50.0, 0.0
  203.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  204.     this.add(bevelPanel5, null);
  205.  
  206.     emailLabel.setAlignment(Label.RIGHT);
  207.     emailLabel.setText(textRes.getString("e_mail"));
  208.  
  209.     emailField.setColumnName("e_mail");
  210.     emailField.setDataSet(appDataModule.getCustomerDataSet());
  211.  
  212.     bevelPanel6.setBevelInner(BevelPanel.FLAT);
  213.     bevelPanel6.setLayout(gridBagLayout6);
  214.     bevelPanel6.add(emailLabel, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  215.             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
  216.     bevelPanel6.add(emailField, new GridBagConstraints2(1, 0, 4, 1, 100.0, 0.0
  217.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  218.     this.add(bevelPanel6, null);
  219.  
  220.     gridLayout1.setRows(6);
  221.     gridLayout1.setColumns(1);
  222.     this.setLayout(gridLayout1);
  223.  
  224.   }
  225.  
  226.   public void setDataSet(DataSet dataSet) {
  227.     address1Field.setDataSet(dataSet);
  228.     address2Field.setDataSet(dataSet);
  229.     cityField.setDataSet(dataSet);
  230.     countryField.setDataSet(dataSet);
  231.     emailField.setDataSet(dataSet);
  232.     faxField.setDataSet(dataSet);
  233.     firstNameField.setDataSet(dataSet);
  234.     lastNameField.setDataSet(dataSet);
  235.     middleNameField.setDataSet(dataSet);
  236.     phoneField.setDataSet(dataSet);
  237.     postalCodeField.setDataSet(dataSet);
  238.     provinceField.setDataSet(dataSet);
  239.   }
  240.  
  241.   public void setReadOnly(boolean readOnly) {
  242.  
  243.     address1Field.setReadOnly(readOnly);
  244.     address2Field.setReadOnly(readOnly);
  245.     cityField.setReadOnly(readOnly);
  246.     countryField.setReadOnly(readOnly);
  247.     emailField.setReadOnly(readOnly);
  248.     faxField.setReadOnly(readOnly);
  249.     firstNameField.setReadOnly(readOnly);
  250.     lastNameField.setReadOnly(readOnly);
  251.     middleNameField.setReadOnly(readOnly);
  252.     phoneField.setReadOnly(readOnly);
  253.     postalCodeField.setReadOnly(readOnly);
  254.     provinceField.setReadOnly(readOnly);
  255.  
  256.     if (readOnly) {
  257.       address1Field.setBackground(SystemColor.control);
  258.       address2Field.setBackground(SystemColor.control);
  259.       cityField.setBackground(SystemColor.control);
  260.       countryField.setBackground(SystemColor.control);
  261.       emailField.setBackground(SystemColor.control);
  262.       faxField.setBackground(SystemColor.control);
  263.       firstNameField.setBackground(SystemColor.control);
  264.       lastNameField.setBackground(SystemColor.control);
  265.       middleNameField.setBackground(SystemColor.control);
  266.       phoneField.setBackground(SystemColor.control);
  267.       postalCodeField.setBackground(SystemColor.control);
  268.       provinceField.setBackground(SystemColor.control);
  269.     } else {
  270.       address1Field.setBackground(SystemColor.window);
  271.       address2Field.setBackground(SystemColor.window);
  272.       cityField.setBackground(SystemColor.window);
  273.       countryField.setBackground(SystemColor.window);
  274.       emailField.setBackground(SystemColor.window);
  275.       faxField.setBackground(SystemColor.window);
  276.       firstNameField.setBackground(SystemColor.window);
  277.       lastNameField.setBackground(SystemColor.window);
  278.       middleNameField.setBackground(SystemColor.window);
  279.       phoneField.setBackground(SystemColor.window);
  280.       postalCodeField.setBackground(SystemColor.window);
  281.       provinceField.setBackground(SystemColor.window);
  282.     }
  283.   }
  284.  
  285.   public void localeChanged(LocaleChangeEvent e) {
  286.     textRes = ResourceBundle.getBundle("borland.samples.intl.application.resources.TextRes", e.getLocale());
  287.     address1Label.setText(textRes.getString("address1"));
  288.     address2Label.setText(textRes.getString("address2"));
  289.     cityLabel.setText(textRes.getString("city"));
  290.     countryLabel.setText(textRes.getString("country"));
  291.     emailLabel.setText(textRes.getString("e_mail"));
  292.     faxLabel.setText(textRes.getString("fax"));
  293.     firstNameLabel.setText(textRes.getString("first_name"));
  294.     lastNameLabel.setText(textRes.getString("last_name"));
  295.     middleNameLabel.setText(textRes.getString("middle_name"));
  296.     phoneLabel.setText(textRes.getString("phone"));
  297.     postalCodeLabel.setText(textRes.getString("postal_code"));
  298.     provinceLabel.setText(textRes.getString("province"));
  299.   }
  300.  
  301. }
  302.  
  303.  
  304.