home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / SoldToPanel.java < prev    next >
Text File  |  1997-07-30  |  4KB  |  112 lines

  1.  
  2. package borland.samples.intl.gui;
  3.  
  4. import java.awt.*;
  5. import java.awt.event.*;
  6. import java.util.*;
  7. import borland.jbcl.layout.*;
  8. import borland.jbcl.control.*;
  9.  
  10. import borland.samples.intl.application.*;
  11. import borland.samples.intl.beans.event.*;
  12.  
  13. public class SoldToPanel extends BevelPanel implements LocaleChangeListener {
  14.   private AppDataModule appDataModule = AppDataModule.getDataModule();
  15.  
  16.   LabelControl customerNoLabel = new LabelControl();
  17.   LabelControl customerNoField = new LabelControl();
  18.   BevelPanel customerNoPanel = new BevelPanel();
  19.   BorderLayout borderLayout1 = new BorderLayout();
  20.   InterchangeableCustomerInfoPanel customerInfoPanel;
  21.   ButtonControl lookupCustomerButton = new ButtonControl();
  22.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  23.   GridBagLayout gridBagLayout2 = new GridBagLayout();
  24.   static ResourceBundle textRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes");
  25.   static ResourceBundle guiRes = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.GuiRes");
  26.  
  27.   public SoldToPanel() {
  28.     try {
  29.       jbInit();
  30.     }
  31.     catch (Exception e) {
  32.       e.printStackTrace();
  33.     }
  34.   }
  35.  
  36.   public void jbInit() throws Exception{
  37.     lookupCustomerButton.setLabel(textRes.getString("Find_customer"));
  38.     lookupCustomerButton.addActionListener(new SoldToPanel_lookupCustomerButton_actionAdapter(this));
  39.     customerNoLabel.setText(textRes.getString("Customer_No"));
  40.     customerNoLabel.setAlignment(Label.RIGHT);
  41.     customerNoField.setDataSet(appDataModule.getCustomerDataSet());
  42.     customerNoField.setColumnName("customer_no");
  43.     customerNoField.setAlignment(Label.RIGHT);
  44.     customerNoPanel.setLayout(gridBagLayout2);
  45.     customerNoPanel.setBevelInner(BevelPanel.FLAT);
  46.     customerNoPanel.add(customerNoLabel, null);
  47.     customerNoPanel.add(customerNoField, null);
  48.     customerNoPanel.add(lookupCustomerButton, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
  49.             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  50.     customerNoPanel.add(customerNoLabel, new GridBagConstraints2(1, 0, 3, 1, 100.0, 0.0
  51.             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  52.     customerNoPanel.add(customerNoField, new GridBagConstraints2(4, 0, 1, 1, 0.0, 0.0
  53.             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
  54.     this.setLayout(borderLayout1);
  55.     customerInfoPanel = (InterchangeableCustomerInfoPanel) guiRes.getObject("SoldToCustomerInfoPanel");
  56.     this.add((Panel) customerInfoPanel, BorderLayout.CENTER);
  57.     this.add(customerNoPanel, BorderLayout.NORTH);
  58.  
  59.     LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
  60.   }
  61.  
  62.   
  63.   void lookupCustomerButton_actionPerformed(ActionEvent e) {
  64.      try {
  65.        Component component = this;
  66.        Frame frame = null;
  67.  
  68.        while ((component = component.getParent()) != null) {
  69.      if (component instanceof Frame) {
  70.        frame = (Frame) component;
  71.        break;
  72.      }
  73.        }
  74.  
  75.        if (frame == null) {
  76.      frame = new Frame();
  77.        }
  78.        CustomerLookupDialog customerLookupDialog = new CustomerLookupDialog(frame, true);
  79.        customerLookupDialog.show();
  80.        if (customerLookupDialog.isValidCustomer()) {
  81.      appDataModule.syncCustomerNoWithCurrentOrder();
  82.        }
  83.      } catch (Exception ex) {
  84.        borland.jbcl.util.Diagnostic.printStackTrace(ex);
  85.      }
  86.      
  87.   }
  88.  
  89.   public void localeChanged(LocaleChangeEvent e) {
  90.     textRes = ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes", e.getLocale());
  91.     guiRes = ResourceBundle.getBundle("borland.samples.intl.gui.resources.GuiRes", e.getLocale());
  92.     customerNoLabel.setText(textRes.getString("Customer_No"));
  93.     lookupCustomerButton.setLabel(textRes.getString("Find_customer"));
  94.     this.remove((Panel) customerInfoPanel);
  95.     customerInfoPanel = (InterchangeableCustomerInfoPanel) guiRes.getObject("SoldToCustomerInfoPanel");
  96.     this.add((Panel) customerInfoPanel, BorderLayout.CENTER);
  97.   }
  98.  
  99. }
  100.  
  101. class SoldToPanel_lookupCustomerButton_actionAdapter implements java.awt.event.ActionListener{
  102.   SoldToPanel adaptee;
  103.  
  104.   SoldToPanel_lookupCustomerButton_actionAdapter(SoldToPanel adaptee) {
  105.     this.adaptee = adaptee;
  106.   }
  107.  
  108.   public void actionPerformed(ActionEvent e) {
  109.     adaptee.lookupCustomerButton_actionPerformed(e);
  110.   }
  111. }
  112.