// Copyright (c) 1995, 1996 Regents of the University of California. // All rights reserved. // // This software was developed by the Arcadia project // at the University of California, Irvine. // // Redistribution and use in source and binary forms are permitted // provided that the above copyright notice and this paragraph are // duplicated in all such forms and that any documentation, // advertising materials, and other materials related to such // distribution and use acknowledge that the software was developed // by the University of California, Irvine. The name of the // University may not be used to endorse or promote products derived // from this software without specific prior written permission. // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED // WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. // File: ActionSave.java // Classes: ActionSave // Original Author: jrobbins@ics.uci.edu // $Id: ActionSave.m4,v 1.1 1997/06/11 01:17:39 jrobbins Exp $ package uci.graphedit; import java.util.*; import java.awt.*; import java.io.*; changequote(<<,>>) /** Action to save the current document to a binary file using Sun's * ObjectSerialization library availible from * java.sun.com. The written file contains the Editor object and * all objects reachable through instance variables of the Editor * (e.g., the selections, the views, the contents of the views, the * net-level description of the graph, etc.). UI objects such as * Windows, Frames, Panels, and Images are not stored because I have * marked those instance variables as transient in the source * code.
* * One advantage of this approach to saving and loading is that * developers using GEF can add subclasses (e.g., to NetNode) which * introduce new instance variables, and those will be saved and * loaded without the developers having to special load and save * methods. However, make sure that you do not point to any AWT * objects unless those instance variables are transient because those * cannot be saved.
* * Needs-More-Work: the files produced by a save are not really good * for anything other than reloading into this tool, or another Java * program that uses ObjectSerialization. At this time GEF provides no * support for saving or loading textual representations of documents * that could be used in other tools.
*
* FEATURE: load_and_save
*
* FEATURE: cross_development_environments
*
* BUG: save_memory_hog
*
* BUG: saved_file_versioning
*
* BUG: save_under_jdk1_0_2
*
* @see ActionLoad */
public class ActionSave extends Action implements FilenameFilter {
public ActionSave() { }
/** Only allow the user to select files that match the fiven
* filename pattern. Needs-More-Work: this is not used yet. */
public ActionSave(String filterPattern) {
setArg("filterPattern", filterPattern);
}
public String name() { return "Save Document"; }
public void doIt(Event e) {
ifdef(<
*
* Needs-More-Work: the source code for this method is duplicated in
* ActionLoad#accept. */
public boolean accept(File dir, String name) {
System.out.println("checking: "+ dir + " " + name);
if (containsArg("filterPattern")) {
// if pattern dosen't match, return false
return true;
}
return true; // no pattern was specified
}
public void undoIt() {
System.out.println("Undo does not make sense for ActionSave");
}
} /* end class ActionSave */