< prev index next >

src/java.desktop/share/classes/javax/swing/text/Document.java

Print this page

        

*** 26,36 **** import javax.swing.event.*; /** * <p> ! * The <code>Document</code> is a container for text that serves * as the model for swing text components. The goal for this * interface is to scale from very simple needs (a plain text textfield) * to complex needs (an HTML or XML document, for example). * * <p><b>Content</b> --- 26,36 ---- import javax.swing.event.*; /** * <p> ! * The {@code Document} is a container for text that serves * as the model for swing text components. The goal for this * interface is to scale from very simple needs (a plain text textfield) * to complex needs (an HTML or XML document, for example). * * <p><b>Content</b>
*** 98,128 **** * <li>{@link #createPosition(int)} * </ul> * * <p><b>Notification</b> * <p> ! * Mutations to the <code>Document</code> must be communicated to * interested observers. The notification of change follows the event model * guidelines that are specified for JavaBeans. In the JavaBeans * event model, once an event notification is dispatched, all listeners * must be notified before any further mutations occur to the source * of the event. Further, order of delivery is not guaranteed. * <p> * Notification is provided as two separate events, * <a href="../event/DocumentEvent.html">DocumentEvent</a>, and * <a href="../event/UndoableEditEvent.html">UndoableEditEvent</a>. ! * If a mutation is made to a <code>Document</code> through its api, ! * a <code>DocumentEvent</code> will be sent to all of the registered ! * <code>DocumentListeners</code>. If the <code>Document</code> * implementation supports undo/redo capabilities, an ! * <code>UndoableEditEvent</code> will be sent ! * to all of the registered <code>UndoableEditListener</code>s. ! * If an undoable edit is undone, a <code>DocumentEvent</code> should be * fired from the Document to indicate it has changed again. ! * In this case however, there should be no <code>UndoableEditEvent</code> * generated since that edit is actually the source of the change ! * rather than a mutation to the <code>Document</code> made through its * api. * <p style="text-align:center"><img src="doc-files/Document-notification.gif" * alt="The preceding text describes this graphic."> * <p> * Referring to the above diagram, suppose that the component shown --- 98,128 ---- * <li>{@link #createPosition(int)} * </ul> * * <p><b>Notification</b> * <p> ! * Mutations to the {@code Document} must be communicated to * interested observers. The notification of change follows the event model * guidelines that are specified for JavaBeans. In the JavaBeans * event model, once an event notification is dispatched, all listeners * must be notified before any further mutations occur to the source * of the event. Further, order of delivery is not guaranteed. * <p> * Notification is provided as two separate events, * <a href="../event/DocumentEvent.html">DocumentEvent</a>, and * <a href="../event/UndoableEditEvent.html">UndoableEditEvent</a>. ! * If a mutation is made to a {@code Document} through its api, ! * a {@code DocumentEvent} will be sent to all of the registered ! * {@code DocumentListeners}. If the {@code Document} * implementation supports undo/redo capabilities, an ! * {@code UndoableEditEvent} will be sent ! * to all of the registered {@code UndoableEditListener}s. ! * If an undoable edit is undone, a {@code DocumentEvent} should be * fired from the Document to indicate it has changed again. ! * In this case however, there should be no {@code UndoableEditEvent} * generated since that edit is actually the source of the change ! * rather than a mutation to the {@code Document} made through its * api. * <p style="text-align:center"><img src="doc-files/Document-notification.gif" * alt="The preceding text describes this graphic."> * <p> * Referring to the above diagram, suppose that the component shown
*** 155,173 **** * <p><b>Properties</b> * <p> * Document implementations will generally have some set of properties * associated with them at runtime. Two well known properties are the * <a href="#StreamDescriptionProperty">StreamDescriptionProperty</a>, ! * which can be used to describe where the <code>Document</code> came from, * and the <a href="#TitleProperty">TitleProperty</a>, which can be used to ! * name the <code>Document</code>. The methods related to the properties are: * <ul> * <li>{@link #getProperty(java.lang.Object)} * <li>{@link #putProperty(java.lang.Object, java.lang.Object)} * </ul> * ! * <p>For more information on the <code>Document</code> class, see * <a href="http://java.sun.com/products/jfc/tsc">The Swing Connection</a> * and most particularly the article, * <a href="http://java.sun.com/products/jfc/tsc/articles/text/element_interface"> * The Element Interface</a>. * --- 155,173 ---- * <p><b>Properties</b> * <p> * Document implementations will generally have some set of properties * associated with them at runtime. Two well known properties are the * <a href="#StreamDescriptionProperty">StreamDescriptionProperty</a>, ! * which can be used to describe where the {@code Document} came from, * and the <a href="#TitleProperty">TitleProperty</a>, which can be used to ! * name the {@code Document}. The methods related to the properties are: * <ul> * <li>{@link #getProperty(java.lang.Object)} * <li>{@link #putProperty(java.lang.Object, java.lang.Object)} * </ul> * ! * <p>For more information on the {@code Document} class, see * <a href="http://java.sun.com/products/jfc/tsc">The Swing Connection</a> * and most particularly the article, * <a href="http://java.sun.com/products/jfc/tsc/articles/text/element_interface"> * The Element Interface</a>. *
*** 228,251 **** public void removeUndoableEditListener(UndoableEditListener listener); /** * Gets the properties associated with the document. * ! * @param key a non-<code>null</code> property key * @return the properties * @see #putProperty(Object, Object) */ public Object getProperty(Object key); /** * Associates a property with the document. Two standard * property keys provided are: <a href="#StreamDescriptionProperty"> ! * <code>StreamDescriptionProperty</code></a> and ! * <a href="#TitleProperty"><code>TitleProperty</code></a>. * Other properties, such as author, may also be defined. * ! * @param key the non-<code>null</code> property key * @param value the property value * @see #getProperty(Object) */ public void putProperty(Object key, Object value); --- 228,251 ---- public void removeUndoableEditListener(UndoableEditListener listener); /** * Gets the properties associated with the document. * ! * @param key a non-{@code null} property key * @return the properties * @see #putProperty(Object, Object) */ public Object getProperty(Object key); /** * Associates a property with the document. Two standard * property keys provided are: <a href="#StreamDescriptionProperty"> ! * {@code StreamDescriptionProperty}</a> and ! * <a href="#TitleProperty">{@code TitleProperty}</a>. * Other properties, such as author, may also be defined. * ! * @param key the non-{@code null} property key * @param value the property value * @see #getProperty(Object) */ public void putProperty(Object key, Object value);
*** 261,271 **** * To ensure reasonable behavior in the face * of concurrency, the event is dispatched after the * mutation has occurred. This means that by the time a * notification of removal is dispatched, the document * has already been updated and any marks created by ! * <code>createPosition</code> have already changed. * For a removal, the end of the removal range is collapsed * down to the start of the range, and any marks in the removal * range are collapsed down to the start of the range. * <p style="text-align:center"><img src="doc-files/Document-remove.gif" * alt="Diagram shows removal of 'quick' from 'The quick brown fox.'"> --- 261,271 ---- * To ensure reasonable behavior in the face * of concurrency, the event is dispatched after the * mutation has occurred. This means that by the time a * notification of removal is dispatched, the document * has already been updated and any marks created by ! * {@code createPosition} have already changed. * For a removal, the end of the removal range is collapsed * down to the start of the range, and any marks in the removal * range are collapsed down to the start of the range. * <p style="text-align:center"><img src="doc-files/Document-remove.gif" * alt="Diagram shows removal of 'quick' from 'The quick brown fox.'">
*** 452,462 **** * The given runnable will be executed in a way that allows it * to safely read the model with no changes while the runnable * is being executed. The runnable itself may <em>not</em> * make any mutations. * ! * @param r a <code>Runnable</code> used to render the model */ public void render(Runnable r); /** * The property name for the description of the stream --- 452,462 ---- * The given runnable will be executed in a way that allows it * to safely read the model with no changes while the runnable * is being executed. The runnable itself may <em>not</em> * make any mutations. * ! * @param r a {@code Runnable} used to render the model */ public void render(Runnable r); /** * The property name for the description of the stream
< prev index next >