[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/actions FileCloseActionListener.java,NONE
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-01-25 11:01:35
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12587/src/net/sourceforge/bprocessor/gui/actions Modified Files: FileSaveActionListener.java FileNewActionListener.java FileLoadActionListener.java Added Files: FileCloseActionListener.java Log Message: File options, now check if changes has been made, also added close option. Index: FileSaveActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileSaveActionListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileSaveActionListener.java 25 Jan 2006 09:33:04 -0000 1.1 --- FileSaveActionListener.java 25 Jan 2006 11:01:14 -0000 1.2 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.bprocessor.gui.actions; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.xml.PersistenceManager; *************** *** 43,46 **** --- 44,48 ---- try { PersistenceManager.save(file); + Project.getInstance().makeClean(); } catch (Exception ex) { log.error("Could not export to file: " + file, ex); Index: FileLoadActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileLoadActionListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileLoadActionListener.java 25 Jan 2006 09:33:04 -0000 1.1 --- FileLoadActionListener.java 25 Jan 2006 11:01:14 -0000 1.2 *************** *** 16,19 **** --- 16,20 ---- import javax.swing.JFileChooser; + import javax.swing.JOptionPane; import org.apache.log4j.Logger; *************** *** 37,54 **** */ public void actionPerformed(ActionEvent e) { ! JFileChooser chooser = new JFileChooser(); ! int state = chooser.showOpenDialog(null); ! File file = chooser.getSelectedFile(); ! if (file != null && ! state == JFileChooser.APPROVE_OPTION) { ! try { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! PersistenceManager.load(file); ! } catch (Exception ex) { ! log.error("Could not import file: " + file, ex); } } } } --- 38,119 ---- */ public void actionPerformed(ActionEvent e) { ! ! if (Project.getInstance().isDirty()) { ! int n = JOptionPane.showConfirmDialog( ! null, ! "Do you want to save the changes?", ! "Projekt has been changed", ! JOptionPane.YES_NO_CANCEL_OPTION); ! if (n == 0) { ! JFileChooser chooser = new JFileChooser(); ! int state = chooser.showSaveDialog(null); ! File file = chooser.getSelectedFile(); ! if (file != null && ! state == JFileChooser.APPROVE_OPTION) { ! try { ! PersistenceManager.save(file); ! JFileChooser loadChooser = new JFileChooser(); ! int lstate = loadChooser.showOpenDialog(null); ! File lfile = loadChooser.getSelectedFile(); ! ! if (lfile != null && ! lstate == JFileChooser.APPROVE_OPTION) { ! try { ! 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); ! } ! } ! } ! ! if (n == 1) { ! JFileChooser loadChooser = new JFileChooser(); ! int lstate = loadChooser.showOpenDialog(null); ! File lfile = loadChooser.getSelectedFile(); ! ! if (lfile != null && ! lstate == JFileChooser.APPROVE_OPTION) { ! try { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! PersistenceManager.load(lfile); ! Project.getInstance().makeClean(); ! } catch (Exception ex) { ! log.error("Could not import file: " + lfile, ex); ! } ! } ! } ! ! } else { ! ! JFileChooser loadChooser = new JFileChooser(); ! int lstate = loadChooser.showOpenDialog(null); ! File lfile = loadChooser.getSelectedFile(); ! ! if (lfile != null && ! lstate == JFileChooser.APPROVE_OPTION) { ! try { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! PersistenceManager.load(lfile); ! Project.getInstance().makeClean(); ! } catch (Exception ex) { ! log.error("Could not import file: " + lfile, ex); ! } } } + + + + + } } Index: FileNewActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/FileNewActionListener.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FileNewActionListener.java 11 Jan 2006 09:07:58 -0000 1.2 --- FileNewActionListener.java 25 Jan 2006 11:01:14 -0000 1.3 *************** *** 10,16 **** --- 10,23 ---- import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + import java.io.File; + + import javax.swing.JFileChooser; + import javax.swing.JOptionPane; + + import org.apache.log4j.Logger; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; + import net.sourceforge.bprocessor.model.xml.PersistenceManager; /** *************** *** 20,23 **** --- 27,33 ---- public class FileNewActionListener implements ActionListener { + /** The logger */ + private static Logger log = Logger.getLogger(FileCloseActionListener.class); + /** * Constructs the FileNewActionListner *************** *** 32,37 **** */ public void actionPerformed(ActionEvent event) { ! Selection.primary().clear(); ! Project.getInstance().clear(); } --- 42,79 ---- */ public void actionPerformed(ActionEvent event) { ! if (Project.getInstance().isDirty()) { ! int n = JOptionPane.showConfirmDialog( ! null, ! "Do you want to save the changes?", ! "Projekt has been changed", ! JOptionPane.YES_NO_CANCEL_OPTION); ! if (n == 0) { ! JFileChooser chooser = new JFileChooser(); ! int state = chooser.showSaveDialog(null); ! File file = chooser.getSelectedFile(); ! if (file != null && ! state == JFileChooser.APPROVE_OPTION) { ! try { ! PersistenceManager.save(file); ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! } catch (Exception ex) { ! log.error("Could not export to file: " + file, ex); ! } ! } ! } ! ! if (n == 1) { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! } ! ! } else { ! Selection.primary().clear(); ! Project.getInstance().clear(); ! Project.getInstance().makeClean(); ! } } --- NEW FILE: FileCloseActionListener.java --- //--------------------------------------------------------------------------------- // $Id: FileCloseActionListener.java,v 1.1 2006/01/25 11:01:14 nbramsen Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.actions; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import org.apache.log4j.Logger; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.xml.PersistenceManager; /** * The FileCloseActionListener */ public class FileCloseActionListener implements ActionListener { /** The logger */ private static Logger log = Logger.getLogger(FileCloseActionListener.class); /** * Constructs the FileCloseActionListner */ public FileCloseActionListener() { super(); } /** * Clears the project * @param event The event */ public void actionPerformed(ActionEvent event) { if (Project.getInstance().isDirty()) { int n = JOptionPane.showConfirmDialog( null, "Do you want to save the changes?", "Projekt has been changed", JOptionPane.YES_NO_CANCEL_OPTION); if (n == 0) { JFileChooser chooser = new JFileChooser(); int state = chooser.showSaveDialog(null); File file = chooser.getSelectedFile(); if (file != null && state == JFileChooser.APPROVE_OPTION) { try { PersistenceManager.save(file); Selection.primary().clear(); Project.getInstance().clear(); Project.getInstance().makeClean(); } catch (Exception ex) { log.error("Could not export to file: " + file, ex); } } } if (n == 1) { Selection.primary().clear(); Project.getInstance().clear(); Project.getInstance().makeClean(); } } else { Selection.primary().clear(); Project.getInstance().clear(); Project.getInstance().makeClean(); } } } |