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

  1. import java.awt.BorderLayout;
  2. import java.awt.Container;
  3. import java.awt.Event;
  4. import java.awt.Label;
  5. import java.awt.Panel;
  6. import java.awt.TextArea;
  7. import java.util.Vector;
  8.  
  9. public class JDPSQLStoredProc extends JDPClassLayout {
  10.    JDPUser user;
  11.    JDPJagg jaggSQL;
  12.    JDPPopupMessage popuppanel;
  13.    JDPMaskEdit JDPMaskEditMain;
  14.    String moduleParameter;
  15.    Panel Main;
  16.    Panel Panel1;
  17.    TextArea completeSQL;
  18.    Label Label4;
  19.    Panel Panel6;
  20.    Panel Panel2;
  21.    Panel Panel8;
  22.    Label Label5;
  23.    JDPList storedProcedures;
  24.    Panel Panel9;
  25.    Panel Panel10;
  26.    Label Label6;
  27.    JDPList paramColumns;
  28.    Panel Panel11;
  29.    Label Label7;
  30.    JDPComboBox paramSettings;
  31.    Vector valueparamSettings;
  32.    Panel Panel7;
  33.    Panel Panel4;
  34.    JDPList returnedColumns;
  35.    Label Label2;
  36.    Panel Panel5;
  37.    Label Label3;
  38.    JDPComboBox placeInto;
  39.    Vector valueplaceInto;
  40.    boolean SQLOnly = false;
  41.    String value;
  42.  
  43.    public void InitClass(JDPUser var1, Panel var2, String var3) {
  44.       this.user = var1;
  45.       this.moduleParameter = var3;
  46.       super.targetPanel = var2;
  47.       this.jaggSQL = new JDPJagg(var1.jaggPath);
  48.       ((Container)this).setLayout(new BorderLayout());
  49.       this.popuppanel = new JDPPopupMessage(var1, this);
  50.       ((Container)this).add(this.popuppanel);
  51.       this.JDPMaskEditMain = new JDPMaskEdit();
  52.       this.Main = new Panel();
  53.       this.Panel1 = new Panel();
  54.       this.completeSQL = new TextArea("", 3, 20);
  55.       this.Label4 = new Label("SQL", 0);
  56.       this.Panel6 = new Panel();
  57.       this.Panel2 = new Panel();
  58.       this.Panel8 = new Panel();
  59.       this.Label5 = new Label("Stored Procedures", 0);
  60.       this.storedProceduresMain();
  61.       this.Panel9 = new Panel();
  62.       this.Panel10 = new Panel();
  63.       this.Label6 = new Label("Parameters", 0);
  64.       this.paramColumnsMain();
  65.       this.Panel11 = new Panel();
  66.       this.Label7 = new Label("Equals", 0);
  67.       this.paramSettingsMain();
  68.       this.Panel7 = new Panel();
  69.       this.Panel4 = new Panel();
  70.       this.returnedColumnsMain();
  71.       this.Label2 = new Label("Return Values", 0);
  72.       this.Panel5 = new Panel();
  73.       this.Label3 = new Label("Place Into", 0);
  74.       this.placeIntoMain();
  75.       this.Main.setLayout(new BorderLayout());
  76.       ((Container)this).add("Center", this.Main);
  77.       this.Main.add("Center", this.Panel1);
  78.       this.Panel1.setLayout(new BorderLayout());
  79.       this.Panel1.add("Center", this.completeSQL);
  80.       this.Panel1.add("North", this.Label4);
  81.       this.Main.add("North", this.Panel6);
  82.       this.Panel6.setLayout(new JDPRowLayout());
  83.       this.Panel6.add("Left", this.Panel2);
  84.       this.Panel2.setLayout(new JDPLineLayout());
  85.       this.Panel2.add("Left", this.Panel8);
  86.       this.Panel8.setLayout(new BorderLayout());
  87.       this.Panel8.add("North", this.Label5);
  88.       this.Panel8.add("Center", this.storedProcedures);
  89.       this.Panel6.add("Left", this.Panel9);
  90.       this.Panel9.setLayout(new JDPLineLayout());
  91.       this.Panel9.add("Left", this.Panel10);
  92.       this.Panel10.setLayout(new BorderLayout());
  93.       this.Panel10.add("North", this.Label6);
  94.       this.Panel10.add("Center", this.paramColumns);
  95.       this.Panel9.add("Left", this.Panel11);
  96.       this.Panel11.setLayout(new JDPRowLayout());
  97.       this.Panel11.add("Left", this.Label7);
  98.       this.Panel11.add("Left", this.paramSettings);
  99.       this.Panel6.add("Left", this.Panel7);
  100.       this.Panel7.setLayout(new JDPLineLayout());
  101.       this.Panel7.add("Left", this.Panel4);
  102.       this.Panel4.setLayout(new BorderLayout());
  103.       this.Panel4.add("Center", this.returnedColumns);
  104.       this.Panel4.add("North", this.Label2);
  105.       this.Panel7.add("Left", this.Panel5);
  106.       this.Panel5.setLayout(new JDPRowLayout());
  107.       this.Panel5.add("Left", this.Label3);
  108.       this.Panel5.add("Left", this.placeInto);
  109.       this.storedProcedures.setBackground(var1.u._cvtcolor("White"));
  110.       this.storedProcedures.setMinHeight(60);
  111.       this.storedProcedures.setMultipleSelections(false);
  112.       this.storedProcedures.setSelectionsCheckboxes(false);
  113.       this.storedProcedures.setMinWidth(285);
  114.       this.paramColumns.setBackground(var1.u._cvtcolor("White"));
  115.       this.paramColumns.setMinHeight(60);
  116.       this.paramColumns.setMultipleSelections(false);
  117.       this.paramColumns.setSelectionsCheckboxes(false);
  118.       this.paramSettings.setMinimumWidth(140);
  119.       this.paramSettings.setMaximumWidth(250);
  120.       this.returnedColumns.setBackground(var1.u._cvtcolor("White"));
  121.       this.returnedColumns.setMinHeight(60);
  122.       this.returnedColumns.setMultipleSelections(false);
  123.       this.returnedColumns.setSelectionsCheckboxes(false);
  124.       this.placeInto.setMinimumWidth(140);
  125.       this.placeInto.setMaximumWidth(250);
  126.       this.InitComponents();
  127.       var1.gParm.addElement(this);
  128.    }
  129.  
  130.    public boolean handleEvent(Event var1) {
  131.       switch (var1.id) {
  132.          case 402:
  133.             if (var1.target.equals(this.paramSettings)) {
  134.                String var15 = this.paramColumns.getSelectedKey();
  135.                String var20 = var15.substring(var15.indexOf(":"));
  136.                this.paramColumns.replaceItemKey(this.paramColumns.getSelectedIndex(), this.paramSettings.getText() + var20);
  137.                this.constructSQL();
  138.                return true;
  139.             } else {
  140.                if (var1.target.equals(this.placeInto)) {
  141.                   String var14 = this.returnedColumns.getSelectedKey();
  142.                   String var19 = var14.substring(var14.indexOf(":"));
  143.                   this.returnedColumns.replaceItemKey(this.returnedColumns.getSelectedIndex(), this.placeInto.getText() + var19);
  144.                   this.constructSQL();
  145.                   return true;
  146.                }
  147.  
  148.                return false;
  149.             }
  150.          case 503:
  151.          case 504:
  152.          case 505:
  153.             this.popuppanel.postEvent(var1);
  154.             return false;
  155.          case 701:
  156.             if (var1.target.equals(this.storedProcedures)) {
  157.                Event var13 = new Event(this, 1001, "StoredProcedures");
  158.                ((Container)this).deliverEvent(var13);
  159.                this.constructSQL();
  160.                return true;
  161.             } else if (var1.target.equals(this.paramColumns)) {
  162.                if (this.paramColumns.getSelectedIndex() >= 0) {
  163.                   String var10 = this.paramColumns.getSelectedKey();
  164.                   var10 = var10.substring(0, var10.indexOf(":"));
  165.                   this.paramSettings.setText(var10);
  166.                } else {
  167.                   this.paramSettings.setText("");
  168.                }
  169.  
  170.                this.constructSQL();
  171.                Event var12 = new Event(this, 701, "paramColumns");
  172.                ((Container)this).deliverEvent(var12);
  173.                return true;
  174.             } else {
  175.                if (var1.target.equals(this.returnedColumns)) {
  176.                   if (this.returnedColumns.getSelectedIndex() >= 0) {
  177.                      String var7 = this.returnedColumns.getSelectedKey();
  178.                      var7 = var7.substring(0, var7.indexOf(":"));
  179.                      this.placeInto.setText(var7);
  180.                   } else {
  181.                      this.placeInto.setText("");
  182.                   }
  183.  
  184.                   this.constructSQL();
  185.                   Event var9 = new Event(this, 701, "returnedColumns");
  186.                   ((Container)this).deliverEvent(var9);
  187.                   return true;
  188.                }
  189.  
  190.                return false;
  191.             }
  192.          case 702:
  193.             if (var1.target.equals(this.paramColumns)) {
  194.                this.constructSQL();
  195.                return true;
  196.             } else {
  197.                if (var1.target.equals(this.returnedColumns)) {
  198.                   this.constructSQL();
  199.                   return true;
  200.                }
  201.  
  202.                return false;
  203.             }
  204.          case 1001:
  205.             if (var1.target.equals(this.paramColumns)) {
  206.                this.constructSQL();
  207.                return true;
  208.             } else if (var1.target.equals(this.paramSettings)) {
  209.                String var6 = this.paramColumns.getSelectedKey();
  210.                String var18 = var6.substring(var6.indexOf(":"));
  211.                this.paramColumns.replaceItemKey(this.paramColumns.getSelectedIndex(), this.paramSettings.getText() + var18);
  212.                this.constructSQL();
  213.                return true;
  214.             } else if (var1.target.equals(this.returnedColumns)) {
  215.                this.constructSQL();
  216.                return true;
  217.             } else {
  218.                if (var1.target.equals(this.placeInto)) {
  219.                   String var5 = this.returnedColumns.getSelectedKey();
  220.                   String var17 = var5.substring(var5.indexOf(":"));
  221.                   this.returnedColumns.replaceItemKey(this.returnedColumns.getSelectedIndex(), this.placeInto.getText() + var17);
  222.                   this.constructSQL();
  223.                   return true;
  224.                }
  225.  
  226.                return false;
  227.             }
  228.          case 1005:
  229.             if (var1.target.equals(this.paramSettings)) {
  230.                String var4 = this.paramColumns.getSelectedKey();
  231.                String var16 = var4.substring(var4.indexOf(":"));
  232.                this.paramColumns.replaceItemKey(this.paramColumns.getSelectedIndex(), this.paramSettings.getText() + var16);
  233.                this.constructSQL();
  234.                return true;
  235.             } else {
  236.                if (var1.target.equals(this.placeInto)) {
  237.                   String var2 = this.returnedColumns.getSelectedKey();
  238.                   String var3 = var2.substring(var2.indexOf(":"));
  239.                   this.returnedColumns.replaceItemKey(this.returnedColumns.getSelectedIndex(), this.placeInto.getText() + var3);
  240.                   this.constructSQL();
  241.                   return true;
  242.                }
  243.  
  244.                return false;
  245.             }
  246.          default:
  247.             return false;
  248.       }
  249.    }
  250.  
  251.    public void InitComponents() {
  252.       this.jaggSQL.setKeepConnectionOpen(false);
  253.    }
  254.  
  255.    public void MainMethod() {
  256.    }
  257.  
  258.    public String constructSQL() {
  259.       String var1 = this.constructCompleteSQL(this.SQLOnly);
  260.       this.completeSQL.setText(var1);
  261.       return var1;
  262.    }
  263.  
  264.    public JDPComboBox getPlaceIntoHandle() {
  265.       return this.placeInto;
  266.    }
  267.  
  268.    public JDPList getParamColumnsHandle() {
  269.       return this.paramColumns;
  270.    }
  271.  
  272.    public JDPComboBox getParamSettingsHandle() {
  273.       return this.paramSettings;
  274.    }
  275.  
  276.    public JDPList getStoredProceduresHandle() {
  277.       return this.storedProcedures;
  278.    }
  279.  
  280.    public JDPList getReturnedColumnsHandle() {
  281.       return this.returnedColumns;
  282.    }
  283.  
  284.    public void setSQLOnly(boolean var1) {
  285.       this.SQLOnly = var1;
  286.       if (var1) {
  287.          this.Panel5.hide();
  288.       } else {
  289.          this.Panel5.show();
  290.       }
  291.    }
  292.  
  293.    public String constructCompleteSQL(boolean var1) {
  294.       StringBuffer var2 = new StringBuffer();
  295.       if (this.storedProcedures.getSelectedItem() == null) {
  296.          return "";
  297.       } else {
  298.          String var3 = "\"";
  299.          String var4 = "+";
  300.          if (var1) {
  301.             var3 = "";
  302.             var4 = "";
  303.          }
  304.  
  305.          var2.append(var3 + this.storedProcedures.getSelectedItem() + " ");
  306.          if (this.paramColumns.countItems() > 0) {
  307.             for(int var5 = 0; var5 < this.paramColumns.countItems(); ++var5) {
  308.                if (var5 > 0) {
  309.                   var2.append(", " + var3 + " " + var4 + "\n\t" + var3);
  310.                }
  311.  
  312.                this.value = this.paramColumns.getItemKey(var5);
  313.                this.value = this.value.substring(0, this.value.indexOf(":"));
  314.                var2.append(this.value);
  315.             }
  316.          }
  317.  
  318.          var2.append(var3);
  319.          return var2.toString();
  320.       }
  321.    }
  322.  
  323.    public String getSQL() {
  324.       return this.SQLOnly ? this.completeSQL.getText() : this.constructCompleteSQL(true);
  325.    }
  326.  
  327.    public void clear() {
  328.       this.storedProcedures.clear();
  329.       this.paramColumns.clear();
  330.       this.paramSettings.clear();
  331.       this.paramSettings.setText("");
  332.       this.returnedColumns.clear();
  333.       this.placeInto.clear();
  334.       this.placeInto.setText("");
  335.       this.completeSQL.setText("");
  336.    }
  337.  
  338.    public void storedProceduresMain() {
  339.       if (this.storedProcedures == null) {
  340.          this.storedProcedures = new JDPList(this.user);
  341.       }
  342.  
  343.    }
  344.  
  345.    public void paramColumnsMain() {
  346.       if (this.paramColumns == null) {
  347.          this.paramColumns = new JDPList(this.user);
  348.       }
  349.  
  350.    }
  351.  
  352.    public void paramSettingsMain() {
  353.       if (this.paramSettings == null) {
  354.          this.paramSettings = new JDPComboBox(this.user);
  355.       }
  356.  
  357.    }
  358.  
  359.    public void returnedColumnsMain() {
  360.       if (this.returnedColumns == null) {
  361.          this.returnedColumns = new JDPList(this.user);
  362.       }
  363.  
  364.    }
  365.  
  366.    public void placeIntoMain() {
  367.       if (this.placeInto == null) {
  368.          this.placeInto = new JDPComboBox(this.user);
  369.       }
  370.  
  371.    }
  372. }
  373.