jdk/src/share/classes/javax/swing/event/DocumentEvent.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 23010 6dadb192ad81
permissions -rw-r--r--
8041917: unexcepted behavior of LineBorder while using Boolean variable true Reviewed-by: alexsch, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21278
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.swing.undo.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Interface for document change notifications.  This provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * detailed information to Document observers about how the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Document changed.  It provides high level information such
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * as type of change and where it occurred, as well as the more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * detailed structural changes (What Elements were inserted and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * removed).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @see javax.swing.text.Document
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @see DocumentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public interface DocumentEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * Returns the offset within the document of the start
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * of the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
    48
     * @return the offset >= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public int getOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Returns the length of the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
    55
     * @return the length >= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public int getLength();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * Gets the document that sourced the change event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @return the document
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public Document getDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Gets the type of event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @return the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public EventType getType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Gets the change information for the given element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * The change information describes what elements were
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * added and removed and the location.  If there were
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * no changes, null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * This method is for observers to discover the structural
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * changes that were made.  This means that only elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * that existed prior to the mutation (and still exist after
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20428
diff changeset
    82
     * the mutation) need to have ElementChange records.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * The changes made available need not be recursive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * For example, if the an element is removed from it's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * parent, this method should report that the parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * changed and provide an ElementChange implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * that describes the change to the parent.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * child element removed had children, these elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * do not need to be reported as removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * If an child element is insert into a parent element,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * the parent element should report a change.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * child element also had elements inserted into it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * (grandchildren to the parent) these elements need
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * not report change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param elem the element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @return the change information, or null if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *   element was not modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public ElementChange getChange(Element elem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Enumeration for document event types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public static final class EventType {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        private EventType(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            typeString = s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
         * Insert type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        public static final EventType INSERT = new EventType("INSERT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
         * Remove type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        public static final EventType REMOVE = new EventType("REMOVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
         * Change type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        public static final EventType CHANGE = new EventType("CHANGE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
         * Converts the type to a string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
         * @return the string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            return typeString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        private String typeString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Describes changes made to a specific element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public interface ElementChange {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
         * Returns the element represented.  This is the element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
         * that was changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
         * @return the element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        public Element getElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
         * Fetches the index within the element represented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
         * This is the location that children were added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
         * and/or removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
         *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   158
         * @return the index &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        public int getIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
         * Gets the child elements that were removed from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
         * given parent element.  The element array returned is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
         * sorted in the order that the elements used to lie in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
         * the document, and must be contiguous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
         * @return the child elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        public Element[] getChildrenRemoved();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
         * Gets the child elements that were added to the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
         * parent element.  The element array returned is in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
         * order that the elements lie in the document, and must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
         * be contiguous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
         * @return the child elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        public Element[] getChildrenAdded();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
}