package bluej.pkgmgr.actions;

import java.io.File;
import java.io.IOException;

import bluej.Config;
import bluej.pkgmgr.Package;
import bluej.pkgmgr.PkgMgrFrame;
import bluej.pkgmgr.Project;
import bluej.pkgmgr.ProjectUtils;
import bluej.utility.Debug;
import bluej.utility.DialogManager;
import bluej.utility.FileUtility;


| User chooses "save project as". This allows saving the project under a | * different name, to make a backup etc. * * @author Davin McCall */ final public class SaveProjectAsAction extends PkgMgrAction{ public SaveProjectAsAction(PkgMgrFrame pmf) | |
{ | |
super(pmf, "menu.package.saveAs"); } public void actionPerformed(PkgMgrFrame pmf) { pmf.menuCall(); saveAs(pmf, pmf.getProject()); } public void saveAs(PkgMgrFrame frame, Project project) | | { | | // get a file name to save under | | File newName = FileUtility.getSaveProjectFX(project, frame.getFXWindow(), Config.getString("pkgmgr.saveAs.title")); if (newName == null) { return; } try { project.saveAll(); project.saveAllEditors(); } | | catch (IOException ioe) | | { | | DialogManager.showErrorFX(frame.getFXWindow(), "cannot-save-project"); return; } if (! ProjectUtils.saveProjectCopy(project, newName, frame.getFXWindow())) { return; } | | // Copy successful: close the current project and open the new one | | PkgMgrFrame.closeProject(project); | | Project openProj = Project.openProject(newName.getAbsolutePath()); | | if (openProj != null) | | { | | Package pkg = openProj.getPackage(""); PkgMgrFrame pmf = PkgMgrFrame.createFrame(pkg, null); pmf.setVisible(true); } else { Debug.message("Save as: could not open package under new name"); } } }




12 neLoCode + 15 LoComm