home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / rmi / rmic / UI.class (.txt) < prev   
Encoding:
Java Class File  |  1997-07-08  |  6.3 KB  |  240 lines

  1. package sun.rmi.rmic;
  2.  
  3. import java.awt.Button;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.Frame;
  7. import java.awt.GridBagConstraints;
  8. import java.awt.GridBagLayout;
  9. import java.awt.Label;
  10. import java.awt.Menu;
  11. import java.awt.MenuBar;
  12. import java.awt.MenuItem;
  13. import java.awt.TextArea;
  14. import java.awt.TextField;
  15. import java.awt.Window;
  16. import java.io.BufferedInputStream;
  17. import java.io.FileInputStream;
  18. import java.io.IOException;
  19. import java.io.InputStream;
  20. import java.text.MessageFormat;
  21. import java.util.MissingResourceException;
  22. import java.util.Properties;
  23. import java.util.ResourceBundle;
  24.  
  25. // $FF: renamed from: sun.rmi.rmic.UI
  26. class class_0 extends Frame implements Runnable {
  27.    Main main;
  28.    Main subcompile;
  29.    // $FF: renamed from: gb java.awt.GridBagLayout
  30.    GridBagLayout field_0;
  31.    TextField classname_t;
  32.    Button compile_b;
  33.    Button stop_b;
  34.    TextArea errors_t;
  35.    Label footer_l;
  36.    MenuBar menu_mb;
  37.    Menu file_m;
  38.    MenuItem exit_i;
  39.    String[] args;
  40.    Thread thread;
  41.    private static ResourceBundle resources;
  42.  
  43.    public class_0(Main var1) {
  44.       this.main = var1;
  45.       String var2 = System.getProperty("java.home");
  46.       String var3 = System.getProperty("rmi.home");
  47.       if (var3 == null || var3.length() == 0) {
  48.          var3 = var2;
  49.       }
  50.  
  51.       try {
  52.          resources = ResourceBundle.getBundle("sun.tools.javac.resources.javac");
  53.       } catch (MissingResourceException var4) {
  54.          throw new Error("Fatal: Resource for javac is missing");
  55.       }
  56.  
  57.       pushPropFile(var3, "rmic.properties");
  58.       ((Frame)this).setTitle(I18N("rmi.stub.compiler"));
  59.    }
  60.  
  61.    public void init() {
  62.       this.file_m = new Menu(I18N("File"));
  63.       this.file_m.add(this.exit_i = new MenuItem(I18N("Exit")));
  64.       this.menu_mb = new MenuBar();
  65.       this.menu_mb.add(this.file_m);
  66.       this.field_0 = new GridBagLayout();
  67.       ((Container)this).setLayout(this.field_0);
  68.       GridBagConstraints var1 = new GridBagConstraints();
  69.       var1.fill = 1;
  70.       Label var2 = new Label(I18N("full.class.name"));
  71.       var2.setAlignment(0);
  72.       this.field_0.setConstraints(var2, var1);
  73.       ((Container)this).add(var2);
  74.       this.classname_t = new TextField(20);
  75.       var1.gridwidth = 1;
  76.       var1.weightx = (double)1.0F;
  77.       this.field_0.setConstraints(this.classname_t, var1);
  78.       ((Container)this).add(this.classname_t);
  79.       this.compile_b = new Button(I18N("compile"));
  80.       var1.gridwidth = 0;
  81.       var1.weightx = (double)0.0F;
  82.       this.field_0.setConstraints(this.compile_b, var1);
  83.       ((Container)this).add(this.compile_b);
  84.       this.stop_b = new Button(I18N("stop"));
  85.       Label var3 = new Label(I18N("errors"));
  86.       var3.setAlignment(0);
  87.       var1.gridwidth = 0;
  88.       this.field_0.setConstraints(var3, var1);
  89.       ((Container)this).add(var3);
  90.       this.errors_t = new TextArea("", 4, 60);
  91.       this.errors_t.setEditable(false);
  92.       this.errors_t.disable();
  93.       var1.gridx = 0;
  94.       var1.gridwidth = 0;
  95.       var1.weighty = (double)1.0F;
  96.       this.field_0.setConstraints(this.errors_t, var1);
  97.       ((Container)this).add(this.errors_t);
  98.       this.footer_l = new Label();
  99.       var1.gridwidth = 0;
  100.       var1.weighty = (double)0.0F;
  101.       this.field_0.setConstraints(this.footer_l, var1);
  102.       ((Container)this).add(this.footer_l);
  103.       ((Container)this).validate();
  104.       ((Window)this).pack();
  105.       ((Window)this).show();
  106.    }
  107.  
  108.    public void start() {
  109.    }
  110.  
  111.    public boolean action(Event var1, Object var2) {
  112.       if (var1.target == this.classname_t) {
  113.          this.compile((String)var1.arg);
  114.          return true;
  115.       } else if (var1.target == this.compile_b) {
  116.          this.compile(this.classname_t.getText());
  117.          return true;
  118.       } else if (var1.target == this.stop_b) {
  119.          this.stop();
  120.          return true;
  121.       } else {
  122.          if (var1.target == this.exit_i) {
  123.             this.exit(0);
  124.          }
  125.  
  126.          return false;
  127.       }
  128.    }
  129.  
  130.    public boolean handleEvent(Event var1) {
  131.       if (var1.id == 201) {
  132.          this.exit(0);
  133.       }
  134.  
  135.       return super.handleEvent(var1);
  136.    }
  137.  
  138.    void compile(String var1) {
  139.       this.footer_l.setText("");
  140.       this.errors_t.setText("");
  141.       if (!var1.equals("")) {
  142.          this.args = new String[1];
  143.          this.args[0] = var1.trim();
  144.          this.subcompile = new Main(new TextAreaOutput(this.errors_t), "rmic");
  145.          this.subcompile.status = false;
  146.          if (this.subcompile.parseArgs(this.args)) {
  147.             this.compile_b.disable();
  148.             this.stop_b.enable();
  149.             this.thread = new Thread(this.subcompile, "rmic");
  150.             this.thread.start();
  151.             (new Thread(this, "rmi-done?")).start();
  152.          }
  153.       }
  154.    }
  155.  
  156.    void stop() {
  157.       this.compile_b.enable();
  158.       this.stop_b.disable();
  159.       if (this.thread != null) {
  160.          this.thread.stop();
  161.          this.thread = null;
  162.       }
  163.  
  164.    }
  165.  
  166.    public void run() {
  167.       while(true) {
  168.          try {
  169.             this.thread.join();
  170.             this.compile_b.enable();
  171.             this.stop_b.disable();
  172.          } catch (InterruptedException var1) {
  173.             continue;
  174.          }
  175.  
  176.          this.footer_l.setText(I18N(this.subcompile.status ? "compile.done" : "compile.failed"));
  177.          return;
  178.       }
  179.    }
  180.  
  181.    private static String getProperty(String var0) {
  182.       String var1;
  183.       try {
  184.          var1 = resources.getString(var0);
  185.       } catch (MissingResourceException var2) {
  186.          var1 = System.getProperty(var0);
  187.       }
  188.  
  189.       return var1;
  190.    }
  191.  
  192.    public static String I18N(String var0) {
  193.       String var1 = getProperty(var0);
  194.       if (var1 == null) {
  195.          var1 = "No message text for " + var0;
  196.       }
  197.  
  198.       return var1;
  199.    }
  200.  
  201.    public static String I18N(String var0, String var1) {
  202.       return I18N(var0, var1, (String)null);
  203.    }
  204.  
  205.    public static String I18N(String var0, String var1, String var2) {
  206.       Object[] var3 = new Object[]{var1, var2};
  207.  
  208.       for(int var4 = 0; var4 < var3.length; ++var4) {
  209.          if (var3[var4] != null & !(var3[var4] instanceof String)) {
  210.             var3[var4] = var3[var4].toString();
  211.          }
  212.       }
  213.  
  214.       String var5 = getProperty(var0);
  215.       if (var5 == null) {
  216.          return "No message text for " + var0;
  217.       } else {
  218.          return MessageFormat.format(var5, var3);
  219.       }
  220.    }
  221.  
  222.    static void pushPropFile(String var0, String var1) {
  223.       String var2 = var0 + System.getProperty("file.separator") + "lib" + System.getProperty("file.separator") + var1;
  224.  
  225.       try {
  226.          Properties var3 = new Properties(System.getProperties());
  227.          BufferedInputStream var4 = new BufferedInputStream(new FileInputStream(var2));
  228.          var3.load(var4);
  229.          ((InputStream)var4).close();
  230.          System.setProperties(var3);
  231.       } catch (IOException var5) {
  232.          System.err.println("failed to read properties file: " + var2);
  233.       }
  234.    }
  235.  
  236.    void exit(int var1) {
  237.       System.exit(var1);
  238.    }
  239. }
  240.