/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A plain document that maintains no character attributes. The
* default element structure for this document is a map of the lines in
* the text. The Element returned by getDefaultRootElement is
* a map of the lines, and each child element represents a line.
* This model does not maintain any character level attributes,
* but each line can be tagged with an arbitrary set of attributes.
* Line to offset, and offset to line translations can be quickly
* performed using the default root element. The structure information
* of the DocumentEvent's fired by edits will indicate the line
* structure changes.
* <p>
* The default content storage management is performed by a
* gapped buffer implementation (GapContent). It supports
* editing reasonably large documents with good efficiency when
* the edits are contiguous or clustered, as is typical.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Timothy Prinzing
* @see Document
* @see AbstractDocument
*/
/**
* Name of the attribute that specifies the tab
* size for tabs contained in the content. The
* type for the value is Integer.
*/
/**
* Name of the attribute that specifies the maximum
* length of a line, if there is a maximum length.
* The type for the value is Integer.
*/
/**
* Constructs a plain text document. A default model using
* <code>GapContent</code> is constructed and set.
*/
public PlainDocument() {
this(new GapContent());
}
/**
* Constructs a plain text document. A default root element is created,
* and the tab size set to 8.
*
* @param c the container for the content
*/
super(c);
}
/**
* Inserts some content into the document.
* Inserting content causes a write lock to be held while the
* actual changes are taking place, followed by notification
* to the observers on the thread that grabbed the write lock.
* <p>
* This method is thread safe, although most Swing methods
* are not. Please see
* to Use Threads</A> for more information.
*
* @param offs the starting offset >= 0
* @param a the attributes for the inserted content
* @exception BadLocationException the given insert position is not a valid
* position within the document
* @see Document#insertString
*/
// fields don't want to have multiple lines. We may provide a field-specific
// model in the future in which case the filtering logic here will no longer
// be needed.
for (int i = 0; i < n; i++) {
}
}
}
}
}
/**
* Gets the default root element for the document model.
*
* @return the root
* @see Document#getDefaultRootElement
*/
return defaultRoot;
}
/**
* Creates the root element to be used to represent the
* default document structure.
*
* @return the element base
*/
return map;
}
/**
* Get the paragraph element containing the given position. Since this
* document only models lines, it returns the line instead.
*/
}
/**
* Updates document structure as a result of text insertion. This
* will happen within a write lock. Since this document simply
* maps out lines, we refresh the line map.
*
* @param chng the change event describing the dit
* @param attr the set of attributes for the inserted text
*/
if (offset > 0) {
offset -= 1;
length += 1;
}
int lastOffset = rmOffs0;
try {
if (s == null) {
s = new Segment();
}
boolean hasBreaks = false;
for (int i = 0; i < length; i++) {
if (c == '\n') {
hasBreaks = true;
}
}
if (hasBreaks) {
removed.addElement(e);
rmOffs1 = e.getEndOffset();
}
if (lastOffset < rmOffs1) {
}
}
}
} catch (BadLocationException e) {
}
}
/**
* Updates any document structure as a result of text removal.
* This will happen within a write lock. Since the structure
* represents a line map, this just checks to see if the
* removal spans lines. If it does, the two lines outside
* of the removal area are joined together.
*
* @param chng the change event describing the edit
*/
// a line was removed
}
} else {
//Check for the composed text element
}
}
}
super.removeUpdate(chng);
}
//
// Inserts the composed text of an input method. The line element
// where the composed text is inserted into becomes an branch element
// which contains leaf elements of the composed text and the text
// backing store.
//
}
private transient Segment s;
}