home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.awt.BorderLayout; import java.awt.Button; import java.awt.Checkbox; import java.awt.CheckboxGroup; import java.awt.Color; import java.awt.Container; import java.awt.Event; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Frame; import java.awt.GridBagLayout; import java.awt.Label; import java.awt.Panel; import java.awt.TextArea; import java.awt.TextField; import java.awt.Window; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; class jadiOptions extends Frame { private Label titleLabel; private Panel outputAreaPanel; private Panel projectOptionsPanel; private Panel HTMLSetupPanel; private TextField appletHeight; private TextField appletWidth; private Button buttonCreate; private CheckboxGroup checkbox_group; private Checkbox[] checkboxes; private TextField theArgs; private TextField theFile; private String ArgsOld; private String FileOld; private Button buttonApply; private Button buttonCancel; private Label Label1; private Label Label2; private TextField commandLineDisplay; private TextArea outputWindow; private GridBagLayout gridBag; private JADI MainWindow; jadiOptions(JADI var1) { super(new String("JADI: Program Options")); this.MainWindow = var1; this.gridBag = new GridBagLayout(); ((Container)this).setLayout(this.gridBag); this.titleLabel = new Label("JADI: Program Options"); this.titleLabel.setFont(new Font("TimesRoman", 1, 24)); this.titleLabel.setAlignment(1); JADI.constrain(this, this.titleLabel, 0, 0, 1, 1, 2, 10, (double)1.0F, (double)1.0F, 0, 0, 0, 0); this.outputAreaPanel = new Panel(); this.outputAreaPanel.setLayout(new BorderLayout()); this.commandLineDisplay = new TextField(40); this.commandLineDisplay.setEditable(false); this.commandLineDisplay.setFont(new Font("Helvetica", 0, 12)); this.outputWindow = new TextArea(7, 40); this.outputWindow.setEditable(false); this.outputWindow.setFont(new Font("Helvetica", 0, 10)); this.outputAreaPanel.add("North", this.commandLineDisplay); this.outputAreaPanel.add("Center", this.outputWindow); JADI.constrain(this, this.outputAreaPanel, 0, 1, 1, 1, 2, 10, (double)1.0F, (double)1.0F, 0, 0, 0, 0); this.projectOptionsPanel = new Panel(); this.projectOptionsPanel.setLayout(new BorderLayout()); Panel var2 = new Panel(); this.checkbox_group = new CheckboxGroup(); this.checkboxes = new Checkbox[2]; this.checkboxes[0] = new Checkbox("Applet", this.checkbox_group, true); this.checkboxes[1] = new Checkbox("Application", this.checkbox_group, false); ((Container)var2).setLayout(new FlowLayout(1, 25, 10)); ((Container)var2).add(this.checkboxes[0]); ((Container)var2).add(this.checkboxes[1]); Panel var3 = new Panel(); this.theArgs = new TextField(20); this.theFile = new TextField(20); this.theArgs.disable(); ((Container)var3).setLayout(new GridBagLayout()); Label var5 = this.Label1 = new Label("Command Line Args:"); JADI.constrain(var3, var5, 0, 0, 1, 1, 0, 18, (double)0.0F, (double)0.0F, 0, 0, 0, 0); TextField var6 = this.theArgs; JADI.constrain(var3, var6, 1, 0, 1, 1, 0, 18, (double)0.0F, (double)0.0F, 0, 0, 0, 0); Label var7 = this.Label2 = new Label("HTML File:"); JADI.constrain(var3, var7, 0, 1, 1, 1, 0, 18, (double)0.0F, (double)0.0F, 0, 0, 0, 0); TextField var8 = this.theFile; JADI.constrain(var3, var8, 1, 1, 1, 1, 0, 18, (double)0.0F, (double)0.0F, 0, 0, 0, 0); Panel var4 = new Panel(); ((Container)var4).setLayout(new FlowLayout(1, 20, 10)); this.buttonApply = new Button("Commit"); this.buttonCancel = new Button("Revert"); ((Container)var4).add(this.buttonApply); ((Container)var4).add(this.buttonCancel); this.projectOptionsPanel.add("North", var2); this.projectOptionsPanel.add("Center", var3); this.projectOptionsPanel.add("South", var4); JADI.constrain(this, this.projectOptionsPanel, 0, 2, 1, 1, 2, 10, (double)1.0F, (double)1.0F, 0, 0, 0, 0); this.HTMLSetupPanel = new Panel(); this.buttonCreate = new Button("Create HTML File"); this.HTMLSetupPanel.setLayout(new GridBagLayout()); this.appletHeight = new TextField(5); this.appletWidth = new TextField(5); JADI.constrain(this.HTMLSetupPanel, this.Label1 = new Label("Height:", 2), 0, 0, 1, 1, 0, 13, (double)1.0F, (double)1.0F, 0, 0, 0, 0); JADI.constrain(this.HTMLSetupPanel, this.appletHeight, 1, 0, 1, 1, 0, 17, (double)1.0F, (double)1.0F, 0, 0, 0, 0); JADI.constrain(this.HTMLSetupPanel, this.Label2 = new Label("Width:", 2), 0, 1, 1, 1, 0, 13, (double)1.0F, (double)1.0F, 0, 0, 0, 0); JADI.constrain(this.HTMLSetupPanel, this.appletWidth, 1, 1, 1, 1, 0, 17, (double)1.0F, (double)1.0F, 0, 0, 0, 0); JADI.constrain(this.HTMLSetupPanel, this.buttonCreate, 2, 0, 1, 2, 0, 10, (double)1.0F, (double)1.0F, 0, 0, 0, 0); JADI.constrain(this, this.HTMLSetupPanel, 0, 3, 1, 1, 2, 10, (double)1.0F, (double)1.0F, 0, 0, 0, 0); ((Window)this).pack(); } void setOutput(String var1, Color var2) { this.outputWindow.setForeground(var2); this.outputWindow.setText(var1); } void setCommandLine(String var1, Color var2) { this.commandLineDisplay.setForeground(var2); this.commandLineDisplay.setText(var1); } void clearOutputArea() { this.outputWindow.setText(""); this.commandLineDisplay.setText(""); } public boolean handleEvent(Event var1) { if (var1.target instanceof Button) { if (var1.target == this.buttonApply) { this.clickApply(); } else if (var1.target == this.buttonCancel) { this.theArgs.setText(this.ArgsOld); this.theFile.setText(this.FileOld); } else if (var1.target == this.buttonCreate) { this.createHTMLFile(); } } else if (var1.target instanceof Checkbox) { this.updateWindowOptions(var1.target); } return super.handleEvent(var1); } private void clickApply() { this.ArgsOld = new String(this.theArgs.getText()); this.FileOld = new String(this.theFile.getText()); } private void revert() { this.theArgs.setText(this.ArgsOld); this.theFile.setText(this.FileOld); } private void updateWindowOptions(Object var1) { if (var1 == this.checkboxes[0]) { this.theFile.enable(); this.theArgs.disable(); this.HTMLSetupPanel.show(); } else { this.theFile.disable(); this.theArgs.enable(); this.HTMLSetupPanel.hide(); } } private void createHTMLFile() { if (this.MainWindow.CurrentDirectory == null) { this.setCommandLine("Error: No File Open", Color.red); this.setOutput("Please open a file first.", Color.red); } else { String var1 = new String(this.theFile.getText().trim()); String var2 = new String(this.appletHeight.getText().trim()); String var3 = new String(this.appletWidth.getText().trim()); this.clearOutputArea(); if (var1.equalsIgnoreCase(new String(""))) { this.setCommandLine("Error: Need HTML File Name", Color.red); this.setOutput("You have not chosen a file name for your HTML File. \n Please fill in the HTML File Field, and try again.", Color.red); } else { if (var1.indexOf(System.getProperty("file.separator")) != -1) { var1 = var1.substring(var1.lastIndexOf(System.getProperty("file.separator")) + 1); } var1 = this.MainWindow.CurrentDirectory + var1.trim(); try { int var4 = Integer.parseInt(var2); var4 = Integer.parseInt(var3); } catch (NumberFormatException var9) { this.setCommandLine("Error: Height and Width must be integer values", Color.red); this.setOutput("The following error occured during the HTML Create\nProcess:\n\n" + ((Throwable)var9).toString() + "\n", Color.red); System.out.println("Height and Width must be integer values"); return; } String var5 = new String(this.MainWindow.CurrentFileName.substring(0, this.MainWindow.CurrentFileName.lastIndexOf("."))); String var6 = new String(System.getProperty("line.separator")); try { PrintStream var7 = new PrintStream(new FileOutputStream(var1)); var7.print("<HTML>" + var6 + "<HEAD>" + var6 + "<TITLE>JADI Generated HTML</TITLE>" + var6 + "</HEAD>" + var6 + "<BODY>" + var6 + "<APPLET CODE=\"" + var5 + ".class\" WIDTH=" + var3 + " HEIGHT=" + var2 + ">Your Browser Does Not Support Java</APPLET>" + var6 + "</BODY>" + var6 + "</HTML>"); var7.close(); } catch (IOException var8) { this.setCommandLine("Error: Error occurred during HTML Create Process", Color.red); this.setOutput("The following error occured during the HTML Create\nProcess:\n\n" + ((Throwable)var8).toString() + "\n" + ((Throwable)var8).getMessage(), Color.red); System.out.println(var8); return; } this.setCommandLine("HTML File Created", Color.blue); this.setOutput("HTML File has been created for your applet", Color.blue); } } } public String getCmdLineArgs() { return this.theArgs.getText().trim(); } public String getHTMLFileName() { String var1 = new String(this.theFile.getText().trim()); if (var1.indexOf(System.getProperty("file.separator")) != -1) { var1 = var1.substring(var1.lastIndexOf(System.getProperty("file.separator")) + 1); } var1 = this.MainWindow.CurrentDirectory + var1.trim(); var1 = var1.replace(':', '|'); var1 = var1.replace('\\', '/'); return var1; } public String getProjectType() { return this.checkboxes[0].getState() ? "Applet" : "Application"; } }