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

  1. import java.awt.BorderLayout;
  2. import java.awt.Checkbox;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.Label;
  7. import java.awt.Panel;
  8. import java.awt.TextField;
  9. import java.util.StringTokenizer;
  10. import java.util.Vector;
  11.  
  12. public class JDPDefineVar extends JDPClassLayout {
  13.    JDPUser user;
  14.    JDPJagg jaggSQL;
  15.    JDPPopupMessage popuppanel;
  16.    JDPMaskEdit JDPMaskEditMain;
  17.    String moduleParameter;
  18.    Panel Main;
  19.    JDPChiselFramePanel ChiselPanel1;
  20.    Panel Panel1;
  21.    JDPScrollPanel ScrollPanel1;
  22.    Label Label1;
  23.    Panel Panel2;
  24.    TextField varName;
  25.    Label Label2;
  26.    JDPComboBox varType;
  27.    Vector valuevarType;
  28.    Label Label3;
  29.    TextField varDesc;
  30.    Label Label4;
  31.    Panel Panel3;
  32.    Checkbox publicCheck;
  33.    Checkbox privateCheck;
  34.    Checkbox staticCheck;
  35.    Checkbox finalCheck;
  36.    Checkbox transientCheck;
  37.  
  38.    public void InitClass(JDPUser var1, Panel var2, String var3) {
  39.       this.user = var1;
  40.       this.moduleParameter = var3;
  41.       super.targetPanel = var2;
  42.       this.jaggSQL = new JDPJagg(var1.jaggPath);
  43.       ((Container)this).setLayout(new BorderLayout());
  44.       this.popuppanel = new JDPPopupMessage(var1, this);
  45.       ((Container)this).add(this.popuppanel);
  46.       this.JDPMaskEditMain = new JDPMaskEdit();
  47.       this.Main = new Panel();
  48.       this.ChiselPanel1 = new JDPChiselFramePanel(var1, "Global Variable Definition");
  49.       this.Panel1 = new Panel();
  50.       this.ScrollPanel1 = new JDPScrollPanel();
  51.       this.Label1 = new Label("Name:", 0);
  52.       this.Panel2 = new Panel();
  53.       this.varName = new TextField("", 20);
  54.       this.Label2 = new Label("Type:", 0);
  55.       this.varTypeMain();
  56.       this.Label3 = new Label("Description:", 0);
  57.       this.varDesc = new TextField("", 44);
  58.       this.Label4 = new Label("", 0);
  59.       this.Panel3 = new Panel();
  60.       this.publicCheck = new Checkbox("public");
  61.       this.privateCheck = new Checkbox("private");
  62.       this.staticCheck = new Checkbox("static");
  63.       this.finalCheck = new Checkbox("final");
  64.       this.transientCheck = new Checkbox("transient");
  65.       this.Main.setLayout(new BorderLayout());
  66.       ((Container)this).add("Center", this.Main);
  67.       this.Main.add("Center", this.ChiselPanel1);
  68.       this.ChiselPanel1.add("Center", this.Panel1);
  69.       this.Panel1.setLayout(new BorderLayout());
  70.       this.Panel1.add("Center", this.ScrollPanel1);
  71.       this.ScrollPanel1.add("Left", this.Label1);
  72.       this.ScrollPanel1.add("Right", this.Panel2);
  73.       this.Panel2.setLayout(new JDPLineLayout());
  74.       this.Panel2.add("Left", this.varName);
  75.       this.Panel2.add("Left", this.Label2);
  76.       this.Panel2.add("Left", this.varType);
  77.       this.ScrollPanel1.add("Left", this.Label3);
  78.       this.ScrollPanel1.add("Right", this.varDesc);
  79.       this.ScrollPanel1.add("Left", this.Label4);
  80.       this.ScrollPanel1.add("Right", this.Panel3);
  81.       this.Panel3.setLayout(new JDPLineLayout());
  82.       this.Panel3.add("Left", this.publicCheck);
  83.       this.Panel3.add("Left", this.privateCheck);
  84.       this.Panel3.add("Left", this.staticCheck);
  85.       this.Panel3.add("Left", this.finalCheck);
  86.       this.Panel3.add("Left", this.transientCheck);
  87.       this.InitComponents();
  88.       var1.gParm.addElement(this);
  89.    }
  90.  
  91.    public boolean handleEvent(Event var1) {
  92.       switch (var1.id) {
  93.          case 401:
  94.             if (var1.key == 9 && var1.modifiers != 1) {
  95.                if (var1.target.equals(this.varName)) {
  96.                   this.user.u.cursor(this.varType);
  97.                }
  98.  
  99.                if (var1.target.equals(this.varType)) {
  100.                   this.user.u.cursor(this.varDesc);
  101.                }
  102.  
  103.                if (var1.target.equals(this.varDesc)) {
  104.                   this.user.u.cursor(this.publicCheck);
  105.                }
  106.  
  107.                if (var1.target.equals(this.publicCheck)) {
  108.                   this.user.u.cursor(this.staticCheck);
  109.                }
  110.  
  111.                if (var1.target.equals(this.staticCheck)) {
  112.                   this.user.u.cursor(this.finalCheck);
  113.                }
  114.  
  115.                if (var1.target.equals(this.finalCheck)) {
  116.                   this.user.u.cursor(this.varName);
  117.                }
  118.             }
  119.  
  120.             if (var1.key == 9 && var1.modifiers == 1) {
  121.                if (var1.target.equals(this.varName)) {
  122.                   this.user.u.cursor(this.finalCheck);
  123.                   return true;
  124.                }
  125.  
  126.                if (var1.target.equals(this.varType)) {
  127.                   this.user.u.cursor(this.varName);
  128.                   return true;
  129.                }
  130.  
  131.                if (var1.target.equals(this.varDesc)) {
  132.                   this.user.u.cursor(this.varType);
  133.                   return true;
  134.                }
  135.  
  136.                if (var1.target.equals(this.publicCheck)) {
  137.                   this.user.u.cursor(this.varDesc);
  138.                   return true;
  139.                }
  140.  
  141.                if (var1.target.equals(this.staticCheck)) {
  142.                   this.user.u.cursor(this.publicCheck);
  143.                   return true;
  144.                }
  145.  
  146.                if (var1.target.equals(this.finalCheck)) {
  147.                   this.user.u.cursor(this.staticCheck);
  148.                   return true;
  149.                }
  150.             }
  151.  
  152.             return false;
  153.          case 503:
  154.          case 504:
  155.          case 505:
  156.             this.popuppanel.postEvent(var1);
  157.             return false;
  158.          case 1001:
  159.             if (var1.target.equals(this.varType)) {
  160.                this.sendLostFocus();
  161.                return true;
  162.             } else if (var1.target.equals(this.publicCheck)) {
  163.                if (this.publicCheck.getState()) {
  164.                   this.privateCheck.setState(false);
  165.                }
  166.  
  167.                this.sendLostFocus();
  168.                return true;
  169.             } else if (var1.target.equals(this.privateCheck)) {
  170.                if (this.privateCheck.getState()) {
  171.                   this.publicCheck.setState(false);
  172.                }
  173.  
  174.                this.sendLostFocus();
  175.                return true;
  176.             } else if (var1.target.equals(this.staticCheck)) {
  177.                this.sendLostFocus();
  178.                return true;
  179.             } else if (var1.target.equals(this.finalCheck)) {
  180.                this.sendLostFocus();
  181.                return true;
  182.             } else {
  183.                if (var1.target.equals(this.transientCheck)) {
  184.                   this.sendLostFocus();
  185.                   return true;
  186.                }
  187.  
  188.                return false;
  189.             }
  190.          case 1005:
  191.             if (var1.target.equals(this.varName)) {
  192.                this.sendLostFocus();
  193.                return true;
  194.             } else if (var1.target.equals(this.varType)) {
  195.                this.sendLostFocus();
  196.                return true;
  197.             } else {
  198.                if (var1.target.equals(this.varDesc)) {
  199.                   this.sendLostFocus();
  200.                   return true;
  201.                }
  202.  
  203.                return false;
  204.             }
  205.          default:
  206.             return false;
  207.       }
  208.    }
  209.  
  210.    public void InitComponents() {
  211.       this.jaggSQL.setKeepConnectionOpen(false);
  212.    }
  213.  
  214.    public void setVarName(String var1) {
  215.       this.varName.setText(var1);
  216.    }
  217.  
  218.    public String getVarName() {
  219.       StringTokenizer var1 = new StringTokenizer(this.varName.getText(), " ,~!@#$^&*()+=|\\`'\":;{}[]?/<>");
  220.  
  221.       String var2;
  222.       for(var2 = ""; var1.hasMoreTokens(); var2 = var2 + var1.nextToken()) {
  223.       }
  224.  
  225.       this.varName.setText(var2);
  226.       return this.varName.getText();
  227.    }
  228.  
  229.    public String getVarType() {
  230.       StringTokenizer var1 = new StringTokenizer(this.varType.getText(), " ,~!@#$^&*()+=|\\`'\":;{}[]?/<>");
  231.  
  232.       String var2;
  233.       for(var2 = ""; var1.hasMoreTokens(); var2 = var2 + var1.nextToken()) {
  234.       }
  235.  
  236.       this.varType.setText(var2);
  237.       return this.varType.getText();
  238.    }
  239.  
  240.    public void setVarType(String var1) {
  241.       this.varType.setText(var1);
  242.    }
  243.  
  244.    public void setVarPublic(boolean var1) {
  245.       this.publicCheck.setState(var1);
  246.    }
  247.  
  248.    public boolean getVarPublic() {
  249.       return this.publicCheck.getState();
  250.    }
  251.  
  252.    public void setVarStatic(boolean var1) {
  253.       this.staticCheck.setState(var1);
  254.    }
  255.  
  256.    public boolean getVarStatic() {
  257.       return this.staticCheck.getState();
  258.    }
  259.  
  260.    public void setVarFinal(boolean var1) {
  261.       this.finalCheck.setState(var1);
  262.    }
  263.  
  264.    public boolean getVarFinal() {
  265.       return this.finalCheck.getState();
  266.    }
  267.  
  268.    public void setVarDesc(String var1) {
  269.       this.varDesc.setText(var1);
  270.    }
  271.  
  272.    public String getVarDesc() {
  273.       return this.varDesc.getText();
  274.    }
  275.  
  276.    public void setSourceItem(JDPSourceItem var1) {
  277.       if (var1.type == 3) {
  278.          this.setVarName(var1.name);
  279.          this.setVarType(var1.varType);
  280.          this.setVarDesc(var1.description);
  281.          this.setVarPublic(var1.ispublic);
  282.          this.setVarPrivate(var1.isprivate);
  283.          this.setVarStatic(var1.isstatic);
  284.          this.setVarFinal(var1.isfinal);
  285.          this.setVarTransient(var1.istransient);
  286.       }
  287.    }
  288.  
  289.    public void setVarPrivate(boolean var1) {
  290.       this.privateCheck.setState(var1);
  291.    }
  292.  
  293.    public boolean getVarPrivate() {
  294.       return this.privateCheck.getState();
  295.    }
  296.  
  297.    public void setVarTransient(boolean var1) {
  298.       this.transientCheck.setState(var1);
  299.    }
  300.  
  301.    public boolean getVarTransient() {
  302.       return this.transientCheck.getState();
  303.    }
  304.  
  305.    public JDPSourceItem getSourceItem() {
  306.       JDPSourceItem var1 = new JDPSourceItem();
  307.       return this.updateSourceItem(var1);
  308.    }
  309.  
  310.    public void sendLostFocus() {
  311.       Event var1 = new Event(this, 1005, (Object)null);
  312.       ((Component)this).getParent().postEvent(var1);
  313.    }
  314.  
  315.    public JDPSourceItem updateSourceItem(JDPSourceItem var1) {
  316.       var1.type = 3;
  317.       var1.name = this.getVarName();
  318.       var1.varType = this.getVarType();
  319.       var1.description = this.getVarDesc();
  320.       var1.ispublic = this.getVarPublic();
  321.       var1.isprivate = this.getVarPrivate();
  322.       var1.isstatic = this.getVarStatic();
  323.       var1.isfinal = this.getVarFinal();
  324.       var1.istransient = this.getVarTransient();
  325.       return var1;
  326.    }
  327.  
  328.    public void varTypeMain() {
  329.       if (this.varType == null) {
  330.          this.varType = new JDPComboBox(this.user);
  331.       }
  332.  
  333.       String[] var1 = new String[]{"int                   ", "boolean", "String", "long", "float", "int[]", "boolean[]", "String[]", "", "", "", "", "", "", "", "", "", "", "", ""};
  334.       this.varType.loadChoice(var1);
  335.    }
  336. }
  337.