Lines 59-64
Link Here
|
59 |
/** Position of cursor. Used to keep the value between deserialization |
59 |
/** Position of cursor. Used to keep the value between deserialization |
60 |
* and initialization time. */ |
60 |
* and initialization time. */ |
61 |
private int cursorPosition = -1; |
61 |
private int cursorPosition = -1; |
|
|
62 |
|
63 |
/** |
64 |
* Persistent data for the document associated with the editor pane. |
65 |
*/ |
66 |
private Object documentPersistentData; |
62 |
|
67 |
|
63 |
// #20647. More important custom component. |
68 |
// #20647. More important custom component. |
64 |
/** Custom editor component, which is used if specified by document |
69 |
/** Custom editor component, which is used if specified by document |
Lines 72-77
Link Here
|
72 |
|
77 |
|
73 |
static final long serialVersionUID = -185739563792410059L; |
78 |
static final long serialVersionUID = -185739563792410059L; |
74 |
|
79 |
|
|
|
80 |
/** |
81 |
* Document property used for storing and retrieving of the data to be persisted |
82 |
* during the CloneableEditor serialization. |
83 |
*/ |
84 |
static final String PERSISTENT_DATA_DOCUMENT_PROPERTY = "persistentData"; |
85 |
|
75 |
/** For externalization of subclasses only */ |
86 |
/** For externalization of subclasses only */ |
76 |
public CloneableEditor() { |
87 |
public CloneableEditor() { |
77 |
this(null); |
88 |
this(null); |
Lines 197-202
Link Here
|
197 |
|
208 |
|
198 |
pane.setEditorKit (support.kit ()); |
209 |
pane.setEditorKit (support.kit ()); |
199 |
|
210 |
|
|
|
211 |
// Set the document's persistent data into the document prior assigning |
212 |
// of the document to the component |
213 |
if (documentPersistentData != null) { |
214 |
doc.putProperty(PERSISTENT_DATA_DOCUMENT_PROPERTY, documentPersistentData); |
215 |
} |
216 |
|
200 |
pane.setDocument (doc); |
217 |
pane.setDocument (doc); |
201 |
if (doc instanceof NbDocument.CustomEditor) { |
218 |
if (doc instanceof NbDocument.CustomEditor) { |
202 |
NbDocument.CustomEditor ce = (NbDocument.CustomEditor)doc; |
219 |
NbDocument.CustomEditor ce = (NbDocument.CustomEditor)doc; |
Lines 486-500
Link Here
|
486 |
} |
503 |
} |
487 |
} |
504 |
} |
488 |
} |
505 |
} |
|
|
506 |
|
507 |
// Gather document persistent data |
508 |
Document doc = p.getDocument(); |
509 |
documentPersistentData = (doc != null) |
510 |
? doc.getProperty(PERSISTENT_DATA_DOCUMENT_PROPERTY) |
511 |
: null; |
489 |
} |
512 |
} |
490 |
|
513 |
|
491 |
out.writeObject(new Integer(pos)); |
514 |
out.writeObject(new Integer(pos)); |
|
|
515 |
|
516 |
out.writeObject(documentPersistentData); |
492 |
} |
517 |
} |
493 |
|
518 |
|
494 |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
519 |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
495 |
super.readExternal(in); |
520 |
super.readExternal(in); |
496 |
|
521 |
|
497 |
int offset; |
522 |
int offset; |
|
|
523 |
Object docPersistentData; |
498 |
|
524 |
|
499 |
Object firstObject = in.readObject (); |
525 |
Object firstObject = in.readObject (); |
500 |
|
526 |
|
Lines 540-550
Link Here
|
540 |
} |
566 |
} |
541 |
// load cursor position |
567 |
// load cursor position |
542 |
offset = ((Integer)in.readObject()).intValue(); |
568 |
offset = ((Integer)in.readObject()).intValue(); |
543 |
|
569 |
docPersistentData = in.readObject(); |
544 |
} |
570 |
} |
545 |
|
571 |
|
546 |
if (!discard ()) { |
572 |
if (!discard ()) { |
547 |
cursorPosition = offset; |
573 |
cursorPosition = offset; |
|
|
574 |
documentPersistentData = docPersistentData; |
548 |
} |
575 |
} |
549 |
|
576 |
|
550 |
updateName(); |
577 |
updateName(); |