You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2006/11/07 14:50:07 UTC
svn commit: r472115 -
/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java
Author: apetrenko
Date: Tue Nov 7 05:50:07 2006
New Revision: 472115
URL: http://svn.apache.org/viewvc?view=rev&rev=472115
Log:
Patch for HARMONY-1809 "[classlib][swing]javax.swing.text.GapContent.replace(int, int, java.lang.Object, int) throws unspescified BadLocationException"
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java?view=diff&rev=472115&r1=472114&r2=472115
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/GapContent.java Tue Nov 7 05:50:07 2006
@@ -26,12 +26,15 @@
import java.io.Serializable;
import java.util.Vector;
+import javax.swing.text.ContentPositions.DocumentMark;
import javax.swing.undo.UndoableEdit;
+@SuppressWarnings("serial")
public class GapContent
implements AbstractDocument.Content, Serializable {
- private final class GapContentEdit extends AbstractContentUndoableEdit implements UndoableEdit {
+ private final class GapContentEdit extends AbstractContentUndoableEdit
+ implements UndoableEdit {
public GapContentEdit(final int where, final String chars,
final boolean isInsertCommand)
@@ -40,6 +43,7 @@
super(where, chars, isInsertCommand);
}
+ @Override
protected Vector getPositionsInRange(final Vector positions,
final int where,
final int length) {
@@ -47,11 +51,13 @@
length);
}
+ @Override
protected void updateUndoPositions(final Vector undoPos) {
GapContent.this.updateUndoPositions(undoPos, pos, len);
}
+ @Override
protected void insertItems(final int where, final String chars) {
try {
GapContent.this.insertItems(where, chars.toCharArray(), len);
@@ -59,6 +65,7 @@
}
+ @Override
protected void removeItems(final int where, final int length) {
try {
GapContent.this.removeItems(where, length);
@@ -66,7 +73,7 @@
}
}
- private class GapContentPositions extends ContentPositions {
+ private final class GapContentPositions extends ContentPositions {
/**
* Resets internal index in Position implementation to be zero if
* the position offset is zero. This ensures that position isn't moved
@@ -76,6 +83,7 @@
GapContent.this.resetMarksAtZero();
}
+ @Override
protected int setOffsetForDocumentMark(final int offset) {
if (offset == 0 || offset < gapStart) {
return offset;
@@ -83,6 +91,7 @@
return offset + (gapEnd - gapStart);
}
+ @Override
protected int getOffsetForDocumentMark(final int index) {
if (index == 0 || index < gapStart) {
return index;
@@ -203,7 +212,7 @@
return new char[len];
}
- protected Object getArray() {
+ protected final Object getArray() {
return array;
}
@@ -214,14 +223,14 @@
/**
* Returns the index of the first character right after the gap.
*/
- protected int getGapEnd() {
+ protected final int getGapEnd() {
return gapEnd;
}
/**
* Returns the index of the first character in the gap.
*/
- protected int getGapStart() {
+ protected final int getGapStart() {
return gapStart;
}
@@ -237,11 +246,12 @@
}
protected void replace(final int position, final int rmSize,
- final Object addItems, final int addSize)
- throws BadLocationException {
-
- removeItems(position, rmSize);
- insertItems(position, addItems, addSize);
+ final Object addItems, final int addSize) {
+ try {
+ removeItems(position, rmSize);
+ insertItems(position, addItems, addSize);
+ } catch (BadLocationException e) {
+ }
}
protected void resetMarksAtZero() {
@@ -252,9 +262,8 @@
}
for (int i = 0; i < gapContentPositions.positionList.size(); i++) {
- ContentPositions.DocumentMark dm =
- (ContentPositions.DocumentMark)gapContentPositions.positionList
- .get(i);
+ DocumentMark dm =
+ (DocumentMark)gapContentPositions.positionList.get(i);
if (dm.index <= gapEnd) {
dm.index = 0;