home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-30 | 11.9 KB | 294 lines |
- package borland.samples.intl.gui;
-
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- import borland.jbcl.layout.*;
- import borland.jbcl.control.*;
- import borland.jbcl.view.*;
- import borland.jbcl.util.*;
-
- import borland.samples.intl.application.*;
- import borland.samples.intl.beans.*;
- import borland.samples.intl.beans.event.*;
-
- public class ProductFrame extends DecoratedFrame implements LocaleChangeListener{
- private static ProductFrame productFrame = null;
-
- GridBagLayout gridBagLayout1 = new GridBagLayout();
- GridBagLayout gridBagLayout2 = new GridBagLayout();
- GridBagLayout gridBagLayout3 = new GridBagLayout();
-
- GridLayout gridLayout1 = new GridLayout();
- GridLayout gridLayout2 = new GridLayout();
- GridLayout gridLayout3 = new GridLayout();
-
- XYLayout xYLayout1 = new XYLayout();
-
- ViewOnlyNavigationBar viewOnlyNavigationBar = new ViewOnlyNavigationBar();
-
- CheckboxPanel checkboxPanel1 = new CheckboxPanel();
-
- BevelPanel bevelPanel1 = new BevelPanel();
- BevelPanel bevelPanel2 = new BevelPanel();
- BevelPanel bevelPanel3 = new BevelPanel();
- BevelPanel bevelPanel4 = new BevelPanel();
- BevelPanel bevelPanel5 = new BevelPanel();
- BevelPanel bevelPanel6 = new BevelPanel();
-
- LabelControl labelControl1 = new LabelControl();
- LabelControl labelControl2 = new LabelControl();
- LabelControl labelControl4 = new LabelControl();
- FieldControl fieldControl1 = new FieldControl();
- FieldControl fieldControl2 = new FieldControl();
- WrappingTextViewer wrappingTextViewer1 = new WrappingTextViewer();
- LabelControl labelControl6 = new LabelControl();
- ImageControl imageControl1 = new ImageControl();
- ButtonControl buttonControl1 = new ButtonControl();
- ButtonControl buttonControl2 = new ButtonControl();
- ButtonControl buttonControl3 = new ButtonControl();
-
- private static AppDataModule appDataModule = AppDataModule.getDataModule();
- ResourceBundle textRes = ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes");
-
- public static ProductFrame getInstance() {
- if (productFrame == null) {
- productFrame = new ProductFrame();
- productFrame.pack();
- //Center the window
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = productFrame.getPreferredSize();
- if (frameSize.height > screenSize.height)
- frameSize.height = screenSize.height;
- if (frameSize.width > screenSize.width)
- frameSize.width = screenSize.width;
- productFrame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
- productFrame.setSize(frameSize.width + 10, frameSize.height + 10);
- }
- return productFrame;
- }
-
- protected ProductFrame() {
- try {
- jbInit();
- LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
- }
- catch (Exception e) {
- borland.jbcl.util.Diagnostic.printStackTrace(e);
- };
- }
-
- void jbInit() throws Exception{
- this.setLayout(gridBagLayout2);
-
- this.add(labelControl1, new GridBagConstraints2(0, 0, 3, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
-
- this.add(checkboxPanel1, new GridBagConstraints2(0, 1, 3, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
-
- xYLayout1.setWidth(200);
- xYLayout1.setHeight(200);
- bevelPanel1.setLayout(xYLayout1);
- bevelPanel1.add(imageControl1, new XYConstraints(0, 0, 200, 200));
- bevelPanel1.setEnabled(false);
-
- this.add(bevelPanel1, new GridBagConstraints2(2, 2, 1, 3, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
-
- bevelPanel2.setLayout(gridBagLayout1);
- bevelPanel2.setBevelInner(BevelPanel.FLAT);
- bevelPanel2.add(labelControl2, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- bevelPanel2.add(fieldControl2, new GridBagConstraints2(1, 0, 1, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- bevelPanel2.add(labelControl4, new GridBagConstraints2(0, 1, 1, 1, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- bevelPanel2.add(fieldControl1, new GridBagConstraints2(1, 1, 1, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- bevelPanel2.add(labelControl6, new GridBagConstraints2(0, 2, 2, 1, 100.0, 0.0
- ,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- bevelPanel2.add(wrappingTextViewer1, new GridBagConstraints2(0, 3, 2, 2, 100.0, 100.0
- ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-
- this.add(bevelPanel2, new GridBagConstraints2(0, 2, 2, 3, 100.0, 100.0
- ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-
- this.add(viewOnlyNavigationBar, new GridBagConstraints2(0, 5, 3, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
-
- bevelPanel4.setLayout(gridLayout1);
- gridLayout1.setRows(1);
- gridLayout1.setColumns(3);
- gridLayout1.setHgap(20);
- bevelPanel4.setMargins(new Insets(10, 10, 10, 10));
- bevelPanel4.add(buttonControl1, null);
- bevelPanel4.add(buttonControl2, null);
- bevelPanel4.add(buttonControl3, null);
-
- this.add(bevelPanel4, new GridBagConstraints2(0, 6, 3, 1, 100.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
-
- imageControl1.setDataSet(appDataModule.getProductsDataSet());
- imageControl1.setColumnName("image");
- imageControl1.setReadOnly(true);
-
- labelControl1.setFont(new Font("serif", 1, 24));
- labelControl1.setText(textRes.getString("The_Borland_Store"));
- labelControl1.setAlignment(Label.LEFT);
-
- checkboxPanel1.setOrientation(0);
- checkboxPanel1.setGrouped(true);
- checkboxPanel1.setLabels(new String[] {textRes.getString("All_Products"),
- textRes.getString("Software_Products"),
- textRes.getString("Deskware_Products"),
- textRes.getString("Bodyware_Products")});
- checkboxPanel1.setSelectedIndex(0);
- checkboxPanel1.addItemListener(new ProductFrame_checkboxPanel1_itemAdapter(this));
-
-
- labelControl2.setText(textRes.getString("Item_No"));
- fieldControl2.setColumnName("sku");
- fieldControl2.setDataSet(appDataModule.getProductsDataSet());
- fieldControl2.setReadOnly(true);
- fieldControl2.setEnabled(false);
- fieldControl2.setBackground(SystemColor.control);
- fieldControl2.setAlignment(Alignment.RIGHT);
- labelControl4.setText(textRes.getString("Unit_Price"));
- // labelControl5.setColumnName("unit_price");
- // labelControl5.setDataSet(appDataModule.getProductsDataSet());
- fieldControl1.setColumnName("unit_price");
- fieldControl1.setDataSet(appDataModule.getProductsDataSet());
- fieldControl1.setReadOnly(true);
- fieldControl1.setEnabled(false);
- fieldControl1.setAlignment(Alignment.RIGHT);
- fieldControl1.setBackground(SystemColor.control);
- labelControl6.setText(textRes.getString("Description"));
-
- buttonControl1.setLabel(textRes.getString("Add_to_Order"));
- buttonControl1.addActionListener(new ProductFrame_buttonControl1_actionAdapter(this));
- buttonControl2.setLabel(textRes.getString("View_Order"));
- buttonControl2.addActionListener(new ProductFrame_buttonControl2_actionAdapter(this));
- buttonControl3.setLabel(textRes.getString("Close"));
- buttonControl3.addActionListener(new ProductFrame_buttonControl3_actionAdapter(this));
-
-
- viewOnlyNavigationBar.setDataSet(appDataModule.getProductsDataSet());
-
- this.setTitle(textRes.getString("Borland_Store_Products"));
-
- wrappingTextViewer1.setColumnName("description");
- wrappingTextViewer1.setDataSet(appDataModule.getProductsDataSet());
-
- }
-
- protected void processWindowEvent(WindowEvent e) {
- if (e.getID() == WindowEvent.WINDOW_CLOSING) {
- this.setVisible(false);
- }
- }
-
- void checkboxPanel1_itemStateChanged(java.awt.event.ItemEvent e) {
- // filter products based upon the type of category
- if (e.getItem().equals(textRes.getString("All_Products"))) {
- // System.out.println("Setting NO_PRODUCT_FILTER");
- appDataModule.filterProducts(AppDataModule.NO_PRODUCT_FILTER);
- } else {
- // System.out.println("Setting filter on: " + checkboxPanel1.getSelectedIndex());
- appDataModule.filterProducts(checkboxPanel1.getSelectedIndex());
- }
- }
-
- void buttonControl1_actionPerformed(java.awt.event.ActionEvent e) {
- this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- WelcomeFrame.getInstance().setAllowOrderViewing(false);
- OrderFrame.getInstance().setBatchUpdateMode(true);
- appDataModule.addProductToOrderLineItem();
- OrderFrame.getInstance().setBatchUpdateMode(false);
- this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
-
- public void localeChanged(LocaleChangeEvent e) {
- textRes = ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes", e.getLocale());
- labelControl1.setText(textRes.getString("The_Borland_Store"));
-
- checkboxPanel1.setLabels(new String[] {textRes.getString("All_Products"),
- textRes.getString("Software_Products"),
- textRes.getString("Deskware_Products"),
- textRes.getString("Bodyware_Products")});
- checkboxPanel1.setSelectedIndex(0);
-
- labelControl2.setText(textRes.getString("Item_No"));
- labelControl4.setText(textRes.getString("Unit_Price"));
- labelControl6.setText(textRes.getString("Description"));
-
- buttonControl1.setLabel(textRes.getString("Add_to_Order"));
- buttonControl2.setLabel(textRes.getString("View_Order"));
- buttonControl3.setLabel(textRes.getString("Close"));
- this.setTitle(textRes.getString("Borland_Store_Products"));
- this.pack();
- }
-
-
- void buttonControl2_actionPerformed(java.awt.event.ActionEvent e) {
- this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- WelcomeFrame.getInstance().setAllowOrderViewing(false);
- appDataModule.initializeOrder();
- OrderFrame.getInstance().setVisible(true);
- this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
-
- void buttonControl3_actionPerformed(java.awt.event.ActionEvent e) {
- this.setVisible(false);
- }
-
- }
-
- class ProductFrame_checkboxPanel1_itemAdapter implements java.awt.event.ItemListener {
- ProductFrame adaptee;
-
- ProductFrame_checkboxPanel1_itemAdapter(ProductFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void itemStateChanged(java.awt.event.ItemEvent e) {
- adaptee.checkboxPanel1_itemStateChanged(e);
- }
- }
-
- class ProductFrame_buttonControl1_actionAdapter implements java.awt.event.ActionListener {
- ProductFrame adaptee;
-
- ProductFrame_buttonControl1_actionAdapter(ProductFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(java.awt.event.ActionEvent e) {
- adaptee.buttonControl1_actionPerformed(e);
- }
- }
-
- class ProductFrame_buttonControl2_actionAdapter implements java.awt.event.ActionListener {
- ProductFrame adaptee;
-
- ProductFrame_buttonControl2_actionAdapter(ProductFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(java.awt.event.ActionEvent e) {
- adaptee.buttonControl2_actionPerformed(e);
- }
- }
-
- class ProductFrame_buttonControl3_actionAdapter implements java.awt.event.ActionListener {
- ProductFrame adaptee;
-
- ProductFrame_buttonControl3_actionAdapter(ProductFrame adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(java.awt.event.ActionEvent e) {
- adaptee.buttonControl3_actionPerformed(e);
- }
- }
-