home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / main.bin / MainFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-08-05  |  9.0 KB  |  375 lines

  1. package symantec.descfileconverter;
  2.  
  3. import java.awt.Button;
  4. import java.awt.Checkbox;
  5. import java.awt.CheckboxGroup;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Event;
  10. import java.awt.Font;
  11. import java.awt.Frame;
  12. import java.awt.Label;
  13. import java.awt.LayoutManager;
  14. import java.awt.List;
  15. import java.awt.Menu;
  16. import java.awt.MenuBar;
  17. import java.awt.MenuItem;
  18. import java.awt.Panel;
  19. import java.awt.TextField;
  20. import java.io.File;
  21. import java.io.FilenameFilter;
  22. import symantec.itools.awt.BorderPanel;
  23. import symantec.itools.awt.RadioButtonGroupPanel;
  24. import symantec.itools.awt.TabPanel;
  25. import symantec.itools.awt.WrappingLabel;
  26.  
  27. public class MainFrame extends Frame {
  28.    private File selectedDir;
  29.    private FilenameFilter filter;
  30.    private String[] files;
  31.    private BrowseDialog browseDlg;
  32.    private DescToBeanInfo engine;
  33.    TabPanel tabPanel1;
  34.    Panel panel1;
  35.    BorderPanel borderPanel2;
  36.    Checkbox icoFilesWithDescFiles;
  37.    Label iconDirLabel;
  38.    TextField iconDir;
  39.    Button iconDirButton;
  40.    Button descDirButton;
  41.    Label descDirLabel;
  42.    TextField descDir;
  43.    BorderPanel borderPanel1;
  44.    Button beaninfoDirButton;
  45.    Label beaninfoDirLabel;
  46.    TextField beaninfoDir;
  47.    RadioButtonGroupPanel radioButtonGroupPanel1;
  48.    Checkbox absolute;
  49.    CheckboxGroup Group1;
  50.    Checkbox relative;
  51.    WrappingLabel wrappingLabel1;
  52.    BorderPanel borderPanel3;
  53.    Checkbox selectAll;
  54.    Label selectLabel;
  55.    List selectList;
  56.    MenuBar mainMenuBar;
  57.    Menu menu1;
  58.    Menu menu3;
  59.  
  60.    void Convert_Action(Event var1) {
  61.       String var2 = this.descDir.getText();
  62.       String[] var4 = this.selectList.getSelectedItems();
  63.       if (var4.length > 0) {
  64.          String var3;
  65.          if (this.icoFilesWithDescFiles.getState()) {
  66.             var3 = this.descDir.getText();
  67.          } else {
  68.             var3 = this.iconDir.getText();
  69.          }
  70.  
  71.          String var5 = this.beaninfoDir.getText();
  72.          DescToBeanInfo.convert(var2, var3, var5, this.relative.getState(), var4);
  73.          (new AlertDialog(this, "Conversion completed", true)).show();
  74.       } else {
  75.          (new AlertDialog(this, "No files selected", true)).show();
  76.       }
  77.    }
  78.  
  79.    void icoFilesWithDescFiles_Action(Event var1) {
  80.       this.iconDirButton.enable(!this.icoFilesWithDescFiles.getState());
  81.       this.iconDir.enable(!this.icoFilesWithDescFiles.getState());
  82.       this.iconDirLabel.enable(!this.icoFilesWithDescFiles.getState());
  83.       ((Component)this).repaint();
  84.    }
  85.  
  86.    void descDir_LostFocus(Event var1) {
  87.       this.selectList.removeAll();
  88.  
  89.       try {
  90.          this.listSelectedDir(this.descDir.getText());
  91.       } catch (IllegalArgumentException var3) {
  92.          (new AlertDialog(this, ((Throwable)var3).getMessage(), true)).show();
  93.          this.descDir.requestFocus();
  94.       }
  95.    }
  96.  
  97.    void iconDir_LostFocus(Event var1) {
  98.       if (!(new File(this.iconDir.getText())).isDirectory() && (!System.getProperty("os.name").startsWith("Windows") || this.iconDir.getText().length() != 2 || !(new File(this.iconDir.getText())).exists())) {
  99.          (new AlertDialog(this, "No such directory", true)).show();
  100.          this.iconDir.requestFocus();
  101.       }
  102.  
  103.    }
  104.  
  105.    void beaninfoDir_LostFocus(Event var1) {
  106.       if (!(new File(this.beaninfoDir.getText())).isDirectory() && (!System.getProperty("os.name").startsWith("Windows") || this.beaninfoDir.getText().length() != 2 || !(new File(this.beaninfoDir.getText())).exists())) {
  107.          (new AlertDialog(this, "No such directory", true)).show();
  108.          this.beaninfoDir.requestFocus();
  109.       }
  110.  
  111.    }
  112.  
  113.    void selectAll_Checked(Event var1) {
  114.       if (this.selectAll.getState()) {
  115.          for(int var3 = 0; var3 < this.selectList.getItemCount(); ++var3) {
  116.             this.selectList.select(var3);
  117.          }
  118.  
  119.       } else {
  120.          for(int var2 = 0; var2 < this.selectList.getItemCount(); ++var2) {
  121.             this.selectList.deselect(var2);
  122.          }
  123.  
  124.       }
  125.    }
  126.  
  127.    void beaninfoDirButton_Clicked(Event var1) {
  128.       this.browseDlg.whoIsShowingMe(var1.target);
  129.       this.browseDlg.show();
  130.    }
  131.  
  132.    void iconDirButton_Clicked(Event var1) {
  133.       this.browseDlg.whoIsShowingMe(var1.target);
  134.       this.browseDlg.show();
  135.    }
  136.  
  137.    void descDirButton_Clicked(Event var1) {
  138.       this.browseDlg.whoIsShowingMe(var1.target);
  139.       this.browseDlg.show();
  140.    }
  141.  
  142.    void About_Action(Event var1) {
  143.       (new AboutDialog(this, true)).show();
  144.    }
  145.  
  146.    void Environment_Action(Event var1) {
  147.       (new EnvironmentDialog(this, true)).show();
  148.    }
  149.  
  150.    void Exit_Action(Event var1) {
  151.       (new QuitDialog(this, true)).show();
  152.    }
  153.  
  154.    public MainFrame() {
  155.       this.filter = new DescFilter();
  156.       this.engine = new DescToBeanInfo();
  157.       ((Container)this).setLayout((LayoutManager)null);
  158.       ((Frame)this).addNotify();
  159.       ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 400, ((Container)this).insets().top + ((Container)this).insets().bottom + 430);
  160.       ((Component)this).setBackground(new Color(12632256));
  161.       this.tabPanel1 = new TabPanel();
  162.       this.tabPanel1.setLayout((LayoutManager)null);
  163.       this.tabPanel1.reshape(((Container)this).insets().left, ((Container)this).insets().top, 401, 394);
  164.       ((Container)this).add(this.tabPanel1);
  165.       String[] var1 = new String[]{new String("Location"), new String("Selection")};
  166.       this.tabPanel1.setPanelLabels(var1);
  167.       this.panel1 = new Panel();
  168.       this.panel1.setLayout((LayoutManager)null);
  169.       this.panel1.reshape(12, 33, 373, 350);
  170.       this.tabPanel1.add(this.panel1);
  171.       this.borderPanel2 = new BorderPanel();
  172.       this.borderPanel2.setLayout((LayoutManager)null);
  173.       this.borderPanel2.reshape(0, 3, 374, 170);
  174.       this.panel1.add(this.borderPanel2);
  175.       this.borderPanel2.setBevelStyle(0);
  176.       this.icoFilesWithDescFiles = new Checkbox(".ico files are with .desc files");
  177.       this.icoFilesWithDescFiles.reshape(12, 48, 192, 27);
  178.       this.icoFilesWithDescFiles.setFont(new Font("Dialog", 1, 12));
  179.       this.borderPanel2.add(this.icoFilesWithDescFiles);
  180.       this.iconDirLabel = new Label("Icon File Directory :");
  181.       this.iconDirLabel.reshape(0, 72, 253, 24);
  182.       this.iconDirLabel.setFont(new Font("Dialog", 1, 12));
  183.       this.borderPanel2.add(this.iconDirLabel);
  184.       this.iconDir = new TextField();
  185.       this.iconDir.reshape(0, 96, 253, 24);
  186.       this.borderPanel2.add(this.iconDir);
  187.       this.iconDirButton = new Button("Browse...");
  188.       this.iconDirButton.reshape(276, 96, 71, 26);
  189.       this.iconDirButton.setFont(new Font("Dialog", 0, 12));
  190.       this.borderPanel2.add(this.iconDirButton);
  191.       this.descDirButton = new Button("Browse...");
  192.       this.descDirButton.reshape(276, 24, 71, 26);
  193.       this.descDirButton.setFont(new Font("Dialog", 0, 12));
  194.       this.borderPanel2.add(this.descDirButton);
  195.       this.descDirLabel = new Label("Description File Directory :");
  196.       this.descDirLabel.reshape(0, 0, 253, 24);
  197.       this.descDirLabel.setFont(new Font("Dialog", 1, 12));
  198.       this.borderPanel2.add(this.descDirLabel);
  199.       this.descDir = new TextField();
  200.       this.descDir.reshape(0, 24, 253, 24);
  201.       this.borderPanel2.add(this.descDir);
  202.       this.borderPanel1 = new BorderPanel();
  203.       this.borderPanel1.setLayout((LayoutManager)null);
  204.       this.borderPanel1.reshape(0, 171, 374, 170);
  205.       this.panel1.add(this.borderPanel1);
  206.       this.borderPanel1.setBevelStyle(0);
  207.       this.beaninfoDirButton = new Button("Browse...");
  208.       this.beaninfoDirButton.reshape(276, 24, 71, 26);
  209.       this.beaninfoDirButton.setFont(new Font("Dialog", 0, 12));
  210.       this.borderPanel1.add(this.beaninfoDirButton);
  211.       this.beaninfoDirLabel = new Label("Output Directory :");
  212.       this.beaninfoDirLabel.reshape(0, 0, 253, 24);
  213.       this.beaninfoDirLabel.setFont(new Font("Dialog", 1, 12));
  214.       this.borderPanel1.add(this.beaninfoDirLabel);
  215.       this.beaninfoDir = new TextField();
  216.       this.beaninfoDir.reshape(0, 24, 253, 24);
  217.       this.borderPanel1.add(this.beaninfoDir);
  218.       this.radioButtonGroupPanel1 = new RadioButtonGroupPanel();
  219.       this.radioButtonGroupPanel1.setLayout((LayoutManager)null);
  220.       this.radioButtonGroupPanel1.reshape(0, 60, 90, 60);
  221.       this.borderPanel1.add(this.radioButtonGroupPanel1);
  222.       this.Group1 = new CheckboxGroup();
  223.       this.absolute = new Checkbox("absolute", this.Group1, false);
  224.       this.absolute.reshape(0, 24, 80, 20);
  225.       this.absolute.setFont(new Font("Dialog", 1, 12));
  226.       this.radioButtonGroupPanel1.add(this.absolute);
  227.       this.relative = new Checkbox("relative", this.Group1, true);
  228.       this.relative.reshape(0, 0, 80, 25);
  229.       this.relative.setFont(new Font("Dialog", 1, 12));
  230.       this.radioButtonGroupPanel1.add(this.relative);
  231.       this.wrappingLabel1 = new WrappingLabel();
  232.       this.wrappingLabel1.reshape(96, 60, 245, 75);
  233.       this.wrappingLabel1.setFont(new Font("TimesRoman", 0, 12));
  234.       this.borderPanel1.add(this.wrappingLabel1);
  235.       this.wrappingLabel1.setText("Selecting relative appends a component's package directory hierarchy to the output directory.  Selecting absolute does not and may lead to name conflicts.");
  236.       this.borderPanel3 = new BorderPanel();
  237.       this.borderPanel3.setLayout((LayoutManager)null);
  238.       this.borderPanel3.reshape(12, 33, 373, 350);
  239.       this.tabPanel1.add(this.borderPanel3);
  240.       this.borderPanel3.setBevelStyle(0);
  241.       this.selectAll = new Checkbox("select all listed files");
  242.       this.selectAll.reshape(24, 291, 144, 27);
  243.       this.selectAll.setFont(new Font("Dialog", 1, 12));
  244.       this.borderPanel3.add(this.selectAll);
  245.       this.selectLabel = new Label("Select files to convert!");
  246.       this.selectLabel.reshape(12, 15, 158, 24);
  247.       this.selectLabel.setFont(new Font("Dialog", 1, 12));
  248.       this.borderPanel3.add(this.selectLabel);
  249.       this.selectList = new List(0, true);
  250.       this.borderPanel3.add(this.selectList);
  251.       this.selectList.reshape(12, 39, 325, 250);
  252.       ((Frame)this).setTitle("Description File Converter");
  253.       ((Frame)this).setResizable(false);
  254.       this.descDir.setText(System.getProperty("user.dir"));
  255.       this.iconDir.setText(System.getProperty("user.dir"));
  256.       this.beaninfoDir.setText(System.getProperty("user.dir"));
  257.       this.listSelectedDir(this.descDir.getText());
  258.       this.browseDlg = new BrowseDialog(this, false);
  259.       this.mainMenuBar = new MenuBar();
  260.       this.menu1 = new Menu("File");
  261.       this.menu1.add("Convert");
  262.       this.menu1.add("Exit");
  263.       this.mainMenuBar.add(this.menu1);
  264.       this.menu3 = new Menu("Help");
  265.       this.mainMenuBar.setHelpMenu(this.menu3);
  266.       this.menu3.add("About...");
  267.       this.menu3.add("Environment...");
  268.       this.mainMenuBar.add(this.menu3);
  269.       ((Frame)this).setMenuBar(this.mainMenuBar);
  270.    }
  271.  
  272.    public MainFrame(String var1) {
  273.       this();
  274.       ((Frame)this).setTitle(var1);
  275.    }
  276.  
  277.    public synchronized void show() {
  278.       ((Component)this).move(50, 50);
  279.       super.show();
  280.    }
  281.  
  282.    public boolean handleEvent(Event var1) {
  283.       if (var1.id == 201) {
  284.          ((Component)this).hide();
  285.          ((Frame)this).dispose();
  286.          System.exit(0);
  287.          return true;
  288.       } else if (var1.target == this.descDirButton && var1.id == 1001) {
  289.          this.descDirButton_Clicked(var1);
  290.          return true;
  291.       } else if (var1.target == this.iconDirButton && var1.id == 1001) {
  292.          this.iconDirButton_Clicked(var1);
  293.          return true;
  294.       } else if (var1.target == this.beaninfoDirButton && var1.id == 1001) {
  295.          this.beaninfoDirButton_Clicked(var1);
  296.          return true;
  297.       } else if (var1.target == this.selectAll && var1.id == 1001) {
  298.          this.selectAll_Checked(var1);
  299.          return true;
  300.       } else if (var1.target == this.descDir && var1.id == 1005) {
  301.          this.descDir_LostFocus(var1);
  302.          return true;
  303.       } else if (var1.target == this.iconDir && var1.id == 1005) {
  304.          this.iconDir_LostFocus(var1);
  305.          return true;
  306.       } else if (var1.target == this.beaninfoDir && var1.id == 1005) {
  307.          this.beaninfoDir_LostFocus(var1);
  308.          return true;
  309.       } else if (var1.target == this.icoFilesWithDescFiles && var1.id == 1001) {
  310.          this.icoFilesWithDescFiles_Action(var1);
  311.          return true;
  312.       } else {
  313.          return super.handleEvent(var1);
  314.       }
  315.    }
  316.  
  317.    public boolean action(Event var1, Object var2) {
  318.       if (var1.target instanceof MenuItem) {
  319.          String var3 = (String)var2;
  320.          if (var3.equalsIgnoreCase("Convert")) {
  321.             this.Convert_Action(var1);
  322.             return true;
  323.          }
  324.  
  325.          if (var3.equalsIgnoreCase("About...")) {
  326.             this.About_Action(var1);
  327.             return true;
  328.          }
  329.  
  330.          if (var3.equalsIgnoreCase("Environment...")) {
  331.             this.Environment_Action(var1);
  332.             return true;
  333.          }
  334.  
  335.          if (var3.equalsIgnoreCase("Exit")) {
  336.             this.Exit_Action(var1);
  337.             return true;
  338.          }
  339.       }
  340.  
  341.       return super.action(var1, var2);
  342.    }
  343.  
  344.    public static void main(String[] var0) {
  345.       (new MainFrame()).show();
  346.    }
  347.  
  348.    void listSelectedDir(String var1) {
  349.       this.selectedDir = new File(var1);
  350.       if (this.selectedDir.isDirectory()) {
  351.          if (System.getProperty("os.name").startsWith("Windows") && var1.length() == 3) {
  352.             this.selectedDir = new File(var1.substring(0, 3));
  353.          }
  354.  
  355.          this.selectList.removeAll();
  356.          this.files = this.selectedDir.list(this.filter);
  357.  
  358.          for(int var3 = 0; var3 < this.files.length; ++var3) {
  359.             this.selectList.addItem(this.files[var3]);
  360.          }
  361.  
  362.       } else if (System.getProperty("os.name").startsWith("Windows") && var1.length() == 2 && this.selectedDir.exists()) {
  363.          this.selectList.removeAll();
  364.          this.files = this.selectedDir.list(this.filter);
  365.  
  366.          for(int var2 = 0; var2 < this.files.length; ++var2) {
  367.             this.selectList.addItem(this.files[var2]);
  368.          }
  369.  
  370.       } else {
  371.          throw new IllegalArgumentException("No such directory");
  372.       }
  373.    }
  374. }
  375.