package controlledparts; import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.Insets; import java.awt.Point; import java.io.File; import java.util.Vector; import javax.swing.JFileChooser; /** * This code was edited or generated using CloudGarden's Jigloo * SWT/Swing GUI Builder, which is free for non-commercial * use. If Jigloo is being used commercially (ie, by a corporation, * company or business for any purpose whatever) then you * should purchase a license for each developer using Jigloo. * Please visit www.cloudgarden.com for details. * Use of Jigloo implies acceptance of these licensing terms. * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. */ public class FileFrame extends ControlledFrame implements DialogListener, FrameWithControlledButton { public boolean isDirectOperation() { return true; } public void setUserPath(String p) { this.userPath=p; } public void setCommonPath(String p) { this.commonPath=p; } public void setWords(){ this.loadFromFileButton.setText(getLclTxt("load_from_common_file")); this.loadFromUserFileButton.setText(getLclTxt("load_from_user_file")); this.loadFromWebButton.setText(getLclTxt("load_from_web")); this.saveToCommonButton.setText(getLclTxt("*save_to_common_file")); this.saveToFileButton.setText(getLclTxt("save_to_user_file")); this.cancelButton.setText(getLclTxt("cancel")); } String userPath; String commonPath; public boolean isShowingRmouse() { // This method is derived from interface DialogListener // to do: code goes here return this.listener.isShowingRmouse(); } public boolean isControlledByLocalUser() { // This method is derived from interface FrameWithControlledButton // to do: code goes here if(this.listener==null) return true; return listener.isControlledByLocalUser(); } public void sendEvent(String x) { listener.sendFileDialogMessage(x); } public DialogListener listener; public void setListener(DialogListener l) { listener=l; } public void exitThis() { // draw.recordMessage("exit draw"); this.setVisible(false); } public JFileDialog fileDialog; public Vector dialogs; public Vector getDialogs() { return dialogs; } public void sendFileDialogMessage(String m) { if(this.listener==null) return; listener.sendFileDialogMessage(m); } public File getDefaultPath() { // This method is derived from interface DialogListener // to do: code goes here return null; } public void whenActionButtonPressed(EditDialog d) { // This method is derived from interface DialogListener // to do: code goes here listener.whenActionButtonPressed(d); this.setVisible(false); //hide(); } public void whenCancelButtonPressed(EditDialog d) { // This method is derived from interface DialogListener // to do: code goes here this.setVisible(false); // hide(); } public void action(int i) { if(fileDialog==null) return; fileDialog.setID(0); fileDialog.setListener(this); if(i==0){ // load from web button fileDialog.setSeparator("/"); fileDialog.setDialogName("url:"); fileDialog.promptLabel.setText("url:"); fileDialog.titleLabel.setText("input fig from web"); fileDialog.actionButton.setText("open"); fileDialog.setPath(""); fileDialog.show(); this.hide(); } else if(i==1){ // load from file button fileDialog.setDialogName("input common file name:"); fileDialog.promptLabel.setText("input common file name:"); fileDialog.titleLabel.setText("input fig from common file"); fileDialog.actionButton.setText("open"); fileDialog.setPath(this.commonPath); // fileDialog.setListener(this); fileDialog.setVisible(true); this.setVisible(false); } else if(i==2){ // load from user file button fileDialog.setDialogName("input user file name:"); fileDialog.promptLabel.setText("input user file name:"); fileDialog.titleLabel.setText("input fig from user file"); fileDialog.actionButton.setText("open"); fileDialog.setPath(this.userPath); // fileDialog.setListener(this); fileDialog.setVisible(true); this.setVisible(false); } else if(i==3){ // save to file button fileDialog.setDialogName("output user file name:"); fileDialog.promptLabel.setText("output user file name:"); fileDialog.titleLabel.setText("save the fig to user file"); fileDialog.actionButton.setText("save"); fileDialog.setPath(this.userPath); // fileDialog.setListener(this); fileDialog.setVisible(true); this.setVisible(false); } else if(i==4){ // cancel button this.setVisible(false); } else if(i==5){ // save to common button fileDialog.setDialogName("output common file name:"); fileDialog.promptLabel.setText("output common file name:"); fileDialog.titleLabel.setText("save the fig to common file"); fileDialog.actionButton.setText("save"); fileDialog.setPath(this.commonPath); // fileDialog.setListener(this); fileDialog.setVisible(true); this.setVisible(false); } } /* public void setDraw(DrawFrame d) { draw=d; } */ // public DrawFrame draw; public Vector buttons; public FileFrame() { //{{INIT_CONTROLS setTitle("A Simple Frame"); getContentPane().setLayout(null); this.setSize(230, 232); setVisible(false); loadFromWebButton.setText("load from Web"); loadFromWebButton.setActionCommand("load"); getContentPane().add(loadFromWebButton); loadFromWebButton.setBackground(new java.awt.Color(204,204,204)); loadFromWebButton.setForeground(java.awt.Color.black); loadFromWebButton.setFont(new Font("Dialog", Font.BOLD, 12)); loadFromWebButton.setBounds(12, 36, 200, 24); loadFromFileButton.setText("load from common file"); loadFromFileButton.setActionCommand("load from file"); getContentPane().add(loadFromFileButton); loadFromFileButton.setBackground(new java.awt.Color(204,204,204)); loadFromFileButton.setForeground(java.awt.Color.black); loadFromFileButton.setFont(new Font("Dialog", Font.BOLD, 12)); loadFromFileButton.setBounds(12,60,200,24); saveToFileButton.setText("save to user file"); saveToFileButton.setActionCommand("save"); getContentPane().add(saveToFileButton); saveToFileButton.setBackground(new java.awt.Color(204,204,204)); saveToFileButton.setForeground(java.awt.Color.black); saveToFileButton.setFont(new Font("Dialog", Font.BOLD, 12)); saveToFileButton.setBounds(12,132,200,24); JLabel1.setText("DSR/Draw/File"); getContentPane().add(JLabel1); JLabel1.setBounds(24,12,144,24); loadFromUserFileButton.setText("load from user file"); loadFromUserFileButton.setActionCommand("load from user file"); getContentPane().add(loadFromUserFileButton); loadFromUserFileButton.setBackground(new java.awt.Color(204,204,204)); loadFromUserFileButton.setForeground(java.awt.Color.black); loadFromUserFileButton.setFont(new Font("Dialog", Font.BOLD, 12)); loadFromUserFileButton.setBounds(12,108,200,24); cancelButton.setText("cancel"); cancelButton.setActionCommand("cancel"); getContentPane().add(cancelButton); cancelButton.setBackground(new java.awt.Color(204,204,204)); cancelButton.setForeground(java.awt.Color.black); cancelButton.setFont(new Font("Dialog", Font.BOLD, 12)); cancelButton.setBounds(12,156,200,24); saveToCommonButton.setText("*save to common file"); saveToCommonButton.setActionCommand("load from file"); getContentPane().add(saveToCommonButton); saveToCommonButton.setBackground(new java.awt.Color(204,204,204)); saveToCommonButton.setForeground(java.awt.Color.black); saveToCommonButton.setFont(new Font("Dialog", Font.BOLD, 12)); saveToCommonButton.setBounds(12,84,200,24); //}} //{{REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); loadFromWebButton.addActionListener(lSymAction); loadFromFileButton.addActionListener(lSymAction); saveToFileButton.addActionListener(lSymAction); loadFromUserFileButton.addActionListener(lSymAction); cancelButton.addActionListener(lSymAction); saveToCommonButton.addActionListener(lSymAction); //}} //{{INIT_MENUS //}} buttons=new Vector(); buttons.addElement(loadFromWebButton); buttons.addElement(loadFromFileButton); buttons.addElement(loadFromUserFileButton); buttons.addElement(saveToFileButton); buttons.addElement(cancelButton); buttons.addElement(saveToCommonButton); int numberOfButtons=buttons.size(); for(int i=0;i