equal
deleted
inserted
replaced
42 * implementation which treats text as styled text and |
42 * implementation which treats text as styled text and |
43 * provides a minimal set of actions for editing styled text. |
43 * provides a minimal set of actions for editing styled text. |
44 * |
44 * |
45 * @author Timothy Prinzing |
45 * @author Timothy Prinzing |
46 */ |
46 */ |
|
47 @SuppressWarnings("serial") // Same-version serialization only |
47 public class StyledEditorKit extends DefaultEditorKit { |
48 public class StyledEditorKit extends DefaultEditorKit { |
48 |
49 |
49 /** |
50 /** |
50 * Creates a new EditorKit used for styled documents. |
51 * Creates a new EditorKit used for styled documents. |
51 */ |
52 */ |
168 } |
169 } |
169 |
170 |
170 /** |
171 /** |
171 * Creates the AttributeSet used for the selection. |
172 * Creates the AttributeSet used for the selection. |
172 */ |
173 */ |
|
174 @SuppressWarnings("serial") // anonymous class |
173 private void createInputAttributes() { |
175 private void createInputAttributes() { |
174 inputAttributes = new SimpleAttributeSet() { |
176 inputAttributes = new SimpleAttributeSet() { |
175 public AttributeSet getResolveParent() { |
177 public AttributeSet getResolveParent() { |
176 return (currentParagraph != null) ? |
178 return (currentParagraph != null) ? |
177 currentParagraph.getAttributes() : null; |
179 currentParagraph.getAttributes() : null; |
216 * caret position. |
218 * caret position. |
217 * <p>This implements PropertyChangeListener to update the |
219 * <p>This implements PropertyChangeListener to update the |
218 * input attributes when the Document changes, as if the Document |
220 * input attributes when the Document changes, as if the Document |
219 * changes the attributes will almost certainly change. |
221 * changes the attributes will almost certainly change. |
220 */ |
222 */ |
|
223 @SuppressWarnings("serial") // JDK-implementation class |
221 class AttributeTracker implements CaretListener, PropertyChangeListener, Serializable { |
224 class AttributeTracker implements CaretListener, PropertyChangeListener, Serializable { |
222 |
225 |
223 /** |
226 /** |
224 * Updates the attributes. <code>dot</code> and <code>mark</code> |
227 * Updates the attributes. <code>dot</code> and <code>mark</code> |
225 * mark give the positions of the selection in <code>c</code>. |
228 * mark give the positions of the selection in <code>c</code>. |
852 * <code>DefaultEditorKit.InsertBreakAction</code>. That is when |
855 * <code>DefaultEditorKit.InsertBreakAction</code>. That is when |
853 * its <code>actionPerformed</code> method is invoked, a newline |
856 * its <code>actionPerformed</code> method is invoked, a newline |
854 * is inserted. Beyond that, this will reset the input attributes to |
857 * is inserted. Beyond that, this will reset the input attributes to |
855 * what they were before the newline was inserted. |
858 * what they were before the newline was inserted. |
856 */ |
859 */ |
|
860 @SuppressWarnings("serial") // Superclass is not serializable across versions |
857 static class StyledInsertBreakAction extends StyledTextAction { |
861 static class StyledInsertBreakAction extends StyledTextAction { |
858 private SimpleAttributeSet tempSet; |
862 private SimpleAttributeSet tempSet; |
859 |
863 |
860 StyledInsertBreakAction() { |
864 StyledInsertBreakAction() { |
861 super(insertBreakAction); |
865 super(insertBreakAction); |