jdk/src/java.desktop/share/classes/javax/swing/text/GapContent.java
changeset 28976 8c912c147654
parent 26037 508779ce6619
child 30462 507bcb03c954
equal deleted inserted replaced
28975:a492b5c5dc53 28976:8c912c147654
   708      * @param v the Vector to use, with a new one created on null
   708      * @param v the Vector to use, with a new one created on null
   709      * @param offset the starting offset >= 0
   709      * @param offset the starting offset >= 0
   710      * @param length the length >= 0
   710      * @param length the length >= 0
   711      * @return the set of instances
   711      * @return the set of instances
   712      */
   712      */
   713     protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v,
   713     @SuppressWarnings({"rawtypes", "unchecked"}) // UndoPosRef type cannot be exposed
   714                                                      int offset, int length) {
   714     protected Vector getPositionsInRange(Vector v,
       
   715                                          int offset, int length) {
   715         int endOffset = offset + length;
   716         int endOffset = offset + length;
   716         int startIndex;
   717         int startIndex;
   717         int endIndex;
   718         int endIndex;
   718         int g0 = getGapStart();
   719         int g0 = getGapStart();
   719         int g1 = getGapEnd();
   720         int g1 = getGapEnd();
   756      * This is meant for internal usage, and is generally not of interest
   757      * This is meant for internal usage, and is generally not of interest
   757      * to subclasses.
   758      * to subclasses.
   758      *
   759      *
   759      * @param positions the UndoPosRef instances to reset
   760      * @param positions the UndoPosRef instances to reset
   760      */
   761      */
   761     protected void updateUndoPositions(Vector<UndoPosRef> positions, int offset,
   762     @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
       
   763     protected void updateUndoPositions(Vector positions, int offset,
   762                                        int length) {
   764                                        int length) {
   763         // Find the indexs of the end points.
   765         // Find the indexs of the end points.
   764         int endOffset = offset + length;
   766         int endOffset = offset + length;
   765         int g1 = getGapEnd();
   767         int g1 = getGapEnd();
   766         int startIndex;
   768         int startIndex;
   773             startIndex = 0;
   775             startIndex = 0;
   774         }
   776         }
   775 
   777 
   776         // Reset the location of the refenences.
   778         // Reset the location of the refenences.
   777         for(int counter = positions.size() - 1; counter >= 0; counter--) {
   779         for(int counter = positions.size() - 1; counter >= 0; counter--) {
   778             UndoPosRef ref = positions.elementAt(counter);
   780             UndoPosRef ref = (UndoPosRef) positions.elementAt(counter);
   779             ref.resetLocation(endOffset, g1);
   781             ref.resetLocation(endOffset, g1);
   780         }
   782         }
   781         // We have to resort the marks in the range startIndex to endIndex.
   783         // We have to resort the marks in the range startIndex to endIndex.
   782         // We can take advantage of the fact that it will be in
   784         // We can take advantage of the fact that it will be in
   783         // increasing order, accept there will be a bunch of MarkData's with
   785         // increasing order, accept there will be a bunch of MarkData's with
   900         /** The string that was inserted. This will only be valid after an
   902         /** The string that was inserted. This will only be valid after an
   901          * undo. */
   903          * undo. */
   902         protected String string;
   904         protected String string;
   903         /** An array of instances of UndoPosRef for the Positions in the
   905         /** An array of instances of UndoPosRef for the Positions in the
   904          * range that was removed, valid after undo. */
   906          * range that was removed, valid after undo. */
   905         protected Vector<UndoPosRef> posRefs;
   907         @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
       
   908         protected Vector posRefs;
   906     } // GapContent.InsertUndo
   909     } // GapContent.InsertUndo
   907 
   910 
   908 
   911 
   909     /**
   912     /**
   910      * UndoableEdit created for removes.
   913      * UndoableEdit created for removes.
   911      */
   914      */
   912     @SuppressWarnings("serial") // JDK-implementation class
   915     @SuppressWarnings("serial") // JDK-implementation class
   913     class RemoveUndo extends AbstractUndoableEdit {
   916     class RemoveUndo extends AbstractUndoableEdit {
       
   917         @SuppressWarnings("unchecked")
   914         protected RemoveUndo(int offset, String string) {
   918         protected RemoveUndo(int offset, String string) {
   915             super();
   919             super();
   916             this.offset = offset;
   920             this.offset = offset;
   917             this.string = string;
   921             this.string = string;
   918             this.length = string.length();
   922             this.length = string.length();
   932             } catch (BadLocationException bl) {
   936             } catch (BadLocationException bl) {
   933               throw new CannotUndoException();
   937               throw new CannotUndoException();
   934             }
   938             }
   935         }
   939         }
   936 
   940 
       
   941         @SuppressWarnings("unchecked")
   937         public void redo() throws CannotRedoException {
   942         public void redo() throws CannotRedoException {
   938             super.redo();
   943             super.redo();
   939             try {
   944             try {
   940                 string = getString(offset, length);
   945                 string = getString(offset, length);
   941                 // Get the Positions in the range being removed.
   946                 // Get the Positions in the range being removed.