@@ -59,10 +59,37 @@ public class TextEditorPane extends RSyntaxTextArea implements
59
59
60
60
private static final long serialVersionUID = 1L ;
61
61
62
+ /**
63
+ * Property change event fired when the file path this text area references
64
+ * is updated.
65
+ *
66
+ * @see #load(FileLocation, String)
67
+ * @see #saveAs(FileLocation)
68
+ */
62
69
public static final String FULL_PATH_PROPERTY = "TextEditorPane.fileFullPath" ;
70
+
71
+ /**
72
+ * Property change event fired when the text area's dirty flag changes.
73
+ *
74
+ * @see #setDirty(boolean)
75
+ */
63
76
public static final String DIRTY_PROPERTY = "TextEditorPane.dirty" ;
77
+
78
+ /**
79
+ * Property change event fired when the text area should be treated as
80
+ * read-only, and previously it should not, or vice-versa.
81
+ *
82
+ * @see #setReadOnly(boolean)
83
+ */
64
84
public static final String READ_ONLY_PROPERTY = "TextEditorPane.readOnly" ;
65
85
86
+ /**
87
+ * Property change event fired when the text area's encoding changes.
88
+ *
89
+ * @see #setEncoding(String)
90
+ */
91
+ public static final String ENCODING_PROPERTY = "TextEditorPane.encoding" ;
92
+
66
93
/**
67
94
* The location of the file being edited.
68
95
*/
@@ -604,7 +631,8 @@ public void setDocument(Document doc) {
604
631
605
632
/**
606
633
* Sets the encoding to use when reading or writing this file. This
607
- * method sets the editor's dirty flag when the encoding is changed.
634
+ * method sets the editor's dirty flag when the encoding is changed, and
635
+ * fires a property change event of type {@link #ENCODING_PROPERTY}.
608
636
*
609
637
* @param encoding The new encoding.
610
638
* @throws UnsupportedCharsetException If the encoding is not supported.
@@ -620,7 +648,9 @@ else if (!Charset.isSupported(encoding)) {
620
648
throw new UnsupportedCharsetException (encoding );
621
649
}
622
650
if (charSet ==null || !charSet .equals (encoding )) {
651
+ String oldEncoding = charSet ;
623
652
charSet = encoding ;
653
+ firePropertyChange (ENCODING_PROPERTY , oldEncoding , charSet );
624
654
setDirty (true );
625
655
}
626
656
}
0 commit comments