[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/actions FileSaveActionListener.java,1.5,1
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-03-21 17:04:35
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3567/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileSaveActionListener.java FileNewActionListener.java FileExitActionListener.java FileLoadActionListener.java FileCloseActionListener.java FileSaveAsActionListener.java Log Message: Cleaned structure of File Menu Code Fixed a large number of bugs in File menu Code (there are still bugs left) Index: FileLoadActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileLoadActionListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FileLoadActionListener.java 13 Feb 2006 12:37:23 -0000 1.5 --- FileLoadActionListener.java 21 Mar 2006 12:24:13 -0000 1.6 *************** *** 8,13 **** import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Selection; - import net.sourceforge.bprocessor.model.xml.PersistenceManager; import java.awt.event.ActionEvent; --- 8,11 ---- *************** *** 57,65 **** Project.getInstance().setDefaultPath(file.getAbsolutePath()); if (file.getName().lastIndexOf('.') != -1) { ! PersistenceManager.save(file); } else { ! PersistenceManager.save(new File(file.getCanonicalFile() + ".bp")); } ! JFileChooser loadChooser = new JFileChooser(Project.getInstance().getDefaultPath()); loadChooser.addChoosableFileFilter(new MyFileFilter()); --- 55,63 ---- Project.getInstance().setDefaultPath(file.getAbsolutePath()); if (file.getName().lastIndexOf('.') != -1) { ! Project.getInstance().saveAs(file); } else { ! Project.getInstance().saveAs(new File(file.getCanonicalFile() + ".bp")); } ! JFileChooser loadChooser = new JFileChooser(Project.getInstance().getDefaultPath()); loadChooser.addChoosableFileFilter(new MyFileFilter()); *************** *** 69,84 **** lstate == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().setSavePath(lfile.getAbsolutePath()); ! Project.getInstance().setDefaultPath(lfile.getAbsolutePath()); ! Selection.primary().clear(); ! Project.getInstance().clear(); ! PersistenceManager.load(lfile); ! Project.getInstance().makeClean(); } catch (Exception ex) { ! log.error("Could not import file: " + lfile, ex); } } } catch (Exception ex) { ! log.error("Could not export to file: " + file, ex); } } --- 67,77 ---- lstate == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().load(lfile); } catch (Exception ex) { ! log.error("Could not open file: " + lfile, ex); } } } catch (Exception ex) { ! log.error("Could not save to file: " + file, ex); } } *************** *** 93,104 **** lstate == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().setSavePath(lfile.getAbsolutePath()); ! Project.getInstance().setDefaultPath(lfile.getAbsolutePath()); ! Selection.primary().clear(); ! Project.getInstance().clear(); ! PersistenceManager.load(lfile); ! Project.getInstance().makeClean(); } catch (Exception ex) { ! log.error("Could not import file: " + lfile, ex); } } --- 86,92 ---- lstate == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().load(lfile); } catch (Exception ex) { ! log.error("Could not open file: " + lfile, ex); } } *************** *** 115,126 **** lstate == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().setSavePath(lfile.getAbsolutePath()); ! Project.getInstance().setDefaultPath(lfile.getAbsolutePath()); ! Selection.primary().clear(); ! Project.getInstance().clear(); ! PersistenceManager.load(lfile); ! Project.getInstance().makeClean(); } catch (Exception ex) { ! log.error("Could not import file: " + lfile, ex); } } --- 103,109 ---- lstate == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().load(lfile); } catch (Exception ex) { ! log.error("Could not open file: " + lfile, ex); } } Index: FileExitActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileExitActionListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FileExitActionListener.java 2 Mar 2006 13:08:12 -0000 1.5 --- FileExitActionListener.java 21 Mar 2006 12:24:13 -0000 1.6 *************** *** 15,19 **** import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.xml.PersistenceManager; import org.apache.log4j.Logger; --- 15,18 ---- *************** *** 52,63 **** state == JFileChooser.APPROVE_OPTION) { try { ! PersistenceManager.save(file); ! Project.getInstance().setDefaultPath(file.getAbsolutePath()); System.exit(0); } catch (Exception ex) { ! log.error("Could not export to file: " + file, ex); } } ! } } else if (n == 1) { System.exit(0); --- 51,69 ---- state == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().saveAs(file); System.exit(0); } catch (Exception ex) { ! log.error("Could not save to file: " + file, ex); } } ! } else { ! try { ! Project.getInstance().save(); ! System.exit(0); ! } catch (Exception ex) { ! log.error("Could not save to file: " + ! new File(Project.getInstance().getSavePath()), ex); ! } ! } } else if (n == 1) { System.exit(0); Index: FileCloseActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileCloseActionListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FileCloseActionListener.java 20 Mar 2006 15:13:08 -0000 1.5 --- FileCloseActionListener.java 21 Mar 2006 12:24:13 -0000 1.6 *************** *** 18,23 **** import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Selection; - import net.sourceforge.bprocessor.model.xml.PersistenceManager; /** --- 18,21 ---- *************** *** 42,46 **** */ public void actionPerformed(ActionEvent event) { - if (Project.getInstance().isDirty()) { int n = JOptionPane.showConfirmDialog( --- 40,43 ---- *************** *** 51,55 **** if (n == 0) { if (Project.getInstance().getSavePath() == null) { ! JFileChooser chooser = new JFileChooser(Project.getInstance().getDefaultPath()); chooser.addChoosableFileFilter(new MyFileFilter()); int state = chooser.showSaveDialog(null); --- 48,53 ---- if (n == 0) { if (Project.getInstance().getSavePath() == null) { ! String path = Project.getInstance().getDefaultPath(); ! JFileChooser chooser = new JFileChooser(path); chooser.addChoosableFileFilter(new MyFileFilter()); int state = chooser.showSaveDialog(null); *************** *** 58,82 **** state == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().setDefaultPath(file.getAbsolutePath()); if (file.getName().lastIndexOf('.') != -1) { ! PersistenceManager.save(file); } else { ! PersistenceManager.save(new File(file.getCanonicalFile() + ".bp")); } ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } catch (Exception ex) { ! log.error("Could not export to file: " + file, ex); } } } else { try { ! PersistenceManager.save(new File(Project.getInstance().getSavePath())); ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } catch (Exception ex) { log.error("Could not export to file: " + --- 56,74 ---- state == JFileChooser.APPROVE_OPTION) { try { ! if (file.getName().lastIndexOf('.') != -1) { ! Project.getInstance().saveAs(file); } else { ! Project.getInstance().saveAs(new File(file.getCanonicalFile() + ".bp")); } ! Project.getInstance().close(); } catch (Exception ex) { ! log.error("Could not save to file: " + file, ex); } } } else { try { ! Project.getInstance().save(); ! Project.getInstance().close(); } catch (Exception ex) { log.error("Could not export to file: " + *************** *** 87,103 **** if (n == 1) { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } - } else { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } } - } --- 79,87 ---- if (n == 1) { ! Project.getInstance().close(); } } else { ! Project.getInstance().close(); } } } Index: FileNewActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileNewActionListener.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FileNewActionListener.java 13 Feb 2006 12:37:23 -0000 1.6 --- FileNewActionListener.java 21 Mar 2006 12:24:13 -0000 1.7 *************** *** 18,23 **** import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Selection; - import net.sourceforge.bprocessor.model.xml.PersistenceManager; /** --- 18,21 ---- *************** *** 59,71 **** try { if (file.getName().lastIndexOf('.') != -1) { ! PersistenceManager.save(file); } else { ! PersistenceManager.save(new File(file.getCanonicalFile() + ".bp")); } ! Project.getInstance().setDefaultPath(file.getAbsolutePath()); ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } catch (Exception ex) { log.error("Could not export to file: " + file, ex); --- 57,65 ---- try { if (file.getName().lastIndexOf('.') != -1) { ! Project.getInstance().saveAs(file); } else { ! Project.getInstance().saveAs(new File(file.getCanonicalFile() + ".bp")); } ! Project.getInstance().close(); } catch (Exception ex) { log.error("Could not export to file: " + file, ex); *************** *** 74,82 **** } else { try { ! PersistenceManager.save(new File(Project.getInstance().getSavePath())); ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } catch (Exception ex) { log.error("Could not export to file: " + --- 68,73 ---- } else { try { ! Project.getInstance().save(); ! Project.getInstance().close(); } catch (Exception ex) { log.error("Could not export to file: " + *************** *** 86,100 **** } if (n == 1) { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } - } else { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! Project.getInstance().setSavePath(null); } } --- 77,84 ---- } if (n == 1) { ! Project.getInstance().close(); } } else { ! Project.getInstance().close(); } } Index: FileSaveAsActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileSaveAsActionListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FileSaveAsActionListener.java 13 Feb 2006 12:37:23 -0000 1.3 --- FileSaveAsActionListener.java 21 Mar 2006 12:24:13 -0000 1.4 *************** *** 8,12 **** import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.xml.PersistenceManager; import java.awt.event.ActionEvent; --- 8,11 ---- *************** *** 43,54 **** state == JFileChooser.APPROVE_OPTION) { try { ! Project.getInstance().setDefaultPath(file.getAbsolutePath()); ! Project.getInstance().setSavePath(file.getAbsolutePath()); if (file.getName().lastIndexOf('.') != -1) { ! PersistenceManager.save(file); } else { ! PersistenceManager.save(new File(file.getCanonicalFile() + ".bp")); } - Project.getInstance().makeClean(); } catch (Exception ex) { log.error("Could not export to file: " + file, ex); --- 42,51 ---- state == JFileChooser.APPROVE_OPTION) { try { ! if (file.getName().lastIndexOf('.') != -1) { ! Project.getInstance().saveAs(file); } else { ! Project.getInstance().saveAs(new File(file.getCanonicalFile() + ".bp")); } } catch (Exception ex) { log.error("Could not export to file: " + file, ex); Index: FileSaveActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileSaveActionListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FileSaveActionListener.java 13 Feb 2006 12:37:22 -0000 1.5 --- FileSaveActionListener.java 21 Mar 2006 12:24:13 -0000 1.6 *************** *** 8,12 **** import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.xml.PersistenceManager; import java.awt.event.ActionEvent; --- 8,11 ---- *************** *** 47,67 **** try { if (file.getName().lastIndexOf('.') != -1) { ! PersistenceManager.save(file); } else { ! PersistenceManager.save(new File(file.getCanonicalFile() + ".bp")); } - Project.getInstance().setSavePath(file.getAbsolutePath()); - Project.getInstance().setDefaultPath(file.getAbsolutePath()); - Project.getInstance().makeClean(); } catch (Exception ex) { ! log.error("Could not export to file: " + file, ex); } } } else { try { ! PersistenceManager.save(new File(Project.getInstance().getSavePath())); ! Project.getInstance().makeClean(); } catch (Exception ex) { ! log.error("Could not export to file: " + new File(Project.getInstance().getSavePath()), ex); } --- 46,62 ---- try { if (file.getName().lastIndexOf('.') != -1) { ! Project.getInstance().saveAs(file); } else { ! Project.getInstance().saveAs(new File(file.getCanonicalFile() + ".bp")); } } catch (Exception ex) { ! log.error("Could not save to file: " + file, ex); } } } else { try { ! Project.getInstance().save(); } catch (Exception ex) { ! log.error("Could not save to file: " + new File(Project.getInstance().getSavePath()), ex); } |