| com.jgraph.editor.JGraphEditorAction com.jgraph.pad.action.JGraphpadFileAction
All known Subclasses: com.jgraph.codecplugin.JGraphpadCodecAction, com.jgraph.jgxplugin.JGraphpadJGXAction, com.jgraph.pdfplugin.JGraphpadPDFAction, com.jgraph.svgplugin.JGraphpadSVGAction, com.jgraph.epsplugin.JGraphpadEPSAction,
JGraphpadFileAction | public class JGraphpadFileAction extends JGraphEditorAction (Code) | | Implements all actions of the file menu. The openRecent menu is implemented
using the
JGraphpadOpenRecentMenu class, and the import/export
actions are added to the file menu by plugins, so look for their
implementations there.
|
Inner Class :public static class AllActions implements Bundle | |
Method Summary | |
public void | actionPerformed(ActionEvent event) Executes the action based on the action name. | public static String | convert(OutputStream data, String mime) Converts the specified data stream into a string assuming the data stream
is of the specified mime type. | protected void | doCloseAll() Closes all open files using
JGraphpadFileAction.doCloseFile(JGraphEditorFile,boolean) giving the user a chance
to save unsaved changes before closing each file. | protected void | doCloseFile(JGraphEditorFile file, boolean remove) Closes the specified file by removing it from the parent. | protected void | doExit() Closes all open files using
JGraphpadFileAction.doCloseAll() , saves the user
settings and terminates the program using
System.exit(int) . | protected void | doImportCSV(GraphLayoutCache cache, String filename) Displays a file- or URL-dialog and loads the selected file or URL into
the specified diagram as a comma separated value file (CSV) using
JGraphpadFileAction.importCSVFile(GraphLayoutCache,InputStream,String,Object,Object,String) . | protected void | doNewDiagram(JGraphEditorFile file) Inserts a new empty diagram into the specified file. | protected void | doNewDocument() Inserts a new empty document into the document model. | protected void | doNewLibrary() Inserts a new library into the given file. | protected void | doOpenFile(String filename) Opens the specified filename using
JGraphEditorModel.addFile(String) if a file for the specified
name is not already open. | protected void | doPageSetup(JGraphEditorDiagramPane diagramPane) Displays the system page format dialog and updates the pageformat on the
specified diagram pane. | protected void | doPrintDiagramPane(JGraphEditorDiagramPane diagramPane) Displays a system print dialog and prints the specified diagram pane. | protected void | doRemoveDiagram(JGraphEditorDiagram diagram) Removes the specified diagram from the parent file if the parent file
contains at least one diagram after the removal. | protected void | doRenameDiagram(JGraphEditorDiagram diagram) Displays a dialog to enter the new name for the specified diagram and
updates the name of the diagram using
JGraphEditorModel.setName(JGraphEditorDiagramString) . | public void | doSave(String filename, byte[] data) Saves the specified byte array to the specified file. | protected void | doSaveAll() Saves all open files using
JGraphpadFileAction.doSaveFile(JGraphEditorFile,boolean,boolean) showing file
dialogs for files whose filename has not been assigned. | protected void | doSaveFile(JGraphEditorFile file, boolean forceFilenameDialog, boolean urlDialog) Saves the specified file displaying a filename dialog if the filename is
not set or if forceFilenameDialog is true. | protected void | doSaveImage(JGraphEditorDiagramPane diagramPane, int inset, String filename) Saves the specified graph as an image using inset as the
size of the empty border around the image. | public static Object | getCellForKey(GraphModel model, Object prototype, Hashtable map, String key, int cols, int w, int h, int offset, boolean image) Utility method to return the cell stored under key in the specified map
or create the cell using the specified prototype and model and put it
into the map under key. | protected int | getFileCount(boolean countLibraries) Uses
JGraphpadFileAction.isLibrary(JGraphEditorFile) to find the number of roots
that are instances of
JGraphEditorFile . | protected int | getFileCount(Object root, boolean countLibraries) Uses
JGraphpadFileAction.isLibrary(JGraphEditorFile) to find the number of roots
that are instances of
JGraphEditorFile . | public static JGraphEditorFile | getPermanentFocusOwnerFile() Returns the diagram for the permanent focus owner diagram pane. | public static JGraphpadLibraryPane | getPermanentFocusOwnerLibraryPane() Returns the permanent focus owner library pane. | public static void | importCSVFile(GraphLayoutCache cache, InputStream fstream, String delim, Object vertexPrototype, Object edgePrototype, String defaultEdgeLabel) Reads the specified input stream as a comma-delimeted file, using the
following format: a,b[,c] where a and b are vertices and c is the label
of the edge to be inserted between a and b. | protected boolean | isLibrary(JGraphEditorFile file) Returns true if the specified file is a library. | public static String | makeMimeForm(String fileName, String type, String path, String content, String comment, String sep) Returns a mime form using the specified parameters. | public static boolean | post(URL url, String path, String mime, OutputStream data) Posts the data to the specified url using path to specify
the filename in the mime response for the specified mime type.
Parameters: url - The url to post the mime response to. Parameters: path - The filename to use in the mime response. Parameters: mime - The mime type to use for the response. Parameters: data - The binary data to send with the mime response. | public static boolean | post(URL url, String path, String mime, String data) Posts the data to the specified url using path to specify
the filename in the mime response for the specified mime type.
Parameters: url - The url to post the mime response to. Parameters: path - The filename to use in the mime response. Parameters: mime - The mime type to use for the response. Parameters: data - The binary data to send with the mime response. | public static boolean | postPlain(URL url, String path, OutputStream data) Posts the data to the specified url using path to specify
the filename in the mime response using for type
JGraphpadFileAction.MIME_PLAINTEXT .
Parameters: url - The url to post the mime response to. Parameters: path - The filename to use in the mime response. Parameters: data - The binary data to send with the mime response. |
KEY_MAINWINDOW | final public static String KEY_MAINWINDOW(Code) | | Defines the key for the main windows object. This key is used to store a
reference in the editor settings for the bounds of the application
window. This class is in charge of storing the bounds in
JGraphpad.PATH_USERSETTINGS on program termination.
|
KEY_RECENTFILES | final public static String KEY_RECENTFILES(Code) | | Defines the key for the recent files user settings. This class is in
charge of updating the list and storing it in
JGraphpad.PATH_USERSETTINGS on program termination.
|
MIME_PLAINTEXTMIME_HTML | final public static String MIME_PLAINTEXTMIME_HTML(Code) | | Defines the text/plain mime-type.
|
NAME_CLOSE | final public static String NAME_CLOSE(Code) | | Specifies the name for the close action.
|
NAME_CLOSEALL | final public static String NAME_CLOSEALL(Code) | | Specifies the name for the closeAll action.
|
NAME_DOWNLOAD | final public static String NAME_DOWNLOAD(Code) | | Specifies the name for the download action.
|
NAME_EXIT | final public static String NAME_EXIT(Code) | | Specifies the name for the exit action.
|
NAME_IMPORTCSV | final public static String NAME_IMPORTCSV(Code) | | Specifies the name for the importCSV action.
|
NAME_NEWDIAGRAM | final public static String NAME_NEWDIAGRAM(Code) | | Specifies the name for the newDiagram action.
|
NAME_NEWDOCUMENT | final public static String NAME_NEWDOCUMENT(Code) | | Specifies the name for the newDocument action.
|
NAME_NEWLIBRARY | final public static String NAME_NEWLIBRARY(Code) | | Specifies the name for the newLibrary action.
|
NAME_OPEN | final public static String NAME_OPEN(Code) | | Specifies the name for the open action.
|
NAME_PAGESETUP | final public static String NAME_PAGESETUP(Code) | | Specifies the name for the pageSetup action.
|
NAME_PRINT | final public static String NAME_PRINT(Code) | | Specifies the name for the print action.
|
NAME_REMOVEDIAGRAM | final public static String NAME_REMOVEDIAGRAM(Code) | | Specifies the name for the removeDiagram action.
|
NAME_RENAMEDIAGRAM | final public static String NAME_RENAMEDIAGRAM(Code) | | Specifies the name for the renameDiagram action.
|
NAME_SAVE | final public static String NAME_SAVE(Code) | | Specifies the name for the save action.
|
NAME_SAVEALL | final public static String NAME_SAVEALL(Code) | | Specifies the name for the saveAll action.
|
NAME_SAVEAS | final public static String NAME_SAVEAS(Code) | | Specifies the name for the saveAs action.
|
NAME_SAVEIMAGE | final public static String NAME_SAVEIMAGE(Code) | | Specifies the name for the saveImage action.
|
NAME_UPLOADAS | final public static String NAME_UPLOADAS(Code) | | Specifies the name for the uploadAs action.
|
NLNLNL | static String NLNLNL(Code) | | Defines the (double) newline character as used in mime responses.
|
lastDirectory | protected File lastDirectory(Code) | | Holds the last directory for file operations.
|
JGraphpadFileAction | public JGraphpadFileAction(String name, JGraphEditor editor)(Code) | | Constructs a new file action for the specified name and editor.
Parameters: name - The name of the action to be created. Parameters: editor - The enclosing editor for the action. |
actionPerformed | public void actionPerformed(ActionEvent event)(Code) | | Executes the action based on the action name.
Parameters: event - The object that describes the event. |
convert | public static String convert(OutputStream data, String mime)(Code) | | Converts the specified data stream into a string assuming the data stream
is of the specified mime type. This performs a byte to char conversion on
all mime types other than
JGraphpadFileAction.MIME_PLAINTEXT .
Parameters: data - The data to be converted. Parameters: mime - The mime type to assume for the data. Returns a string representation of the data in the stream. |
doNewDiagram | protected void doNewDiagram(JGraphEditorFile file)(Code) | | Inserts a new empty diagram into the specified file. The name is assigned
automatically using the Diagram resource string and the number returned
by
TreeModel.getChildCount(java.lang.Object) for the file.
Parameters: file - The file to add the diagram to. |
doNewDocument | protected void doNewDocument()(Code) | | Inserts a new empty document into the document model. The name is
assigned automatically using the Document resource string and the number
returned by
JGraphpadFileAction.getFileCount(boolean) .
|
doPageSetup | protected void doPageSetup(JGraphEditorDiagramPane diagramPane)(Code) | | Displays the system page format dialog and updates the pageformat on the
specified diagram pane.
Parameters: diagramPane - The diagram pane to set the page format. |
doPrintDiagramPane | protected void doPrintDiagramPane(JGraphEditorDiagramPane diagramPane) throws PrinterException(Code) | | Displays a system print dialog and prints the specified diagram pane.
Parameters: diagramPane - The diagram pane to be printed. throws: PrinterException - If the document can not be printed. |
doRemoveDiagram | protected void doRemoveDiagram(JGraphEditorDiagram diagram)(Code) | | Removes the specified diagram from the parent file if the parent file
contains at least one diagram after the removal. Otherwise the diagram is
not removed. This implementation displays a confirmation dialog before
actually removing the diagram.
Parameters: diagram - The diagram to be removed from its parent file. See Also: JGraphpadDialogs.confirmDialog(ComponentStringbooleanboolean) |
doSave | public void doSave(String filename, byte[] data) throws Exception(Code) | | Saves the specified byte array to the specified file.
Parameters: filename - The filename of the file to be written. Parameters: data - The array of bytes to write to the file. |
doSaveFile | protected void doSaveFile(JGraphEditorFile file, boolean forceFilenameDialog, boolean urlDialog) throws IOException(Code) | | Saves the specified file displaying a filename dialog if the filename is
not set or if forceFilenameDialog is true. If
urlDialog is true, then the dialog will ask for an URL
instead of a local file.
This implementation does the following additional checks:
- If the file already exists it asks whether it should be overwritten.
- It rejects to assign filenames of files which are already open.
- If filename is an URL it tries to upload the data to that URL.
Furthermore, this implementation updates the isNew and modified state of
the file if it has successfully been saved.
Parameters: file - The file to be saved. Parameters: forceFilenameDialog - Whether to display a dialog regardless of the filename. Parameters: urlDialog - Whether to display an URL dialog to specifiy the filename. throws: IOException - If the file cannot be saved. See Also: JGraphEditorModel.getOutputStream(String) See Also: JGraphpadFileAction.postPlain(URL,String,OutputStream) |
getCellForKey | public static Object getCellForKey(GraphModel model, Object prototype, Hashtable map, String key, int cols, int w, int h, int offset, boolean image)(Code) | | Utility method to return the cell stored under key in the specified map
or create the cell using the specified prototype and model and put it
into the map under key. The cells will be positioned into a matrix with
cols columns and entries of size (w,h).
Parameters: model - The model to use for cloning the prototype. Parameters: prototype - The prototype to use for creating new cells. Parameters: map - The map to check whether the cell exists for key. Parameters: key - The key to return the cell for. Parameters: cols - The number of columns for the matrix. Parameters: w - The width of the entries. Parameters: h - The height of the entries. Parameters: offset - The offset from the top left. Parameters: image - Whether to insert image or text cells. Returns the cell for the specified key. |
getFileCount | protected int getFileCount(boolean countLibraries)(Code) | | Uses
JGraphpadFileAction.isLibrary(JGraphEditorFile) to find the number of roots
that are instances of
JGraphEditorFile . If
countLibraries is true, then the number of libraries is
returned.
The following always holds:
getFileCount(false) + getFileCount(true) ==
getChildCount(getRoot())
Parameters: countLibraries - Whether libraries or non-libraries should be counted. Returns the number of libraries or non-libraries. |
getFileCount | protected int getFileCount(Object root, boolean countLibraries)(Code) | | Uses
JGraphpadFileAction.isLibrary(JGraphEditorFile) to find the number of roots
that are instances of
JGraphEditorFile . If
countLibraries is true, then the number of libraries is
returned.
The following always holds:
getFileCount(false) + getFileCount(true) ==
getChildCount(getRoot())
Parameters: countLibraries - Whether libraries or non-libraries should be counted. Returns the number of libraries or non-libraries. |
getPermanentFocusOwnerFile | public static JGraphEditorFile getPermanentFocusOwnerFile()(Code) | | Returns the diagram for the permanent focus owner diagram pane.
|
getPermanentFocusOwnerLibraryPane | public static JGraphpadLibraryPane getPermanentFocusOwnerLibraryPane()(Code) | | Returns the permanent focus owner library pane.
|
importCSVFile | public static void importCSVFile(GraphLayoutCache cache, InputStream fstream, String delim, Object vertexPrototype, Object edgePrototype, String defaultEdgeLabel) throws IOException(Code) | | Reads the specified input stream as a comma-delimeted file, using the
following format: a,b[,c] where a and b are vertices and c is the label
of the edge to be inserted between a and b. For example, to create a
triangle, use:
a,b,ab
b,c,bc
c,a,ca
Parameters: cache - The layout cache to import the file into. Parameters: fstream - The stream to import the cells from. Parameters: delim - The delimeter to parse the tokens. Parameters: vertexPrototype - The prototype to create new vertices with. Parameters: edgePrototype - The prototype to create new edges with. Parameters: defaultEdgeLabel - The default label to use for edges if none is specified. throws: IOException - |
isLibrary | protected boolean isLibrary(JGraphEditorFile file)(Code) | | Returns true if the specified file is a library. This implementation
returns true if file is an instance of
JGraphpadLibrary .
Parameters: file - The file to be checked. Returns true if file is a library. |
post | public static boolean post(URL url, String path, String mime, OutputStream data) throws IOException(Code) | | Posts the data to the specified url using path to specify
the filename in the mime response for the specified mime type.
Parameters: url - The url to post the mime response to. Parameters: path - The filename to use in the mime response. Parameters: mime - The mime type to use for the response. Parameters: data - The binary data to send with the mime response. Returns true if the data was successfuly posted. throws: IOException - |
post | public static boolean post(URL url, String path, String mime, String data) throws IOException(Code) | | Posts the data to the specified url using path to specify
the filename in the mime response for the specified mime type.
Parameters: url - The url to post the mime response to. Parameters: path - The filename to use in the mime response. Parameters: mime - The mime type to use for the response. Parameters: data - The binary data to send with the mime response. Returns true if the data was successfuly posted. throws: IOException - |
postPlain | public static boolean postPlain(URL url, String path, OutputStream data) throws IOException(Code) | | Posts the data to the specified url using path to specify
the filename in the mime response using for type
JGraphpadFileAction.MIME_PLAINTEXT .
Parameters: url - The url to post the mime response to. Parameters: path - The filename to use in the mime response. Parameters: data - The binary data to send with the mime response. Returns true if the data was successfuly posted. throws: IOException - |
|
|