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

  1. import java.awt.BorderLayout;
  2. import java.awt.Choice;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.Font;
  7. import java.awt.Panel;
  8. import java.awt.TextArea;
  9. import java.awt.TextField;
  10. import java.util.Vector;
  11.  
  12. public class JDPScreenBuild extends JDPClassLayout implements Runnable {
  13.    JDPProjectMgr targetProject;
  14.    JDPSearchResults searchResults;
  15.    Panel targetPanel;
  16.    String moduleParameter;
  17.    String layoutName;
  18.    Vector eventVector;
  19.    TextField className;
  20.    TextField classDesc;
  21.    TextField frameTitle;
  22.    Choice allowUpdates;
  23.    Choice allowInserts;
  24.    Choice allowDeletes;
  25.    Choice confirmDeletes;
  26.    TextArea compileResults;
  27.    Panel centerTopPanel;
  28.    Panel centerMainPanel;
  29.    JDPPanelLoader testPanel;
  30.    JDPPopupMessage popuppanel;
  31.    String pfromWhereClause;
  32.    String[] psortChoice;
  33.    String[] pdisplayChoice;
  34.    Vector gParmObject;
  35.    int thisScreenIndex;
  36.    JDPLayoutGenerator blg;
  37.    boolean sourceDisplayed;
  38.    String choice;
  39.    String appDir;
  40.  
  41.    boolean restoreSelections() {
  42.       JDPSaveProps var1 = super.user.saveProperties;
  43.       if (super.user.prevProperties != null) {
  44.          var1 = super.user.prevProperties;
  45.       }
  46.  
  47.       String var2 = "JDPScreenBuild";
  48.       var1.restoreObject(this.classDesc, var2, "classDesc");
  49.       var1.restoreObject(this.frameTitle, var2, "frameTitle");
  50.       var1.restoreObject(this.allowUpdates, var2, "allowUpdates");
  51.       var1.restoreObject(this.allowInserts, var2, "allowInserts");
  52.       var1.restoreObject(this.allowDeletes, var2, "allowDeletes");
  53.       var1.restoreObject(this.confirmDeletes, var2, "confirmDeletes");
  54.       return true;
  55.    }
  56.  
  57.    void newSearch() {
  58.       String var1 = this.pfromWhereClause;
  59.       this.searchResults.setFromWhereClause(var1);
  60.       this.searchResults.clearList();
  61.       this.searchResults.loadList();
  62.       if (this.searchResults.treeRoot.leaves.size() > 0) {
  63.          JDPTreeBranch var2 = (JDPTreeBranch)this.searchResults.treeRoot.leaves.elementAt(0);
  64.          var2.expanded = true;
  65.       }
  66.  
  67.    }
  68.  
  69.    void retrieveTargets() {
  70.       for(int var1 = 0; var1 < super.user.gParm.size(); ++var1) {
  71.          if (super.user.gParm.elementAt(var1) instanceof JDPProjectMgr) {
  72.             this.targetProject = (JDPProjectMgr)super.user.gParm.elementAt(var1);
  73.             if (this.targetProject.projectType.equals("W")) {
  74.                String var2 = "";
  75.                if (this.targetProject != null) {
  76.                   var2 = this.targetProject.ClassDesc.getText();
  77.                }
  78.  
  79.                this.classDesc.setText(var2);
  80.                this.frameTitle.setText(var2);
  81.             } else {
  82.                this.targetProject = null;
  83.             }
  84.          }
  85.       }
  86.  
  87.    }
  88.  
  89.    boolean saveSelections() {
  90.       JDPSaveProps var1 = super.user.saveProperties;
  91.       String var2 = "JDPScreenBuild";
  92.       var1.saveObject(this.classDesc, var2, "classDesc");
  93.       var1.saveObject(this.frameTitle, var2, "frameTitle");
  94.       var1.saveObject(this.allowUpdates, var2, "allowUpdates");
  95.       var1.saveObject(this.allowInserts, var2, "allowInserts");
  96.       var1.saveObject(this.allowDeletes, var2, "allowDeletes");
  97.       var1.saveObject(this.confirmDeletes, var2, "confirmDeletes");
  98.       return true;
  99.    }
  100.  
  101.    void loadSource() {
  102.       this.compileResults.setText("");
  103.       super.user.mainmsg.setStatusMsg("Loading source file...", 0);
  104.       String var1 = super.user.u.readFromFile(this.appDir + this.className.getText() + ".java");
  105.       if (var1 != null) {
  106.          this.compileResults.setText(var1);
  107.       }
  108.  
  109.    }
  110.  
  111.    public boolean handleEvent(Event var1) {
  112.       switch (var1.id) {
  113.          case 202:
  114.             if (var1.target instanceof JDPTabSelectPanel) {
  115.                if (this.targetProject == null) {
  116.                   this.retrieveTargets();
  117.                }
  118.  
  119.                return true;
  120.             }
  121.  
  122.             return false;
  123.          case 401:
  124.             if (var1.key == 9) {
  125.                if (var1.target.equals(this.className)) {
  126.                   super.user.u.cursor(this.classDesc);
  127.                   return true;
  128.                }
  129.  
  130.                if (var1.target.equals(this.classDesc)) {
  131.                   super.user.u.cursor(this.frameTitle);
  132.                   return true;
  133.                }
  134.  
  135.                if (var1.target.equals(this.frameTitle)) {
  136.                   super.user.u.cursor(this.allowUpdates);
  137.                   return true;
  138.                }
  139.  
  140.                if (var1.target.equals(this.allowUpdates)) {
  141.                   super.user.u.cursor(this.allowInserts);
  142.                   return true;
  143.                }
  144.  
  145.                if (var1.target.equals(this.allowInserts)) {
  146.                   super.user.u.cursor(this.allowDeletes);
  147.                   return true;
  148.                }
  149.  
  150.                if (var1.target.equals(this.allowDeletes)) {
  151.                   super.user.u.cursor(this.confirmDeletes);
  152.                   return true;
  153.                }
  154.  
  155.                if (var1.target.equals(this.confirmDeletes)) {
  156.                   super.user.u.cursor(this.className);
  157.                   return true;
  158.                }
  159.             }
  160.  
  161.             return false;
  162.          case 503:
  163.          case 504:
  164.          case 505:
  165.             this.popuppanel.postEvent(var1);
  166.             return false;
  167.          case 1001:
  168.             this.eventVector.addElement(var1);
  169.             Thread var2 = new Thread(this);
  170.             var2.start();
  171.             return true;
  172.          default:
  173.             return false;
  174.       }
  175.    }
  176.  
  177.    public void run() {
  178.       Event var1 = (Event)this.eventVector.elementAt(0);
  179.       this.eventVector.removeElementAt(0);
  180.       switch (var1.id) {
  181.          case 1001:
  182.             if (var1.target instanceof JDPTreePicker && var1.target.equals(this.searchResults.tree)) {
  183.                this.className.setText(this.searchResults.recordKey1[this.searchResults.getSelectedIndex()]);
  184.                this.loadSource();
  185.                this.sourceDisplayed = true;
  186.                return;
  187.             } else if (var1.target instanceof JDPButton) {
  188.                String var2 = (String)var1.arg;
  189.                if (var2.trim().equals("Build") || var2.trim().equals("Final Build")) {
  190.                   this.choice = var2;
  191.                   this.buildProject();
  192.                   return;
  193.                } else if (var2.trim().compareTo("Load Source") == 0) {
  194.                   if (this.targetProject != null) {
  195.                      this.className.setText(this.targetProject.ClassName.getText());
  196.                   }
  197.  
  198.                   this.loadSource();
  199.                   this.sourceDisplayed = true;
  200.                   return;
  201.                } else if (var2.trim().compareTo("Save") == 0) {
  202.                   if (!this.sourceDisplayed) {
  203.                      super.user.mainmsg.setStatusMsg("You must load the source before you can save it.", 7);
  204.                      return;
  205.                   } else {
  206.                      if (this.blg == null) {
  207.                         this.blg = new JDPLayoutGenerator(super.user, this.layoutName, this.className.getText());
  208.                      }
  209.  
  210.                      if (this.blg != null) {
  211.                         super.user.mainmsg.setStatusMsg("Saving source...", 0);
  212.                         this.blg.outputText = this.compileResults.getText();
  213.                         if (super.user.u.writeToFile(this.appDir + this.className.getText().trim() + ".java", this.blg.outputText, "w+")) {
  214.                            super.user.mainmsg.setStatusMsg("Source file successfully saved.", 5);
  215.                            return;
  216.                         }
  217.  
  218.                         super.user.mainmsg.setStatusMsg("Could not save source file.", 10);
  219.                      }
  220.  
  221.                      return;
  222.                   }
  223.                } else if (var2.trim().compareTo("Compile") == 0) {
  224.                   String var3 = "-d " + super.user.JDesignerPro.JDPDirectory + " ";
  225.                   String var4 = super.user.JDesignerPro.JDPCompiler + " -classpath " + super.user.JDesignerPro.JDPClasses + JDesignerPro.pathDelimiter + super.user.JDesignerPro.JDPDirectory + " " + var3 + this.appDir + this.className.getText().trim() + ".java";
  226.                   if (super.user.JDesignerPro.JDPCompiler.toUpperCase().indexOf("JVC") >= 0 && JDPJagg.useJaggServer) {
  227.                      var4 = super.user.JDesignerPro.JDPCompiler + " " + var3 + this.appDir + this.className.getText().trim() + ".java";
  228.                   }
  229.  
  230.                   JDPCommandExecuter var5 = new JDPCommandExecuter(super.user, var4, "Compiling source code...", "Screen compiled successfully.", "Compile failed.");
  231.                   String var6 = "";
  232.                   if (var5.success) {
  233.                      if (this.testPanel != null) {
  234.                         this.testPanel.removeAll();
  235.                         super.user.JDPBuildTestPanel[this.thisScreenIndex].remove(this.testPanel);
  236.                         this.testPanel = null;
  237.                      } else {
  238.                         this.thisScreenIndex = super.user.JDPBuildTestPanelIndex++;
  239.                      }
  240.  
  241.                      super.user.JDPBuildTestPanel[this.thisScreenIndex].setLayout(new BorderLayout());
  242.                      this.testPanel = new JDPPanelLoader(super.user, this.className.getText());
  243.                      super.user.JDPBuildTestPanel[this.thisScreenIndex].add("Center", this.testPanel);
  244.                      super.user.JDPBuildTestPanel[this.thisScreenIndex].paintAll(super.user.JDPBuildTestPanel[this.thisScreenIndex].getGraphics());
  245.                      super.user.jdpMenuPanel.loadNextTab();
  246.                      return;
  247.                   }
  248.  
  249.                   for(int var7 = 0; var7 < var5.results.size(); ++var7) {
  250.                      var6 = var6 + var5.results.elementAt(var7) + "\n";
  251.                   }
  252.  
  253.                   this.sourceDisplayed = false;
  254.                   this.compileResults.setText(var6);
  255.                   return;
  256.                }
  257.             }
  258.          default:
  259.       }
  260.    }
  261.  
  262.    public void InitClass(JDPUser var1, Panel var2, String var3) {
  263.       super.user = var1;
  264.       this.targetPanel = var2;
  265.       int var4 = var3.indexOf(" ");
  266.       if (var4 > 0) {
  267.          this.layoutName = "JDPLayout" + var3.substring(0, var4);
  268.          var3 = var3.substring(var4 + 1);
  269.       } else {
  270.          this.layoutName = "JDPLayout" + var3;
  271.          var3 = "";
  272.       }
  273.  
  274.       this.moduleParameter = var3;
  275.       this.appDir = var1.JDesignerPro.JDPDirectory + "Applications" + JDesignerPro.serverSeparator + "Wizard" + JDesignerPro.serverSeparator;
  276.       this.eventVector = new Vector();
  277.       ((Container)this).setLayout(new BorderLayout());
  278.       ((Component)this).setFont(var1.plainFont);
  279.       Panel var5 = new Panel();
  280.       ((Container)var5).setLayout(new BorderLayout());
  281.       Panel var6 = new Panel();
  282.       ((Container)var6).setLayout(new BorderLayout());
  283.       this.centerMainPanel = new Panel();
  284.       this.centerMainPanel.setLayout(new BorderLayout());
  285.       this.centerTopPanel = new Panel();
  286.       this.centerTopPanel.setLayout(new JDPRowLayout(1, 1));
  287.       Panel var7 = new Panel();
  288.       ((Container)var7).setLayout(new BorderLayout());
  289.       Panel var8 = new Panel();
  290.       ((Container)var8).setLayout(new BorderLayout());
  291.       Panel var9 = new Panel();
  292.       ((Container)var9).setLayout(new BorderLayout());
  293.       String var10 = "b.JDPSystem,a.ClassName";
  294.       String[] var11 = new String[]{"ClassName"};
  295.       this.pfromWhereClause = "FROM JDPClassDef a, JDPSystemDef b WHERE a.JDPSystem = b.JDPSystem AND a.JDPSystem = '" + var1.JDPSystem + "' AND a.projtype = 'W'";
  296.       this.psortChoice = new String[1];
  297.       this.psortChoice[0] = "b.JDPSystemD";
  298.       String[] var12 = new String[]{"Jdpsystem"};
  299.       this.pdisplayChoice = this.psortChoice;
  300.       boolean var13 = false;
  301.       String var14 = "Total Entries:";
  302.       this.className = new TextField("DemoClass", 20);
  303.       this.classDesc = new TextField("", 40);
  304.       this.frameTitle = new TextField("", 30);
  305.       this.allowUpdates = new Choice();
  306.       this.allowUpdates.addItem("Yes");
  307.       this.allowUpdates.addItem("No");
  308.       this.allowInserts = new Choice();
  309.       this.allowInserts.addItem("Yes");
  310.       this.allowInserts.addItem("No");
  311.       this.allowDeletes = new Choice();
  312.       this.allowDeletes.addItem("Yes");
  313.       this.allowDeletes.addItem("No");
  314.       this.confirmDeletes = new Choice();
  315.       this.confirmDeletes.addItem("Yes");
  316.       this.confirmDeletes.addItem("No");
  317.       this.compileResults = new TextArea("", 2, 60);
  318.       this.compileResults.setFont(new Font("Courier", 0, 12));
  319.       if (var3.compareTo("") != 0 && var3.compareTo("IDE") != 0) {
  320.          this.allowUpdates.select(1);
  321.          this.allowUpdates.disable();
  322.          this.allowInserts.select(1);
  323.          this.allowInserts.disable();
  324.          this.allowDeletes.select(1);
  325.          this.allowDeletes.disable();
  326.          this.confirmDeletes.select(1);
  327.          this.confirmDeletes.disable();
  328.          String var15 = Long.toString(System.currentTimeMillis());
  329.          var15 = var3 + var15.substring(var15.length() - 6);
  330.          this.className.setText(var15);
  331.          this.className.setEditable(false);
  332.       }
  333.  
  334.       if (var3.compareTo("IDE") != 0) {
  335.          this.centerMainPanel.add("North", this.centerTopPanel);
  336.          this.centerTopPanel.add("Left", new JDPWrapLabel(var1, "Class Description:"));
  337.          this.centerTopPanel.add("Right", this.classDesc);
  338.          this.centerTopPanel.add("Left", new JDPWrapLabel(var1, "Frame Text Title:"));
  339.          this.centerTopPanel.add("Right", this.frameTitle);
  340.          this.centerTopPanel.add("Left", new JDPWrapLabel(var1, "Allow Updates:"));
  341.          Panel var21 = new Panel();
  342.          ((Container)var21).setLayout(new JDPLineLayout(3));
  343.          if (this.layoutName.equals("JDPLayout1") || this.layoutName.equals("JDPLayout2") || this.layoutName.equals("JDPLayout3")) {
  344.             this.centerTopPanel.add("Right", var21);
  345.             ((Container)var21).add("Left", this.allowUpdates);
  346.             ((Container)var21).add("Left", new JDPWrapLabel(var1, "Allow Inserts:"));
  347.             ((Container)var21).add("Left", this.allowInserts);
  348.             ((Container)var21).add("Left", new JDPWrapLabel(var1, "Allow Deletes:"));
  349.             ((Container)var21).add("Left", this.allowDeletes);
  350.             ((Container)var21).add("Left", new JDPWrapLabel(var1, "Confirm:"));
  351.             ((Container)var21).add("Left", this.confirmDeletes);
  352.          }
  353.  
  354.          this.restoreSelections();
  355.       }
  356.  
  357.       ((Container)var8).add("Center", this.compileResults);
  358.       if (var3.compareTo("IDE") != 0) {
  359.          ((Container)var7).add("Center", new JDPChiselFramePanel(var1, "Compile Results", var8, "North"));
  360.       } else {
  361.          ((Container)var7).add("Center", var8);
  362.       }
  363.  
  364.       this.centerMainPanel.add("Center", var7);
  365.       String var22 = "Build the class file";
  366.       this.popuppanel = new JDPPopupMessage(var1, var2);
  367.       if (var3.compareTo("IDE") != 0) {
  368.          String[] var16 = new String[]{"Build", "Final Build", "Load Source", "Save", "Compile"};
  369.          int[] var17 = new int[]{3, 3, 1, 0, 2};
  370.          JDPButtons var18 = new JDPButtons(var1, var16, var17, JDPButtons.HORIZONTAL);
  371.          this.centerMainPanel.add("South", var18);
  372.          this.popuppanel.addComponent(var18.button[0], "Save, Build, Compile and Load new class", "Generate a preliminary Build to prior to running the final build finished product");
  373.          this.popuppanel.addComponent(var18.button[1], "Final Build", "Run a final Build if the preliminary build is complete and requires no more changes");
  374.          this.popuppanel.addComponent(var18.button[2], "Load Source", "Load the source file specified in the Name field");
  375.          this.popuppanel.addComponent(var18.button[3], "Save Source", "Save the source file specified in the Name field");
  376.          this.popuppanel.addComponent(var18.button[4], "Compile and Load Source", "Compile the source file specified in the Name field and load the result");
  377.          if (var3.compareTo("") != 0) {
  378.             var18.button[1].disable();
  379.             var18.button[2].disable();
  380.             var18.button[3].disable();
  381.             var18.button[4].disable();
  382.          }
  383.       } else {
  384.          var22 = "Source editor and compiler";
  385.          String[] var23 = new String[]{"Save", "Compile"};
  386.          int[] var25 = new int[]{0, 2};
  387.          JDPButtons var26 = new JDPButtons(var1, var23, var25, JDPButtons.HORIZONTAL);
  388.          this.centerMainPanel.add("South", var26);
  389.          this.popuppanel.addComponent(var26.button[0], "Save Source", "Save the source file specified in the Name field");
  390.          this.popuppanel.addComponent(var26.button[1], "Compile and Load Source", "Compile the source file specified in the Name field and load the result");
  391.       }
  392.  
  393.       ((Container)var2).add(this.popuppanel);
  394.       ((Container)var5).add("Center", this.centerMainPanel);
  395.       if (var3.equals("IDE")) {
  396.          this.searchResults = new JDPSearchResults(var1, var2, true, var1.jaggSQL, false, var10, var11, this.pfromWhereClause, var12, this.psortChoice, this.pdisplayChoice, "", var13, var14);
  397.          int[] var24 = new int[]{4, 2, 1};
  398.          this.searchResults.setIcons(var24);
  399.          this.searchResults.setMinWidth(160);
  400.          ((Container)var9).add("Center", this.searchResults);
  401.          ((Container)var5).add("West", var9);
  402.          this.newSearch();
  403.       }
  404.  
  405.       ((Container)this).add("Center", new JDPChiselFramePanel(var1, var22, var5, "North"));
  406.       this.retrieveTargets();
  407.       this.gParmObject = new Vector();
  408.       this.gParmObject.addElement("ScreenBuild");
  409.       this.gParmObject.addElement(this);
  410.       var1.gParm.addElement(this.gParmObject);
  411.       ((Component)var2).paintAll(((Component)var2).getGraphics());
  412.    }
  413.  
  414.    void buildProject() {
  415.       this.saveSelections();
  416.       if (this.targetProject != null) {
  417.          this.targetProject.saveData();
  418.       }
  419.  
  420.       super.user.saveProperties.save(this.appDir + this.targetProject.ClassName.getText() + ".jdp");
  421.       String var1 = "DEL ";
  422.       if (JDesignerPro.pathDelimiter.equals(":")) {
  423.          var1 = "rm ";
  424.       }
  425.  
  426.       if (!JDPJagg.useJaggServer) {
  427.          new JDPCommandExecuter(super.user, var1 + this.appDir + this.className.getText().trim() + ".java", "", "", "");
  428.          new JDPCommandExecuter(super.user, var1 + this.appDir + this.className.getText().trim() + ".class", "", "", "");
  429.       }
  430.  
  431.       String var2 = this.appDir;
  432.       if (this.choice.trim().equals("Build")) {
  433.          String var3 = Long.toString(System.currentTimeMillis());
  434.          var3 = "Prelim" + var3.substring(var3.length() - 6);
  435.          this.className.setText(var3);
  436.          var2 = super.user.JDesignerPro.JDPDirectory + "Temp" + JDesignerPro.serverSeparator;
  437.       } else {
  438.          this.className.setText(this.targetProject.ClassName.getText());
  439.       }
  440.  
  441.       super.user.mainmsg.setStatusMsg("Loading JDPLayoutGenerator...", 0);
  442.       this.blg = new JDPLayoutGenerator(super.user, this.layoutName, this.className.getText());
  443.       if (this.blg != null && this.blg.readyToBuild() && this.blg.buildJava()) {
  444.          String var9 = "-d " + super.user.JDesignerPro.JDPDirectory + " ";
  445.          String var4 = super.user.JDesignerPro.JDPCompiler + " -classpath " + super.user.JDesignerPro.JDPClasses + JDesignerPro.pathDelimiter + super.user.JDesignerPro.JDPDirectory + " " + var9 + var2 + this.className.getText().trim() + ".java";
  446.          if (super.user.JDesignerPro.JDPCompiler.indexOf("JVC") >= 0 && JDPJagg.useJaggServer) {
  447.             var4 = super.user.JDesignerPro.JDPCompiler + " " + var9 + " " + var2 + this.className.getText().trim() + ".java";
  448.          }
  449.  
  450.          JDPCommandExecuter var5 = new JDPCommandExecuter(super.user, var4, "Compiling source code...", "Screen compiled successfully.", "Compile failed.");
  451.          String var6 = "";
  452.          if (var5.success) {
  453.             this.sourceDisplayed = false;
  454.             this.compileResults.setText("");
  455.             if (this.testPanel != null) {
  456.                this.testPanel.removeAll();
  457.                super.user.JDPBuildTestPanel[this.thisScreenIndex].remove(this.testPanel);
  458.                this.testPanel = null;
  459.             } else {
  460.                this.thisScreenIndex = super.user.JDPBuildTestPanelIndex++;
  461.             }
  462.  
  463.             super.user.JDPBuildTestPanel[this.thisScreenIndex].setLayout(new BorderLayout());
  464.             this.testPanel = new JDPPanelLoader(super.user, this.className.getText());
  465.             super.user.JDPBuildTestPanel[this.thisScreenIndex].add("Center", this.testPanel);
  466.             super.user.JDPBuildTestPanel[this.thisScreenIndex].paintAll(super.user.JDPBuildTestPanel[this.thisScreenIndex].getGraphics());
  467.             if (this.moduleParameter.compareTo("IDE") != 0) {
  468.                super.user.jdpMenuPanel.loadNextTab();
  469.                return;
  470.             }
  471.          } else {
  472.             for(int var7 = 0; var7 < var5.results.size(); ++var7) {
  473.                var6 = var6 + var5.results.elementAt(var7) + "\n";
  474.             }
  475.  
  476.             this.compileResults.setText(var6);
  477.             this.sourceDisplayed = false;
  478.          }
  479.       }
  480.  
  481.    }
  482. }
  483.