org.tigris.gef.base
Class CmdSavePGML

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.tigris.gef.base.Cmd
          extended by org.tigris.gef.base.CmdSavePGML
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.FilenameFilter, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public class CmdSavePGML
extends Cmd
implements java.io.FilenameFilter

Cmd to save the current document to a binary file using Sun's ObjectSerialization library. 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.

See Also:
CmdOpen, Serialized Form

Field Summary
 
Fields inherited from class org.tigris.gef.base.Cmd
_args, _resource
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
CmdSavePGML()
           
CmdSavePGML(java.lang.String filterPattern)
          Only allow the user to select files that match the fiven filename pattern.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Only let the user select files that match the filter.
 void doIt()
          Perform whatever Cmd this Cmd is meant to do.
 void undoIt()
          Undo the Cmd using information stored during its execution.
 
Methods inherited from class org.tigris.gef.base.Cmd
about, actionPerformed, cmdAtIndex, containsArg, getArg, getArg, getName, getResource, register, registeredCmds, setArg, setName, setResource, shouldBeEnabled, updateEnabled
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmdSavePGML

public CmdSavePGML()

CmdSavePGML

public CmdSavePGML(java.lang.String filterPattern)
Only allow the user to select files that match the fiven filename pattern. Needs-More-Work: this is not used yet.

Method Detail

doIt

public void doIt()
Description copied from class: Cmd
Perform whatever Cmd this Cmd is meant to do. Subclasses should override this to do whatever is intended. When the Cmd executes, it should store enough information to undo itself later if needed.

Specified by:
doIt in class Cmd

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Only let the user select files that match the filter. This does not seem to be called under JDK 1.0.2 on solaris. I have not finished this method, it currently accepts all filenames.

Needs-More-Work: the source code for this method is duplicated in CmdOpen#accept.

Specified by:
accept in interface java.io.FilenameFilter

undoIt

public void undoIt()
Description copied from class: Cmd
Undo the Cmd using information stored during its execution.

TODO Abandon this. We need the memento pattern for undo

Specified by:
undoIt in class Cmd