home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPSelectReportDef.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  8.7 KB  |  410 lines

  1. import java.awt.BorderLayout;
  2. import java.awt.Button;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.GridLayout;
  7. import java.awt.Label;
  8. import java.awt.Panel;
  9. import java.awt.TextField;
  10. import java.util.Vector;
  11.  
  12. public class JDPSelectReportDef extends JDPClassLayout {
  13.    JDPSelectColumns target;
  14.    JDPGridSettings targetSettings;
  15.    JDPGridLayout targetGrid;
  16.    JDPPopupMessage popuppanel;
  17.    JDPList columns;
  18.    JDPList groupBy;
  19.    TextField reportTitle;
  20.    JDPComboBox totalsOnly;
  21.    JDPComboBox subtotal;
  22.    JDPComboBox grandtotal;
  23.    TextField maxRows;
  24.    TextField pfromwhereclause;
  25.    Vector gParmObject;
  26.    boolean[] subTotal;
  27.    boolean[] grandTotal;
  28.    int currentSelection = -1;
  29.    JDPTabSelectPanel tabPanel;
  30.  
  31.    void updateArrays() {
  32.       if (this.currentSelection >= 0) {
  33.          this.subTotal[this.currentSelection] = this.subtotal.getSelectedItem().equals("Yes");
  34.          this.grandTotal[this.currentSelection] = this.grandtotal.getSelectedItem().equals("Yes");
  35.       }
  36.    }
  37.  
  38.    void clearList() {
  39.       this.columns.clear();
  40.       this.groupBy.clear();
  41.    }
  42.  
  43.    void loadList() {
  44.       this.clearList();
  45.       if (this.target != null && this.target.columnName != null && this.target.columns.getSelectedIndexes().length != 0) {
  46.          if (this.reportTitle.getText().equals("")) {
  47.             String var1 = this.target.table.getText().toUpperCase();
  48.             int var2 = var1.indexOf(".");
  49.             if (var2 >= 0) {
  50.                var1 = var1.substring(var2 + 1);
  51.             }
  52.  
  53.             var1 = var1 + " REPORT";
  54.             this.reportTitle.setText(var1);
  55.          }
  56.  
  57.          String[] var5 = this.target.columns.getSelectedItems();
  58.          int var6 = var5.length;
  59.          this.subTotal = new boolean[var6];
  60.          this.grandTotal = new boolean[var6];
  61.  
  62.          for(int var3 = 0; var3 < var5.length; ++var3) {
  63.             this.subTotal[var3] = false;
  64.             this.grandTotal[var3] = false;
  65.             this.columns.addItem(var5[var3], 8);
  66.          }
  67.  
  68.       } else {
  69.          if (super.componentName.equals("") && ((Component)this).isShowing()) {
  70.             super.user.mainmsg.setStatusMsg("You must first select a Table.", 5);
  71.          }
  72.  
  73.       }
  74.    }
  75.  
  76.    boolean restoreSelections() {
  77.       JDPSaveProps var1 = super.user.saveProperties;
  78.       if (super.user.prevProperties != null) {
  79.          var1 = super.user.prevProperties;
  80.       }
  81.  
  82.       String var2 = "JDPSelectReportDef" + super.componentName;
  83.       var1.restoreObject(this.groupBy, var2, "groupBy", 1);
  84.       var1.restoreObject(this.reportTitle, var2, "reportTitle");
  85.       var1.restoreObject(this.maxRows, var2, "maxRows");
  86.       var1.restoreObject(this.pfromwhereclause, var2, "pfromwhereclause");
  87.       boolean[] var3 = (boolean[])var1.restoreObject(this.subTotal, var2, "subTotal");
  88.       boolean[] var4 = (boolean[])var1.restoreObject(this.grandTotal, var2, "grandTotal");
  89.       if (var3 != null) {
  90.          if (this.subTotal.length < var3.length) {
  91.             this.subTotal = new boolean[var3.length];
  92.          }
  93.  
  94.          if (this.grandTotal.length < var4.length) {
  95.             this.grandTotal = new boolean[var4.length];
  96.          }
  97.  
  98.          for(int var5 = 0; var5 < var3.length; ++var5) {
  99.             this.subTotal[var5] = var3[var5];
  100.             this.grandTotal[var5] = var4[var5];
  101.          }
  102.       }
  103.  
  104.       return true;
  105.    }
  106.  
  107.    void clearFields() {
  108.       this.subtotal.select("No");
  109.       this.grandtotal.select("No");
  110.    }
  111.  
  112.    boolean saveSelections() {
  113.       JDPSaveProps var1 = super.user.saveProperties;
  114.       String var2 = "JDPSelectReportDef" + super.componentName;
  115.       var1.saveObject(this.groupBy, var2, "groupBy", 1);
  116.       var1.saveObject(this.reportTitle, var2, "reportTitle");
  117.       var1.saveObject(this.maxRows, var2, "maxRows");
  118.       var1.saveObject(this.pfromwhereclause, var2, "pfromwhereclause");
  119.       var1.saveObject(this.subTotal, var2, "subTotal");
  120.       var1.saveObject(this.grandTotal, var2, "grandTotal");
  121.       return true;
  122.    }
  123.  
  124.    void refresh() {
  125.       this.clearFields();
  126.       this.currentSelection = -1;
  127.       this.retrieveColumns();
  128.       this.loadList();
  129.       this.restoreSelections();
  130.    }
  131.  
  132.    void retrieveColumns() {
  133.       for(int var1 = 0; var1 < super.user.gParm.size(); ++var1) {
  134.          if (super.user.gParm.elementAt(var1) instanceof Vector) {
  135.             Vector var2 = (Vector)super.user.gParm.elementAt(var1);
  136.             if (((String)var2.elementAt(0)).compareTo("SelectColumns" + super.componentName) == 0) {
  137.                this.target = (JDPSelectColumns)var2.elementAt(1);
  138.             }
  139.  
  140.             if (((String)var2.elementAt(0)).compareTo("GridSettings" + super.componentName) == 0) {
  141.                this.targetSettings = (JDPGridSettings)var2.elementAt(1);
  142.             }
  143.  
  144.             if (((String)var2.elementAt(0)).compareTo("GridLayout" + super.componentName) == 0) {
  145.                this.targetGrid = (JDPGridLayout)var2.elementAt(1);
  146.             }
  147.          }
  148.       }
  149.  
  150.    }
  151.  
  152.    public boolean handleEvent(Event var1) {
  153.       switch (var1.id) {
  154.          case 202:
  155.             if (var1.target instanceof JDPTabSelectTopPanel) {
  156.                this.retrieveColumns();
  157.                return true;
  158.             }
  159.  
  160.             return false;
  161.          case 401:
  162.             if (var1.key == 9) {
  163.                if (var1.target.equals(this.reportTitle)) {
  164.                   super.user.u.cursor(this.pfromwhereclause);
  165.                   return true;
  166.                }
  167.  
  168.                if (var1.target.equals(this.pfromwhereclause)) {
  169.                   super.user.u.cursor(this.maxRows);
  170.                   return true;
  171.                }
  172.  
  173.                if (var1.target.equals(this.maxRows)) {
  174.                   super.user.u.cursor(this.subTotal);
  175.                   return true;
  176.                }
  177.  
  178.                if (var1.target.equals(this.subTotal)) {
  179.                   super.user.u.cursor(this.grandTotal);
  180.                   return true;
  181.                }
  182.  
  183.                if (var1.target.equals(this.grandTotal)) {
  184.                   super.user.u.cursor(this.reportTitle);
  185.                   return true;
  186.                }
  187.  
  188.                return true;
  189.             }
  190.  
  191.             return false;
  192.          case 503:
  193.          case 504:
  194.          case 505:
  195.             this.popuppanel.postEvent(var1);
  196.             return false;
  197.          case 701:
  198.             if (var1.target instanceof JDPList) {
  199.                this.updateArrays();
  200.                if (var1.target.equals(this.columns)) {
  201.                   this.groupBy.addItem(this.columns.getSelectedItem(), 8);
  202.                   this.columns.delItem(this.columns.getSelectedIndex());
  203.                }
  204.  
  205.                if (var1.target.equals(this.groupBy)) {
  206.                   int var3 = this.groupBy.getSelectedIndex();
  207.                   this.loadItem(var3);
  208.                   this.currentSelection = var3;
  209.                }
  210.  
  211.                return true;
  212.             }
  213.  
  214.             return false;
  215.          case 1001:
  216.             if (var1.target instanceof TextField) {
  217.                super.user.u.isnumeric(this.maxRows, super.user.mainmsg);
  218.                return true;
  219.             } else if (var1.target instanceof JDPComboBox) {
  220.                if (this.groupBy.getSelectedIndex() < 0) {
  221.                   super.user.mainmsg.setStatusMsg("You must first select a column for which to display totals", 7);
  222.                }
  223.  
  224.                return true;
  225.             } else {
  226.                if (var1.target instanceof Button) {
  227.                   String var2 = (String)var1.arg;
  228.                   if (var2.trim().compareTo(">") == 0 && this.columns.getSelectedIndex() >= 0) {
  229.                      this.groupBy.addItem(this.columns.getSelectedItem(), 8);
  230.                      this.columns.delItem(this.columns.getSelectedIndex());
  231.                   }
  232.  
  233.                   if (var2.trim().compareTo("<") == 0 && this.groupBy.getSelectedIndex() >= 0) {
  234.                      this.columns.addItem(this.groupBy.getSelectedItem(), 8);
  235.                      this.groupBy.delItem(this.groupBy.getSelectedIndex());
  236.                   }
  237.  
  238.                   if (var2.trim().compareTo("Accept") == 0) {
  239.                      if (super.user.u.isnumeric(this.maxRows, super.user.mainmsg)) {
  240.                         this.updateArrays();
  241.                         this.saveSelections();
  242.                         if (this.groupBy.countItems() == 0) {
  243.                            super.user.mainmsg.setStatusMsg("You must choose a column by which to order your report.", 5);
  244.                            return true;
  245.                         }
  246.  
  247.                         if (this.targetSettings != null) {
  248.                            this.targetSettings.refresh();
  249.                         }
  250.  
  251.                         if (this.targetGrid != null) {
  252.                            this.targetGrid.refresh();
  253.                         }
  254.  
  255.                         if (super.componentName.equals("")) {
  256.                            super.user.jdpMenuPanel.loadNextTab();
  257.                         } else {
  258.                            this.tabPanel = JDPUtils.getTabPanel(this);
  259.                            if (this.tabPanel != null) {
  260.                               this.tabPanel.loadNextTab();
  261.                            }
  262.                         }
  263.  
  264.                         super.user.mainmsg.setStatusMsg("Selections accepted.", 5);
  265.                      }
  266.  
  267.                      return true;
  268.                   }
  269.  
  270.                   if (var2.trim().compareTo("Reset") == 0) {
  271.                      this.refresh();
  272.                      return true;
  273.                   }
  274.                }
  275.  
  276.                return true;
  277.             }
  278.          default:
  279.             return false;
  280.       }
  281.    }
  282.  
  283.    boolean removeSelections() {
  284.       JDPSaveProps var1 = super.user.saveProperties;
  285.       String var2 = "JDPSelectReportDef" + super.componentName;
  286.       var1.removeObject(this.groupBy, var2, "groupBy");
  287.       var1.removeObject(this.reportTitle, var2, "reportTitle");
  288.       var1.removeObject(this.maxRows, var2, "maxRows");
  289.       var1.removeObject(this.pfromwhereclause, var2, "pfromwhereclause");
  290.       var1.removeObject(this.subTotal, var2, "subTotal");
  291.       var1.removeObject(this.grandTotal, var2, "grandTotal");
  292.       return true;
  293.    }
  294.  
  295.    void loadItem(int var1) {
  296.       if (this.subTotal[var1]) {
  297.          this.subtotal.select("Yes");
  298.       } else {
  299.          this.subtotal.select("No");
  300.       }
  301.  
  302.       if (this.grandTotal[var1]) {
  303.          this.grandtotal.select("Yes");
  304.       } else {
  305.          this.grandtotal.select("No");
  306.       }
  307.    }
  308.  
  309.    public void InitClass(JDPUser var1, Panel var2, String var3) {
  310.       super.user = var1;
  311.       super.moduleName = "SelectReportDef";
  312.       if (var3.startsWith("JDPLayoutMgr:")) {
  313.          super.componentName = var3.substring(13);
  314.          var3 = "";
  315.       }
  316.  
  317.       ((Container)this).setLayout(new BorderLayout());
  318.       ((Component)this).setFont(var1.plainFont);
  319.       this.popuppanel = new JDPPopupMessage(var1, var2);
  320.       ((Container)var2).add(this.popuppanel);
  321.       Panel var4 = new Panel();
  322.       ((Container)var4).setLayout(new BorderLayout());
  323.       Panel var5 = new Panel();
  324.       ((Container)var5).setLayout(new BorderLayout());
  325.       Panel var6 = new Panel();
  326.       ((Container)var6).setLayout(new GridLayout(4, 1));
  327.       Panel var7 = new Panel();
  328.       ((Container)var7).setLayout(new JDPRowLayout(1, 1));
  329.       Panel var8 = new Panel();
  330.       ((Container)var8).setLayout(new BorderLayout());
  331.       Panel var9 = new Panel();
  332.       ((Container)var9).setLayout(new BorderLayout());
  333.       Panel var10 = new Panel();
  334.       ((Container)var10).setLayout(new JDPLineLayout(1));
  335.       JDPScrollPanel var11 = new JDPScrollPanel();
  336.       this.reportTitle = new TextField("", 30);
  337.       this.totalsOnly = new JDPComboBox(var1, "", 5);
  338.       this.totalsOnly.setEditable(false);
  339.       this.totalsOnly.addItem("No");
  340.       this.totalsOnly.addItem("Yes");
  341.       this.pfromwhereclause = new TextField("(1=1)", 30);
  342.       this.maxRows = new TextField("5000", 10);
  343.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "Report Title:"));
  344.       ((Container)var7).add("Right", this.reportTitle);
  345.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "Special Where Clause:"));
  346.       ((Container)var7).add("Right", this.pfromwhereclause);
  347.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "Maximum rows to report on:"));
  348.       ((Container)var7).add("Right", this.maxRows);
  349.       ((Container)var4).add("North", var7);
  350.       this.subtotal = new JDPComboBox(var1, "", 5);
  351.       this.subtotal.setEditable(false);
  352.       this.subtotal.addItem("No");
  353.       this.subtotal.addItem("Yes");
  354.       this.grandtotal = new JDPComboBox(var1, "", 5);
  355.       this.grandtotal.setEditable(false);
  356.       this.grandtotal.addItem("No");
  357.       this.grandtotal.addItem("Yes");
  358.       ((Container)var11).add("Left", new JDPWrapLabel(var1, "For this column:"));
  359.       ((Container)var11).add("Right", new Panel());
  360.       ((Container)var11).add("Left", new JDPWrapLabel(var1, "Display a subtotal:"));
  361.       ((Container)var11).add("Right", this.subtotal);
  362.       ((Container)var11).add("Left", new JDPWrapLabel(var1, "Display a grand total:"));
  363.       ((Container)var11).add("Right", this.grandtotal);
  364.       ((Container)var11).add("Left", new Label(""));
  365.       ((Container)var11).add("Left", new Label(""));
  366.       this.groupBy = new JDPList(var1);
  367.       this.groupBy.setMinWidth(140);
  368.       this.groupBy.setMinHeight(260);
  369.       ((Container)var6).add(new Label(""));
  370.       ((Container)var6).add(new Label(""));
  371.       ((Container)var6).add(new JDPButton("  >  "));
  372.       ((Container)var6).add(new JDPButton("  <  "));
  373.       ((Container)var5).add("Center", this.groupBy);
  374.       this.columns = new JDPList(var1);
  375.       this.columns.setMinWidth(140);
  376.       this.columns.setMinHeight(260);
  377.       Panel var12 = new Panel();
  378.       ((Container)var12).setLayout(new BorderLayout());
  379.       ((Container)var12).add("Center", this.columns);
  380.       ((Container)var10).add("Left", var12);
  381.       ((Container)var10).add("Left", var6);
  382.       ((Container)var10).add("Left", var5);
  383.       Panel var13 = new Panel();
  384.       ((Container)var13).setLayout(new BorderLayout());
  385.       ((Container)var13).add("North", var11);
  386.       ((Container)var13).add("Center", new Panel());
  387.       String[] var14 = new String[]{"Accept", "Reset"};
  388.       int[] var15 = new int[]{5, 6};
  389.       JDPButtons var16 = new JDPButtons(var1, var14, var15, JDPButtons.HORIZONTAL);
  390.       this.popuppanel.addComponent(var16.button[0], "Accept Selections", "Accept selections and proceed to next screen");
  391.       this.popuppanel.addComponent(var16.button[1], "Reset Selections", "Reset selections back to default settings");
  392.       ((Container)var10).add("Left", var13);
  393.       ((Container)var9).add("North", new JDPWrapLabel(var1, "Choose the columns by which to order your report:"));
  394.       ((Container)var9).add("Center", var10);
  395.       ((Container)var4).add("Center", var9);
  396.       JDPScrollPanel var17 = new JDPScrollPanel();
  397.       ((Container)var17).add("Left", var4);
  398.       Panel var18 = new Panel();
  399.       ((Container)var18).setLayout(new BorderLayout());
  400.       ((Container)var18).add("Center", var17);
  401.       ((Container)var18).add("South", var16);
  402.       ((Container)this).add("Center", new JDPChiselFramePanel(var1, "Report definition and column grouping:", var18, "North"));
  403.       this.gParmObject = new Vector();
  404.       this.gParmObject.addElement(super.moduleName + super.componentName);
  405.       this.gParmObject.addElement(this);
  406.       var1.gParm.addElement(this.gParmObject);
  407.       ((Component)var2).paintAll(((Component)var2).getGraphics());
  408.    }
  409. }
  410.