home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 March / maximum-cd-1999-03.iso / Feature / Lotus / ORGANIZE / COMPNENT / LTOUIN21.ZIP / sun / activator / panel / AdvancedPanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-12  |  5.9 KB  |  225 lines

  1. package sun.activator.panel;
  2.  
  3. import com.sun.java.swing.BorderFactory;
  4. import com.sun.java.swing.Box;
  5. import com.sun.java.swing.BoxLayout;
  6. import com.sun.java.swing.ImageIcon;
  7. import com.sun.java.swing.JCheckBox;
  8. import com.sun.java.swing.JComboBox;
  9. import com.sun.java.swing.JComponent;
  10. import com.sun.java.swing.JLabel;
  11. import com.sun.java.swing.JPanel;
  12. import com.sun.java.swing.JTextField;
  13. import java.awt.Container;
  14. import java.awt.Dimension;
  15. import java.awt.event.ActionEvent;
  16. import java.awt.event.ActionListener;
  17. import java.awt.event.KeyEvent;
  18. import java.awt.event.KeyListener;
  19. import java.util.EventObject;
  20.  
  21. public class AdvancedPanel extends ActivatorSubPanel implements ActionListener, KeyListener {
  22.    private static boolean hideJITBox;
  23.    private static boolean hideDebugBox;
  24.    private JCheckBox debugButton;
  25.    private JCheckBox jitButton;
  26.    private JTextField debugPort;
  27.    private JLabel debugPortLabel;
  28.    private JLabel jitPathLabel;
  29.    private JTextField jdkPath;
  30.    private JTextField jitPath;
  31.    private JComboBox jdkInstalled;
  32.    private final String otherJDK = "Other... ";
  33.    private JLabel pathLabel;
  34.  
  35.    AdvancedPanel(ResourceLoader var1, ConfigurationInfo var2) {
  36.       super(var1, var2);
  37.       ImageIcon var3 = var1.loadImageIcon("images/WebSpice/bulb1.gif", "dim light bulb");
  38.       ImageIcon var4 = var1.loadImageIcon("images/WebSpice/bulb2.gif", "lit light bulb");
  39.       ImageIcon var5 = var1.loadImageIcon("images/WebSpice/bulb3.gif", "greyed out light bulb");
  40.       JPanel var6 = new JPanel();
  41.       ((JComponent)var6).setBorder(BorderFactory.createTitledBorder("Java Run Time Environment"));
  42.       JPanel var7 = new JPanel();
  43.       ((Container)var7).setLayout(new BoxLayout(var7, 0));
  44.       ((Container)var7).add(Box.createRigidArea(new Dimension(10, 1)));
  45.       ((Container)var6).setLayout(new BoxLayout(var6, 0));
  46.       ((Container)var6).add(var7);
  47.       ((Container)var6).add(Box.createRigidArea(new Dimension(10, 1)));
  48.       this.jdkInstalled = new JComboBox();
  49.       if (this.setInstalledJavaList()) {
  50.          this.jdkInstalled.addActionListener(this);
  51.          ((Container)var6).add(Box.createRigidArea(new Dimension(1, 5)));
  52.          ((Container)var6).add(this.jdkInstalled);
  53.       }
  54.  
  55.       ((Container)var6).add(Box.createRigidArea(new Dimension(1, 5)));
  56.       ((Container)this).setLayout(new BoxLayout(this, 1));
  57.       ((Container)this).add(Box.createRigidArea(new Dimension(1, 5)));
  58.       ((Container)this).add(var6);
  59.       ((Container)this).add(Box.createRigidArea(new Dimension(1, 5)));
  60.       JPanel var8 = new JPanel();
  61.       ((Container)var8).setLayout(new BoxLayout(var8, 0));
  62.       this.pathLabel = new JLabel("Path : ");
  63.       ((Container)var8).add(this.pathLabel);
  64.       this.jdkPath = new JTextField();
  65.       this.jdkPath.addKeyListener(this);
  66.       ((Container)var8).add(this.jdkPath);
  67.       ((Container)var6).setLayout(new BoxLayout(var6, 1));
  68.       ((Container)var6).add(var8);
  69.       JPanel var9 = new JPanel();
  70.       this.jitButton = new JCheckBox("Enable Just In Time Compiler");
  71.       this.jitButton.addActionListener(this);
  72.       ((Container)var9).add(this.jitButton);
  73.       ((Container)var9).add(Box.createRigidArea(new Dimension(5, 1)));
  74.       this.jitPathLabel = new JLabel("JIT path");
  75.       ((Container)var9).add(this.jitPathLabel);
  76.       this.jitPath = new JTextField(var2.getJITPath(), 8);
  77.       this.jitPath.setAlignmentX(0.0F);
  78.       this.jitPath.setMaximumSize(this.jitPath.getPreferredSize());
  79.       this.jitPath.addKeyListener(this);
  80.       ((Container)var9).add(this.jitPath);
  81.       if (!hideJITBox) {
  82.          ((Container)var6).add(Box.createRigidArea(new Dimension(1, 5)));
  83.          ((Container)var6).add(var9);
  84.       }
  85.  
  86.       this.debugButton = new JCheckBox("Enable Debug", var3);
  87.       this.debugButton.setSelectedIcon(var4);
  88.       this.debugButton.setDisabledIcon(var5);
  89.       this.debugButton.addActionListener(this);
  90.       JPanel var10 = new JPanel();
  91.       ((JComponent)var10).setBorder(BorderFactory.createTitledBorder("Debug Settings"));
  92.       ((Container)var10).add(this.debugButton);
  93.       this.debugPortLabel = new JLabel("Debug Port :");
  94.       ((Container)var10).add(this.debugPortLabel);
  95.       ((Container)var10).add(Box.createRigidArea(new Dimension(5, 1)));
  96.       this.debugPort = new JTextField("2502", 6);
  97.       this.debugPort.setAlignmentX(0.0F);
  98.       this.debugPort.setMaximumSize(this.debugPort.getPreferredSize());
  99.       this.debugPort.addKeyListener(this);
  100.       ((Container)var10).add(this.debugPort);
  101.       if (!hideDebugBox) {
  102.          ((Container)this).add(Box.createRigidArea(new Dimension(1, 5)));
  103.          ((Container)this).add(var10);
  104.       }
  105.  
  106.       this.reset();
  107.    }
  108.  
  109.    public void actionPerformed(ActionEvent var1) {
  110.       if (((EventObject)var1).getSource() == this.debugButton) {
  111.          this.debugPort.setEnabled(this.debugButton.isSelected());
  112.          this.debugPortLabel.setEnabled(this.debugButton.isSelected());
  113.          this.debugPort.repaint();
  114.          this.debugPortLabel.repaint();
  115.          super.model.setDebugEnabled(this.debugButton.isSelected());
  116.       }
  117.  
  118.       if (((EventObject)var1).getSource() == this.jdkInstalled) {
  119.          String var2 = (String)this.jdkInstalled.getSelectedItem();
  120.          if (var2 == null) {
  121.             return;
  122.          }
  123.  
  124.          if (var2.equals("Other... ")) {
  125.             var2 = this.jdkPath.getText();
  126.          }
  127.  
  128.          if (!var2.equals(super.model.getJDK())) {
  129.             super.model.setJDK(var2);
  130.             this.reset();
  131.          }
  132.       }
  133.  
  134.       if (((EventObject)var1).getSource() == this.jitButton) {
  135.          boolean var3 = this.jitButton.isSelected();
  136.          this.jitPathLabel.setEnabled(var3);
  137.          this.jitPath.setEnabled(var3);
  138.          this.jitPath.repaint();
  139.          this.jitPathLabel.repaint();
  140.          super.model.setJITEnabled(var3);
  141.       }
  142.  
  143.    }
  144.  
  145.    public void keyPressed(KeyEvent var1) {
  146.    }
  147.  
  148.    public void keyReleased(KeyEvent var1) {
  149.       this.keyTyped(var1);
  150.    }
  151.  
  152.    public void keyTyped(KeyEvent var1) {
  153.       if (((EventObject)var1).getSource() == this.debugPort) {
  154.          super.model.setDebugPort(this.debugPort.getText());
  155.       } else if (((EventObject)var1).getSource() == this.jdkPath) {
  156.          super.model.setJDK(this.jdkPath.getText());
  157.       } else if (((EventObject)var1).getSource() == this.jitPath) {
  158.          if (this.jitPath.getText().length() != 0) {
  159.             super.model.setJITPath(this.jitPath.getText());
  160.          } else {
  161.             super.model.setJITPath((String)null);
  162.          }
  163.       }
  164.  
  165.    }
  166.  
  167.    public void reset() {
  168.       boolean var1 = super.model.isJITEnabled();
  169.       this.jitButton.setSelected(var1);
  170.       this.jitPath.setText(super.model.getJITPath());
  171.       this.jitPathLabel.setEnabled(var1);
  172.       this.jitPath.setEnabled(var1);
  173.       boolean var2 = super.model.isDebugEnabled();
  174.       this.debugButton.setSelected(var2);
  175.       this.debugPort.setText(super.model.getDebugPort());
  176.       this.debugPort.setEnabled(var2);
  177.       this.debugPortLabel.setEnabled(var2);
  178.       boolean var3 = true;
  179.       String var4 = super.model.getJDK();
  180.       String[] var5 = super.model.getInstalledJavaList();
  181.  
  182.       for(int var6 = 0; var6 < var5.length; ++var6) {
  183.          if (var4 == null || var5[var6].equals(var4)) {
  184.             this.jdkInstalled.setSelectedItem(var5[var6]);
  185.             this.jdkPath.setEnabled(false);
  186.             this.pathLabel.setEnabled(false);
  187.             var3 = false;
  188.             break;
  189.          }
  190.       }
  191.  
  192.       if (var3) {
  193.          this.jdkInstalled.setSelectedItem("Other... ");
  194.          this.jdkPath.setText(var4);
  195.          this.jdkPath.setEnabled(true);
  196.          this.pathLabel.setEnabled(true);
  197.       }
  198.  
  199.    }
  200.  
  201.    public static void setHideDebugBox(boolean var0) {
  202.       hideDebugBox = var0;
  203.    }
  204.  
  205.    public static void setHideJITBox(boolean var0) {
  206.       hideJITBox = var0;
  207.    }
  208.  
  209.    private boolean setInstalledJavaList() {
  210.       String[] var1 = super.model.getInstalledJavaList();
  211.       if (var1 != null && var1.length != 0) {
  212.          this.jdkInstalled.removeAllItems();
  213.  
  214.          for(int var2 = 0; var2 < var1.length; ++var2) {
  215.             this.jdkInstalled.addItem(var1[var2]);
  216.          }
  217.  
  218.          this.jdkInstalled.addItem("Other... ");
  219.          return true;
  220.       } else {
  221.          return false;
  222.       }
  223.    }
  224. }
  225.