home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.GridLayout;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.TextField;
- import java.util.Vector;
-
- public class JDPSelectReportDef extends JDPClassLayout {
- JDPSelectColumns target;
- JDPGridSettings targetSettings;
- JDPGridLayout targetGrid;
- JDPPopupMessage popuppanel;
- JDPList columns;
- JDPList groupBy;
- TextField reportTitle;
- JDPComboBox totalsOnly;
- JDPComboBox subtotal;
- JDPComboBox grandtotal;
- TextField maxRows;
- TextField pfromwhereclause;
- Vector gParmObject;
- boolean[] subTotal;
- boolean[] grandTotal;
- int currentSelection = -1;
- JDPTabSelectPanel tabPanel;
-
- void updateArrays() {
- if (this.currentSelection >= 0) {
- this.subTotal[this.currentSelection] = this.subtotal.getSelectedItem().equals("Yes");
- this.grandTotal[this.currentSelection] = this.grandtotal.getSelectedItem().equals("Yes");
- }
- }
-
- void clearList() {
- this.columns.clear();
- this.groupBy.clear();
- }
-
- void loadList() {
- this.clearList();
- if (this.target != null && this.target.columnName != null && this.target.columns.getSelectedIndexes().length != 0) {
- if (this.reportTitle.getText().equals("")) {
- String var1 = this.target.table.getText().toUpperCase();
- int var2 = var1.indexOf(".");
- if (var2 >= 0) {
- var1 = var1.substring(var2 + 1);
- }
-
- var1 = var1 + " REPORT";
- this.reportTitle.setText(var1);
- }
-
- String[] var5 = this.target.columns.getSelectedItems();
- int var6 = var5.length;
- this.subTotal = new boolean[var6];
- this.grandTotal = new boolean[var6];
-
- for(int var3 = 0; var3 < var5.length; ++var3) {
- this.subTotal[var3] = false;
- this.grandTotal[var3] = false;
- this.columns.addItem(var5[var3], 8);
- }
-
- } else {
- if (super.componentName.equals("") && ((Component)this).isShowing()) {
- super.user.mainmsg.setStatusMsg("You must first select a Table.", 5);
- }
-
- }
- }
-
- boolean restoreSelections() {
- JDPSaveProps var1 = super.user.saveProperties;
- if (super.user.prevProperties != null) {
- var1 = super.user.prevProperties;
- }
-
- String var2 = "JDPSelectReportDef" + super.componentName;
- var1.restoreObject(this.groupBy, var2, "groupBy", 1);
- var1.restoreObject(this.reportTitle, var2, "reportTitle");
- var1.restoreObject(this.maxRows, var2, "maxRows");
- var1.restoreObject(this.pfromwhereclause, var2, "pfromwhereclause");
- boolean[] var3 = (boolean[])var1.restoreObject(this.subTotal, var2, "subTotal");
- boolean[] var4 = (boolean[])var1.restoreObject(this.grandTotal, var2, "grandTotal");
- if (var3 != null) {
- if (this.subTotal.length < var3.length) {
- this.subTotal = new boolean[var3.length];
- }
-
- if (this.grandTotal.length < var4.length) {
- this.grandTotal = new boolean[var4.length];
- }
-
- for(int var5 = 0; var5 < var3.length; ++var5) {
- this.subTotal[var5] = var3[var5];
- this.grandTotal[var5] = var4[var5];
- }
- }
-
- return true;
- }
-
- void clearFields() {
- this.subtotal.select("No");
- this.grandtotal.select("No");
- }
-
- boolean saveSelections() {
- JDPSaveProps var1 = super.user.saveProperties;
- String var2 = "JDPSelectReportDef" + super.componentName;
- var1.saveObject(this.groupBy, var2, "groupBy", 1);
- var1.saveObject(this.reportTitle, var2, "reportTitle");
- var1.saveObject(this.maxRows, var2, "maxRows");
- var1.saveObject(this.pfromwhereclause, var2, "pfromwhereclause");
- var1.saveObject(this.subTotal, var2, "subTotal");
- var1.saveObject(this.grandTotal, var2, "grandTotal");
- return true;
- }
-
- void refresh() {
- this.clearFields();
- this.currentSelection = -1;
- this.retrieveColumns();
- this.loadList();
- this.restoreSelections();
- }
-
- void retrieveColumns() {
- for(int var1 = 0; var1 < super.user.gParm.size(); ++var1) {
- if (super.user.gParm.elementAt(var1) instanceof Vector) {
- Vector var2 = (Vector)super.user.gParm.elementAt(var1);
- if (((String)var2.elementAt(0)).compareTo("SelectColumns" + super.componentName) == 0) {
- this.target = (JDPSelectColumns)var2.elementAt(1);
- }
-
- if (((String)var2.elementAt(0)).compareTo("GridSettings" + super.componentName) == 0) {
- this.targetSettings = (JDPGridSettings)var2.elementAt(1);
- }
-
- if (((String)var2.elementAt(0)).compareTo("GridLayout" + super.componentName) == 0) {
- this.targetGrid = (JDPGridLayout)var2.elementAt(1);
- }
- }
- }
-
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 202:
- if (var1.target instanceof JDPTabSelectTopPanel) {
- this.retrieveColumns();
- return true;
- }
-
- return false;
- case 401:
- if (var1.key == 9) {
- if (var1.target.equals(this.reportTitle)) {
- super.user.u.cursor(this.pfromwhereclause);
- return true;
- }
-
- if (var1.target.equals(this.pfromwhereclause)) {
- super.user.u.cursor(this.maxRows);
- return true;
- }
-
- if (var1.target.equals(this.maxRows)) {
- super.user.u.cursor(this.subTotal);
- return true;
- }
-
- if (var1.target.equals(this.subTotal)) {
- super.user.u.cursor(this.grandTotal);
- return true;
- }
-
- if (var1.target.equals(this.grandTotal)) {
- super.user.u.cursor(this.reportTitle);
- return true;
- }
-
- return true;
- }
-
- return false;
- case 503:
- case 504:
- case 505:
- this.popuppanel.postEvent(var1);
- return false;
- case 701:
- if (var1.target instanceof JDPList) {
- this.updateArrays();
- if (var1.target.equals(this.columns)) {
- this.groupBy.addItem(this.columns.getSelectedItem(), 8);
- this.columns.delItem(this.columns.getSelectedIndex());
- }
-
- if (var1.target.equals(this.groupBy)) {
- int var3 = this.groupBy.getSelectedIndex();
- this.loadItem(var3);
- this.currentSelection = var3;
- }
-
- return true;
- }
-
- return false;
- case 1001:
- if (var1.target instanceof TextField) {
- super.user.u.isnumeric(this.maxRows, super.user.mainmsg);
- return true;
- } else if (var1.target instanceof JDPComboBox) {
- if (this.groupBy.getSelectedIndex() < 0) {
- super.user.mainmsg.setStatusMsg("You must first select a column for which to display totals", 7);
- }
-
- return true;
- } else {
- if (var1.target instanceof Button) {
- String var2 = (String)var1.arg;
- if (var2.trim().compareTo(">") == 0 && this.columns.getSelectedIndex() >= 0) {
- this.groupBy.addItem(this.columns.getSelectedItem(), 8);
- this.columns.delItem(this.columns.getSelectedIndex());
- }
-
- if (var2.trim().compareTo("<") == 0 && this.groupBy.getSelectedIndex() >= 0) {
- this.columns.addItem(this.groupBy.getSelectedItem(), 8);
- this.groupBy.delItem(this.groupBy.getSelectedIndex());
- }
-
- if (var2.trim().compareTo("Accept") == 0) {
- if (super.user.u.isnumeric(this.maxRows, super.user.mainmsg)) {
- this.updateArrays();
- this.saveSelections();
- if (this.groupBy.countItems() == 0) {
- super.user.mainmsg.setStatusMsg("You must choose a column by which to order your report.", 5);
- return true;
- }
-
- if (this.targetSettings != null) {
- this.targetSettings.refresh();
- }
-
- if (this.targetGrid != null) {
- this.targetGrid.refresh();
- }
-
- if (super.componentName.equals("")) {
- super.user.jdpMenuPanel.loadNextTab();
- } else {
- this.tabPanel = JDPUtils.getTabPanel(this);
- if (this.tabPanel != null) {
- this.tabPanel.loadNextTab();
- }
- }
-
- super.user.mainmsg.setStatusMsg("Selections accepted.", 5);
- }
-
- return true;
- }
-
- if (var2.trim().compareTo("Reset") == 0) {
- this.refresh();
- return true;
- }
- }
-
- return true;
- }
- default:
- return false;
- }
- }
-
- boolean removeSelections() {
- JDPSaveProps var1 = super.user.saveProperties;
- String var2 = "JDPSelectReportDef" + super.componentName;
- var1.removeObject(this.groupBy, var2, "groupBy");
- var1.removeObject(this.reportTitle, var2, "reportTitle");
- var1.removeObject(this.maxRows, var2, "maxRows");
- var1.removeObject(this.pfromwhereclause, var2, "pfromwhereclause");
- var1.removeObject(this.subTotal, var2, "subTotal");
- var1.removeObject(this.grandTotal, var2, "grandTotal");
- return true;
- }
-
- void loadItem(int var1) {
- if (this.subTotal[var1]) {
- this.subtotal.select("Yes");
- } else {
- this.subtotal.select("No");
- }
-
- if (this.grandTotal[var1]) {
- this.grandtotal.select("Yes");
- } else {
- this.grandtotal.select("No");
- }
- }
-
- public void InitClass(JDPUser var1, Panel var2, String var3) {
- super.user = var1;
- super.moduleName = "SelectReportDef";
- if (var3.startsWith("JDPLayoutMgr:")) {
- super.componentName = var3.substring(13);
- var3 = "";
- }
-
- ((Container)this).setLayout(new BorderLayout());
- ((Component)this).setFont(var1.plainFont);
- this.popuppanel = new JDPPopupMessage(var1, var2);
- ((Container)var2).add(this.popuppanel);
- Panel var4 = new Panel();
- ((Container)var4).setLayout(new BorderLayout());
- Panel var5 = new Panel();
- ((Container)var5).setLayout(new BorderLayout());
- Panel var6 = new Panel();
- ((Container)var6).setLayout(new GridLayout(4, 1));
- Panel var7 = new Panel();
- ((Container)var7).setLayout(new JDPRowLayout(1, 1));
- Panel var8 = new Panel();
- ((Container)var8).setLayout(new BorderLayout());
- Panel var9 = new Panel();
- ((Container)var9).setLayout(new BorderLayout());
- Panel var10 = new Panel();
- ((Container)var10).setLayout(new JDPLineLayout(1));
- JDPScrollPanel var11 = new JDPScrollPanel();
- this.reportTitle = new TextField("", 30);
- this.totalsOnly = new JDPComboBox(var1, "", 5);
- this.totalsOnly.setEditable(false);
- this.totalsOnly.addItem("No");
- this.totalsOnly.addItem("Yes");
- this.pfromwhereclause = new TextField("(1=1)", 30);
- this.maxRows = new TextField("5000", 10);
- ((Container)var7).add("Left", new JDPWrapLabel(var1, "Report Title:"));
- ((Container)var7).add("Right", this.reportTitle);
- ((Container)var7).add("Left", new JDPWrapLabel(var1, "Special Where Clause:"));
- ((Container)var7).add("Right", this.pfromwhereclause);
- ((Container)var7).add("Left", new JDPWrapLabel(var1, "Maximum rows to report on:"));
- ((Container)var7).add("Right", this.maxRows);
- ((Container)var4).add("North", var7);
- this.subtotal = new JDPComboBox(var1, "", 5);
- this.subtotal.setEditable(false);
- this.subtotal.addItem("No");
- this.subtotal.addItem("Yes");
- this.grandtotal = new JDPComboBox(var1, "", 5);
- this.grandtotal.setEditable(false);
- this.grandtotal.addItem("No");
- this.grandtotal.addItem("Yes");
- ((Container)var11).add("Left", new JDPWrapLabel(var1, "For this column:"));
- ((Container)var11).add("Right", new Panel());
- ((Container)var11).add("Left", new JDPWrapLabel(var1, "Display a subtotal:"));
- ((Container)var11).add("Right", this.subtotal);
- ((Container)var11).add("Left", new JDPWrapLabel(var1, "Display a grand total:"));
- ((Container)var11).add("Right", this.grandtotal);
- ((Container)var11).add("Left", new Label(""));
- ((Container)var11).add("Left", new Label(""));
- this.groupBy = new JDPList(var1);
- this.groupBy.setMinWidth(140);
- this.groupBy.setMinHeight(260);
- ((Container)var6).add(new Label(""));
- ((Container)var6).add(new Label(""));
- ((Container)var6).add(new JDPButton(" > "));
- ((Container)var6).add(new JDPButton(" < "));
- ((Container)var5).add("Center", this.groupBy);
- this.columns = new JDPList(var1);
- this.columns.setMinWidth(140);
- this.columns.setMinHeight(260);
- Panel var12 = new Panel();
- ((Container)var12).setLayout(new BorderLayout());
- ((Container)var12).add("Center", this.columns);
- ((Container)var10).add("Left", var12);
- ((Container)var10).add("Left", var6);
- ((Container)var10).add("Left", var5);
- Panel var13 = new Panel();
- ((Container)var13).setLayout(new BorderLayout());
- ((Container)var13).add("North", var11);
- ((Container)var13).add("Center", new Panel());
- String[] var14 = new String[]{"Accept", "Reset"};
- int[] var15 = new int[]{5, 6};
- JDPButtons var16 = new JDPButtons(var1, var14, var15, JDPButtons.HORIZONTAL);
- this.popuppanel.addComponent(var16.button[0], "Accept Selections", "Accept selections and proceed to next screen");
- this.popuppanel.addComponent(var16.button[1], "Reset Selections", "Reset selections back to default settings");
- ((Container)var10).add("Left", var13);
- ((Container)var9).add("North", new JDPWrapLabel(var1, "Choose the columns by which to order your report:"));
- ((Container)var9).add("Center", var10);
- ((Container)var4).add("Center", var9);
- JDPScrollPanel var17 = new JDPScrollPanel();
- ((Container)var17).add("Left", var4);
- Panel var18 = new Panel();
- ((Container)var18).setLayout(new BorderLayout());
- ((Container)var18).add("Center", var17);
- ((Container)var18).add("South", var16);
- ((Container)this).add("Center", new JDPChiselFramePanel(var1, "Report definition and column grouping:", var18, "North"));
- this.gParmObject = new Vector();
- this.gParmObject.addElement(super.moduleName + super.componentName);
- this.gParmObject.addElement(this);
- var1.gParm.addElement(this.gParmObject);
- ((Component)var2).paintAll(((Component)var2).getGraphics());
- }
- }
-