home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Library / msjOptions.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  16.5 KB  |  744 lines

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. // This script sets up the initial standard options for Microsoft's Java 
  5. // development kit.  
  6.  
  7. var helpers = getMapFile("ApplicationHelpers");
  8. var gOptions = getMapFile("MSJToolsStandardOptions");
  9.  
  10. function DoCommand()
  11. {
  12.   alert("The msjOptions script only contains funtions\nthat can be used by other scripts");
  13. }
  14.  
  15. function GetRunOptions()
  16. {
  17.   var options;
  18.   var runInWindow = gOptions.lookup("runInWindow", true);
  19.   if (runInWindow)
  20.   {
  21.     options = gOptions.lookup("msj-wjview", "");
  22.   }
  23.   else
  24.   {
  25.     options = gOptions.lookup("msj-jview", "");
  26.   }
  27.   return options;
  28. }
  29.  
  30. function ChooseRunOptions()
  31. {
  32.   var standardOptions;
  33.   var runInWindow = gOptions.lookup("runInWindow", true);
  34.   if (runInWindow)
  35.   {
  36.     standardOptions = gOptions.lookup("msj-wjview", "");
  37.   }
  38.   else
  39.   {
  40.     standardOptions = gOptions.lookup("msj-jview", "");
  41.   }
  42.  
  43.   var editedOptions = RunOptions(standardOptions);
  44.   
  45.   if (editedOptions != null)
  46.   {
  47.     // Get the value again because RunOptions may have changed it
  48.     runInWindow = gOptions.lookup("runInWindow", true);
  49.     if (runInWindow)
  50.     {
  51.       gOptions.setValue("msj-wjview", editedOptions);
  52.     }
  53.     else
  54.     {
  55.       gOptions.setValue("msj-jview", editedOptions);
  56.     }
  57.   }
  58. }
  59.  
  60. function CompileOptions(value)
  61. {
  62.   // Input value should be a string containing
  63.   // existing options
  64.   
  65.   if (typeof(value) != "string")
  66.   {
  67.     return value;
  68.   }
  69.   
  70.   // Function must return a string of selected options.
  71.   // Any options not included are appended to the 
  72.   // the end of the returned string.
  73.   
  74.   var list = newList();
  75.   var checked = newList();
  76.   var action = newList();
  77.   
  78.   value = AddOption(
  79.     list,
  80.     checked,
  81.     "Disable Microsoft Java extensions ( /x )",
  82.     "/x",
  83.     value,
  84.     action, null);
  85.  
  86.   // debugging tables
  87.   value = AddOption(
  88.     list,
  89.     checked,
  90.     "Generate all debugging information. ( /g )",
  91.     "/g",
  92.     value,
  93.     action, null);
  94.  
  95.   value = AddOption(
  96.     list,
  97.     checked,
  98.     "Generate line number debugging information. ( /g:l )",
  99.     "/g:l",
  100.     value,
  101.     action, null);
  102.  
  103.   value = AddOption(
  104.     list,
  105.     checked,
  106.     "Generate debug tables. ( /g:t )",
  107.     "/g:l",
  108.     value,
  109.     action, null);
  110.  
  111.   value = AddOption(
  112.     list,
  113.     checked,
  114.     "Do not generate class file ( /nowrite )",
  115.     "/nowrite",
  116.     value,
  117.     action, null);
  118.   
  119.   // optimiation
  120.   value = AddOption(
  121.     list,
  122.     checked,
  123.     "Optimize run time  ( /O )",
  124.     "/O",
  125.     value,
  126.     action, null);
  127.     
  128.   value = AddOption(
  129.     list,
  130.     checked,
  131.     "Optimize by inlining methods  ( /O:I )",
  132.     "/O:I",
  133.     value,
  134.     action, null);
  135.  
  136.   value = AddOption(
  137.     list,
  138.     checked,
  139.     "Optimize byte codes - default  ( /O:J )",
  140.     "/O:J",
  141.     value,
  142.     action, null);
  143.  
  144.   // verbose
  145.   value = AddOption(
  146.     list,
  147.     checked,
  148.     "Output additional information ( /verbose )",
  149.     "/verbose",
  150.     value,
  151.     action, null);
  152.  
  153.   // Warning levels
  154.   value = AddOption(
  155.     list,
  156.     checked,
  157.     "Set warning level 0 ( /w0 )",
  158.     "/w0",
  159.     value,
  160.     action, null);
  161.  
  162.   value = AddOption(
  163.     list,
  164.     checked,
  165.     "Set warning level 1 ( /w1 )",
  166.     "/w1",
  167.     value,
  168.     action, null);
  169.  
  170.   value = AddOption(
  171.     list,
  172.     checked,
  173.     "Set warning level 2 - default ( /w2 )",
  174.     "/w2",
  175.     value,
  176.     action, null);
  177.  
  178.   value = AddOption(
  179.     list,
  180.     checked,
  181.     "Set warning level 3 ( /w3 )",
  182.     "/w3",
  183.     value,
  184.     action, null);
  185.  
  186.   value = AddOption(
  187.     list,
  188.     checked,
  189.     "Set warning level 4 ( /w4 )",
  190.     "/w4",
  191.     value,
  192.     action, null);
  193.  
  194.  
  195.   var result = chooseOptions("Choose Options",
  196.     "Choose compile options", list, checked);
  197.   
  198.   // result is a list of booleans 
  199.   if (result)
  200.   {
  201.     var listPosition = list.getHeadPosition();
  202.     var resultPosition = result.getHeadPosition();
  203.     var returnValue = "";
  204.     while (resultPosition.valid && listPosition.valid)
  205.     {
  206.       var selected = result.getNext(resultPosition);
  207.       var item = list.getNext(listPosition);
  208.       
  209.       if (selected)
  210.       {
  211.         // Separate from the previous using a space
  212.         if (returnValue.length > 0)
  213.         {
  214.           returnValue += " ";
  215.         }
  216.         returnValue += item.value;
  217.       }
  218.     }
  219.     
  220.     // Add what's left over if there is any non-space data in value
  221.     // Note: the expression "[^ ]" matches the first non-space
  222.     // character in value
  223.     
  224.     if (value.length > 0)
  225.     {
  226.       // Don't add extra spaces
  227.       var nonspace = searchInString(value, "[^ ]");
  228.       if (nonspace)
  229.       {
  230.         returnValue += " " + 
  231.           value.substring(nonspace.value, value.length);
  232.       }
  233.     }
  234.     return returnValue;
  235.   }
  236.   return null;
  237. }
  238.  
  239.  
  240. function RunOptions(value)
  241. {
  242.   // Input value should be a string containing
  243.   // existing options
  244.   
  245.   if (typeof(value) != "string")
  246.   {
  247.     return value;
  248.   }
  249.   
  250.   // Function must return a string of selected options.
  251.   // Any options not included are appended to the 
  252.   // the end of the returned string.
  253.   
  254.   var list = newList();
  255.   var checked = newList();
  256.   var action = newList();
  257.  
  258.   AddSpecialOption(
  259.     list,
  260.     checked,
  261.     "Show command line",
  262.     "",
  263.     gOptions.lookup("showCommandLine", false),
  264.     action, null);
  265.  
  266.   AddSpecialOption(
  267.     list,
  268.     checked,
  269.     "Run in window ( use wjview )",
  270.     "",
  271.     gOptions.lookup("runInWindow", true),
  272.     action, null);
  273.  
  274.   AddSpecialOption(
  275.     list,
  276.     checked,
  277.     "Show console window",
  278.     "",
  279.     gOptions.lookup("showConsoleWindow", false),
  280.     action, null);
  281.  
  282.   value = AddOption(
  283.     list,
  284.     checked,
  285.     "Pause before terminated if an error occurs ( /p )",
  286.     "/p",
  287.     value,
  288.     action, null);
  289.  
  290.   value = AddOption(
  291.     list,
  292.     checked,
  293.     "Verify all invoked methods ( /v )",
  294.     "/v",
  295.     value,
  296.     action, null);
  297.   
  298.   var result = chooseOptions("Choose Options",
  299.     "Choose java runtime options", list, checked,
  300.     null, true, "Classpaths...", EditClasspaths);
  301.   
  302.   // result is a list of booleans 
  303.   if (result)
  304.   {
  305.     var listPosition = list.getHeadPosition();
  306.     var resultPosition = result.getHeadPosition();
  307.     var returnValue = "";
  308.     
  309.     var selected = result.getNext(resultPosition);
  310.     var item = list.getNext(listPosition);
  311.     gOptions.setValue("showCommandLine", selected);
  312.     
  313.     selected = result.getNext(resultPosition);
  314.     item = list.getNext(listPosition);
  315.     gOptions.setValue("runInWindow", selected);
  316.     
  317.     selected = result.getNext(resultPosition);
  318.     item = list.getNext(listPosition);
  319.     gOptions.setValue("showConsoleWindow", selected);
  320.     
  321.     while (resultPosition.valid && listPosition.valid)
  322.     {
  323.       selected = result.getNext(resultPosition);
  324.       item = list.getNext(listPosition);
  325.       
  326.       if (selected )
  327.       {
  328.         // Separate from the previous using a space
  329.         if (returnValue.length > 0)
  330.         {
  331.           returnValue += " ";
  332.         }
  333.         returnValue += item.value;
  334.       }
  335.     }
  336.     
  337.     // Add what's left over if there is any non-space data in value
  338.     // Note: the expression "[^ ]" matches the first non-space
  339.     // character in value
  340.     
  341.     if (value.length > 0)
  342.     {
  343.       // Don't add extra spaces
  344.       var nonspace = searchInString(value, "[^ ]");
  345.       if (nonspace)
  346.       {
  347.         returnValue += " " + 
  348.           value.substring(nonspace.value, value.length);
  349.       }
  350.     }
  351.     return returnValue;
  352.   }
  353.   return null;
  354. }
  355.  
  356. function EditClasspaths()
  357. {
  358.   var classpaths = gOptions.lookup("customClasspaths", ""); 
  359.   var classpathUtilities = getScriptObject("\\Library\\classpathUtilities");
  360.   
  361.   var newclasspaths = classpathUtilities.EditClasspaths(
  362.     "Edit MSJ custom classpaths (do not add a path for classes.zip)",
  363.     classpaths);
  364.   gOptions.setValue("customClasspaths", newclasspaths); 
  365. }
  366.  
  367. function JViewOptions(value)
  368. {
  369.   // Input value should be a string containing
  370.   // existing options
  371.   
  372.   if (typeof(value) != "string")
  373.   {
  374.     return value;
  375.   }
  376.   
  377.   // Function must return a string of selected options.
  378.   // Any options not included are appended to the 
  379.   // the end of the returned string.
  380.   
  381.   var list = newList();
  382.   var checked = newList();
  383.   var action = newList();
  384.   
  385.   value = AddOption(
  386.     list,
  387.     checked,
  388.     "Pause before terminated if an error occurs ( /p )",
  389.     "/p",
  390.     value,
  391.     action, null);
  392.  
  393.   value = AddOption(
  394.     list,
  395.     checked,
  396.     "Verify all invoked methods ( /v )",
  397.     "/v",
  398.     value,
  399.     action, null);
  400.   
  401.   var result = chooseOptions("Choose Options",
  402.     "Choose java runtime options", list, checked);
  403.   
  404.   // result is a list of booleans 
  405.   if (result)
  406.   {
  407.     var listPosition = list.getHeadPosition();
  408.     var resultPosition = result.getHeadPosition();
  409.     var returnValue = "";
  410.     while (resultPosition.valid && listPosition.valid)
  411.     {
  412.       var selected = result.getNext(resultPosition);
  413.       var item = list.getNext(listPosition);
  414.       
  415.       if (selected)
  416.       {
  417.         // Separate from the previous using a space
  418.         if (returnValue.length > 0)
  419.         {
  420.           returnValue += " ";
  421.         }
  422.         returnValue += item.value;
  423.       }
  424.     }
  425.     
  426.     // Add what's left over if there is any non-space data in value
  427.     // Note: the expression "[^ ]" matches the first non-space
  428.     // character in value
  429.     
  430.     if (value.length > 0)
  431.     {
  432.       // Don't add extra spaces
  433.       var nonspace = searchInString(value, "[^ ]");
  434.       if (nonspace)
  435.       {
  436.         returnValue += " " + 
  437.           value.substring(nonspace.value, value.length);
  438.       }
  439.     }
  440.     return returnValue;
  441.   }
  442.   return null;
  443. }
  444.  
  445. function WJViewOptions(value)
  446. {
  447.   // Input value should be a string containing
  448.   // existing options
  449.   
  450.   if (typeof(value) != "string")
  451.   {
  452.     return value;
  453.   }
  454.   
  455.   // Function must return a string of selected options.
  456.   // Any options not included are appended to the 
  457.   // the end of the returned string.
  458.   
  459.   var list = newList();
  460.   var checked = newList();
  461.   var action = newList();
  462.   
  463.   value = AddOption(
  464.     list,
  465.     checked,
  466.     "Verify all invoked methods ( /v )",
  467.     "/v",
  468.     value,
  469.     action, null);
  470.   
  471.   var result = chooseOptions("Choose Options",
  472.     "Choose java runtime options", list, checked);
  473.   
  474.   // result is a list of booleans 
  475.   if (result)
  476.   {
  477.     var listPosition = list.getHeadPosition();
  478.     var resultPosition = result.getHeadPosition();
  479.     var returnValue = "";
  480.     while (resultPosition.valid && listPosition.valid)
  481.     {
  482.       var selected = result.getNext(resultPosition);
  483.       var item = list.getNext(listPosition);
  484.       
  485.       if (selected)
  486.       {
  487.         // Separate from the previous using a space
  488.         if (returnValue.length > 0)
  489.         {
  490.           returnValue += " ";
  491.         }
  492.         returnValue += item.value;
  493.       }
  494.     }
  495.     
  496.     // Add what's left over if there is any non-space data in value
  497.     // Note: the expression "[^ ]" matches the first non-space
  498.     // character in value
  499.     
  500.     if (value.length > 0)
  501.     {
  502.       // Don't add extra spaces
  503.       var nonspace = searchInString(value, "[^ ]");
  504.       if (nonspace)
  505.       {
  506.         returnValue += " " + 
  507.           value.substring(nonspace.value, value.length);
  508.       }
  509.     }
  510.     return returnValue;
  511.   }
  512.   return null;
  513. }
  514.  
  515. function ClassViewOptions(value)
  516. {
  517.   // Input value should be a string containing
  518.   // existing options
  519.   
  520.   if (typeof(value) != "string")
  521.   {
  522.     return value;
  523.   }
  524.   
  525.   // Function must return a string of selected options.
  526.   // Any options not included are appended to the 
  527.   // the end of the returned string.
  528.   
  529.   var list = newList();
  530.   var checked = newList();
  531.   var action = newList();
  532.   
  533.   value = AddOption(
  534.     list,
  535.     checked,
  536.     "Display minimum infomation (D1, /min )",
  537.     "/min",
  538.     value,
  539.     action, null);
  540.  
  541.   value = AddOption(
  542.     list,
  543.     checked,
  544.     "Display minimum infomation (D1, D2 and D3, /ltd )",
  545.     "/ltd",
  546.     value,
  547.     action, null);
  548.  
  549.   value = AddOption(
  550.     list,
  551.     checked,
  552.     "Verbose display of information ( /v )",
  553.     "/v",
  554.     value,
  555.     action, null);
  556.  
  557.   value = AddOption(
  558.     list,
  559.     checked,
  560.     "Suppress display of constant pooling ( /cpno )",
  561.     "/cpno",
  562.     value,
  563.     action, null);
  564.  
  565.   value = AddOption(
  566.     list,
  567.     checked,
  568.     "Display many items in table form ( /tables )",
  569.     "/tables",
  570.     value,
  571.     action, null);
  572.  
  573.   value = AddOption(
  574.     list,
  575.     checked,
  576.     "Generate informal Virtual Machine Assembly Language ( /ivmal )",
  577.     "/ivmal",
  578.     value,
  579.     action, null);
  580.  
  581.   value = AddOption(
  582.     list,
  583.     checked,
  584.     "Send output to a file named by the package and class with the extension .cvue  ( /CVue )",
  585.     "/CVue",
  586.     value,
  587.     action, null);
  588.  
  589.   value = AddOption(
  590.     list,
  591.     checked,
  592.     "Quiet mode, suppresses copyright banner ( /q )",
  593.     "/q",
  594.     value,
  595.     action, null);
  596.  
  597.   value = AddOption(
  598.     list,
  599.     checked,
  600.     "Display the list of available options ( /? )",
  601.     "/?",
  602.     value,
  603.     action, null);
  604.  
  605.   value = AddOption(
  606.     list,
  607.     checked,
  608.     "Display list of information levels.  ( /D? )",
  609.     "/D?",
  610.     value,
  611.     action, null);
  612.  
  613.   value = AddOption(
  614.     list,
  615.     checked,
  616.     "Output information to help in reading the output ( /README )",
  617.     "/README",
  618.     value,
  619.     action, null);
  620.  
  621.   var result = chooseOptions("Choose Options",
  622.     "Choose java runtime options", list, checked);
  623.   
  624.   // result is a list of booleans 
  625.   if (result)
  626.   {
  627.     var listPosition = list.getHeadPosition();
  628.     var resultPosition = result.getHeadPosition();
  629.     var returnValue = "";
  630.     while (resultPosition.valid && listPosition.valid)
  631.     {
  632.       var selected = result.getNext(resultPosition);
  633.       var item = list.getNext(listPosition);
  634.       
  635.       if (selected)
  636.       {
  637.         // Separate from the previous using a space
  638.         if (returnValue.length > 0)
  639.         {
  640.           returnValue += " ";
  641.         }
  642.         returnValue += item.value;
  643.       }
  644.     }
  645.     
  646.     // Add what's left over if there is any non-space data in value
  647.     // Note: the expression "[^ ]" matches the first non-space
  648.     // character in value
  649.     
  650.     if (value.length > 0)
  651.     {
  652.       // Don't add extra spaces
  653.       var nonspace = searchInString(value, "[^ ]");
  654.       if (nonspace)
  655.       {
  656.         returnValue += " " + 
  657.           value.substring(nonspace.value, value.length);
  658.       }
  659.     }
  660.     return returnValue;
  661.   }
  662.   return null;
  663. }
  664.  
  665. // Use this function to add a command line option 
  666. // when preparing to use the editProperties dialog
  667. function AddOption(optionsList, checkedList, 
  668.   option, optionValue, 
  669.   optionString,
  670.   actionList, action)
  671. {
  672.   if (typeof(optionString) == "string")
  673.   {
  674.     optionsList.addTail(newAssociation(option, optionValue));
  675.     var index1 = optionString.indexOf(optionValue + " ");
  676.     var index2 = optionString.indexOf(optionValue);
  677.     if (index1 != -1)
  678.     {
  679.       checkedList.addTail(true);
  680.       
  681.       // Remove this option from the list
  682.       optionString = replaceInString(optionString, index1, 
  683.         optionValue.length, "");
  684.     }
  685.     else if (index2 != -1 && index2 + optionValue.length == optionString.length)
  686.     {
  687.       checkedList.addTail(true);
  688.       
  689.       // Remove this option from the list
  690.       optionString = replaceInString(optionString, index2, 
  691.         optionValue.length, "");
  692.     }
  693.     else
  694.     {
  695.       checkedList.addTail(false);
  696.     }
  697.   }
  698.   
  699.   if (actionList)
  700.   {
  701.     actionList.addTail(action);
  702.   }
  703.   
  704.   return optionString;
  705. }
  706.  
  707. // Use this function to add a special command line option 
  708. // when preparing to use the editProperties dialog
  709. function AddSpecialOption(optionsList, checkedList, 
  710.   option, optionValue, 
  711.   checkOn,
  712.   actionList, action)
  713. {
  714.   optionsList.addTail(newAssociation(option, optionValue));
  715.   checkedList.addTail(checkOn);
  716.   
  717.   if (actionList)
  718.   {
  719.     actionList.addTail(action);
  720.   }
  721. }
  722.  
  723. function UpdateOptions()
  724. {
  725.   var buildmode = gOptions.lookup("msj-buildmode", "release");
  726.  
  727.   if (buildmode == "release")
  728.   {
  729.     // Change tool options
  730.     var compileOptions = gOptions.lookup("msj-jvc_release", "");
  731.     gOptions.setValue("msj-jvc",compileOptions);
  732.   }
  733.       
  734.   if (buildmode == "debug")
  735.   {
  736.     // Change tool options
  737.     var compileOptions = gOptions.lookup("msj-jvc_debug", "/g");
  738.     gOptions.setValue("msj-jvc",compileOptions);
  739.   }
  740. }
  741.  
  742.  
  743. !!/Script
  744.