01: /*
02: * $Id: JGraphpadFile.java,v 1.2 2005/08/06 22:24:16 gaudenz Exp $
03: * Copyright (c) 2001-2005, Gaudenz Alder
04: *
05: * All rights reserved.
06: *
07: * See LICENSE file for license details. If you are unable to locate
08: * this file please contact info (at) jgraph (dot) com.
09: */
10: package com.jgraph.pad;
11:
12: import javax.swing.tree.DefaultMutableTreeNode;
13:
14: import com.jgraph.editor.JGraphEditorFile;
15:
16: /**
17: * Represents a file in the JGraphpad editor. A file may contain any number of
18: * children which are themselfes XML encodable.
19: */
20: public class JGraphpadFile extends DefaultMutableTreeNode implements
21: JGraphEditorFile {
22:
23: /**
24: * Specifies if the file has been modified since the last save.
25: */
26: protected transient boolean modified;
27:
28: /**
29: * Specifies if the file has been saved since its creation.
30: */
31: protected transient boolean isNew = false;
32:
33: /**
34: * Constructs a new file.
35: */
36: public JGraphpadFile() {
37: this (null);
38: }
39:
40: /**
41: * Constructs a new file using the filename as the user object.
42: *
43: * @param filename
44: * The user object of the parent object.
45: */
46: public JGraphpadFile(String filename) {
47: super (filename);
48: isNew = (filename != null);
49: }
50:
51: /*
52: * (non-Javadoc)
53: */
54: public void setNew(boolean isNew) {
55: this .isNew = isNew;
56: }
57:
58: /*
59: * (non-Javadoc)
60: */
61: public boolean isNew() {
62: return isNew;
63: }
64:
65: /*
66: * (non-Javadoc)
67: */
68: public void setModified(boolean modified) {
69: this .modified = modified;
70: }
71:
72: /*
73: * (non-Javadoc)
74: */
75: public boolean isModified() {
76: return modified;
77: }
78:
79: /*
80: * (non-Javadoc)
81: */
82: public void setFilename(String filename) {
83: setUserObject(filename);
84: }
85:
86: /*
87: * (non-Javadoc)
88: */
89: public String getFilename() {
90: Object obj = getUserObject();
91: if (obj != null)
92: return obj.toString();
93: return null;
94: }
95:
96: }
|