home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
ProductFrame.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
14KB
|
329 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.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 labelControl3 = new LabelControl();
LabelControl labelControl4 = new LabelControl();
LabelControl labelControl5 = new LabelControl();
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 = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes",
LocaleChangeManager.getLocale());
public static ProductFrame getInstance() {
if (productFrame == null) {
productFrame = new ProductFrame();
}
return productFrame;
}
protected ProductFrame() {
try {
jbInit();
// For cosmetic reasons, because we want the wrappingTextViewer's to be
// the same height as its ImageControl neighbor, we set its preferred size
// to be smaller than its neighbor. This effectively removes the size of
// the wrappingTextViewer from the calculation of the packed frame.
// Note that the wrappingTextViewer can accommodate any non-zero size.
wrappingTextViewer1.setPreferredSize(new Dimension(50, 50));
LocaleChangeManager.getLocaleChangeManager().addLocaleChangeListener(this);
}
catch (Exception e) {
borland.jbcl.util.Diagnostic.printStackTrace(e);
};
}
public void addNotify() {
super.addNotify();
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);
}
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, 10, 0, 10), 0, 0));
bevelPanel2.add(labelControl3, new GridBagConstraints2(1, 0, 1, 1, 100.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 10), 0, 0));
bevelPanel2.add(labelControl4, new GridBagConstraints2(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 10, 0, 10), 0, 0));
bevelPanel2.add(labelControl5, new GridBagConstraints2(1, 1, 1, 1, 100.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 10), 0, 0));
bevelPanel2.add(labelControl6, new GridBagConstraints2(0, 2, 2, 1, 100.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 10), 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"));
labelControl3.setColumnName("sku");
labelControl3.setDataSet(appDataModule.getProductsDataSet());
labelControl3.setAlignment(Label.RIGHT);
labelControl4.setText(textRes.getString("Unit_Price"));
labelControl5.setColumnName("unit_price");
labelControl5.setDataSet(appDataModule.getProductsDataSet());
labelControl5.setAlignment(Label.RIGHT);
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.setSize(new Dimension(478, 392));
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 = java.util.ResourceBundle.getBundle("borland.samples.intl.gui.resources.TextRes", e.getLocale());
labelControl1.setText(textRes.getString("The_Borland_Store"));
labelControl1.invalidate();
int currentIndex = checkboxPanel1.getSelectedIndex();
checkboxPanel1.setLabels(new String[] {textRes.getString("All_Products"),
textRes.getString("Software_Products"),
textRes.getString("Deskware_Products"),
textRes.getString("Bodyware_Products")});
checkboxPanel1.invalidate();
checkboxPanel1.setSelectedIndex(currentIndex);
labelControl2.setText(textRes.getString("Item_No"));
labelControl2.invalidate();
labelControl4.setText(textRes.getString("Unit_Price"));
labelControl4.invalidate();
labelControl6.setText(textRes.getString("Description"));
labelControl6.invalidate();
buttonControl1.setLabel(textRes.getString("Add_to_Order"));
buttonControl1.invalidate();
buttonControl2.setLabel(textRes.getString("View_Order"));
buttonControl2.invalidate();
buttonControl3.setLabel(textRes.getString("Close"));
buttonControl3.invalidate();
wrappingTextViewer1.setLocale(e.getLocale());
wrappingTextViewer1.invalidate();
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);
}
}