Removes deprecated unsafe Tree/TreeItem methods.
Change-Id: I04f98d0623d01aeda8e21a91b47ba356d8e939d1
Review-Link: https://gwt-review.googlesource.com/#/c/4761/
diff --git a/tools/api-checker/config/gwt25_26userApi.conf b/tools/api-checker/config/gwt25_26userApi.conf
index a95d12e..7c6119f 100644
--- a/tools/api-checker/config/gwt25_26userApi.conf
+++ b/tools/api-checker/config/gwt25_26userApi.conf
@@ -188,3 +188,10 @@
# Fix API compatibility for StringBuilder
java.lang.StringBuilder::append(Ljava/lang/StringBuilder;) OVERRIDABLE_METHOD_ARGUMENT_TYPE_CHANGE
+
+# Removed long deprecated unsecure Tree/TreeItem methods
+com.google.gwt.user.client.ui.Tree::addItem(Ljava/lang/String;) MISSING
+com.google.gwt.user.client.ui.Tree::insertItem(ILjava/lang/String;) MISSING
+com.google.gwt.user.client.ui.TreeItem::TreeItem(Ljava/lang/String;) MISSING
+com.google.gwt.user.client.ui.TreeItem::addItem(Ljava/lang/String;) MISSING
+com.google.gwt.user.client.ui.TreeItem::insertItem(ILjava/lang/String;) MISSING
diff --git a/user/src/com/google/gwt/user/client/ui/Tree.java b/user/src/com/google/gwt/user/client/ui/Tree.java
index 2649b4f..724cf3f 100644
--- a/user/src/com/google/gwt/user/client/ui/Tree.java
+++ b/user/src/com/google/gwt/user/client/ui/Tree.java
@@ -298,18 +298,6 @@
/**
* Adds a simple tree item containing the specified html.
*
- * @param itemHtml the text of the item to be added
- * @return the item that was added
- * @deprecated use {@link #addItem(SafeHtml)} instead
- */
- @Deprecated
- public TreeItem addItem(String itemHtml) {
- return root.addItem(itemHtml);
- }
-
- /**
- * Adds a simple tree item containing the specified html.
- *
* @param itemHtml the html of the item to be added
* @return the item that was added
*/
@@ -522,21 +510,6 @@
* html.
*
* @param beforeIndex the index where the item will be inserted
- * @param itemHtml the html to be added
- * @return the item that was added
- * @throws IndexOutOfBoundsException if the index is out of range
- * @deprecated use {@link #insertItem(int, SafeHtml)} instead
- */
- @Deprecated
- public TreeItem insertItem(int beforeIndex, String itemHtml) {
- return root.insertItem(beforeIndex, itemHtml);
- }
-
- /**
- * Inserts a child tree item at the specified index containing the specified
- * html.
- *
- * @param beforeIndex the index where the item will be inserted
* @param itemHtml the html of the item to be added
* @return the item that was added
* @throws IndexOutOfBoundsException if the index is out of range
diff --git a/user/src/com/google/gwt/user/client/ui/TreeItem.java b/user/src/com/google/gwt/user/client/ui/TreeItem.java
index d65a2f2..949967b 100644
--- a/user/src/com/google/gwt/user/client/ui/TreeItem.java
+++ b/user/src/com/google/gwt/user/client/ui/TreeItem.java
@@ -289,21 +289,10 @@
* Constructs a tree item with the given HTML.
*
* @param html the item's HTML
- * @deprecated use {@link #TreeItem(SafeHtml)} instead
- */
- @Deprecated
- public TreeItem(String html) {
- this();
- setHTML(html);
- }
-
- /**
- * Constructs a tree item with the given HTML.
- *
- * @param html the item's HTML
*/
public TreeItem(SafeHtml html) {
- this(html.asString());
+ this();
+ setHTML(html);
}
/**
@@ -337,20 +326,6 @@
/**
* Adds a child tree item containing the specified html.
*
- * @param itemHtml the text to be added
- * @return the item that was added
- * @deprecated use {@link #addItem(SafeHtml)} instead
- */
- @Deprecated
- public TreeItem addItem(String itemHtml) {
- TreeItem ret = new TreeItem(itemHtml);
- addItem(ret);
- return ret;
- }
-
- /**
- * Adds a child tree item containing the specified html.
- *
* @param itemHtml the item's HTML
* @return the item that was added
*/
@@ -519,24 +494,6 @@
* html.
*
* @param beforeIndex the index where the item will be inserted
- * @param itemHtml the html that the item will contain
- * @return the item that was added
- * @throws IndexOutOfBoundsException if the index is out of range
- * @deprecated use {@link #insertItem(int, SafeHtml)} instead
- */
- @Deprecated
- public TreeItem insertItem(int beforeIndex, String itemHtml)
- throws IndexOutOfBoundsException {
- TreeItem ret = new TreeItem(itemHtml);
- insertItem(beforeIndex, ret);
- return ret;
- }
-
- /**
- * Inserts a child tree item at the specified index containing the specified
- * html.
- *
- * @param beforeIndex the index where the item will be inserted
* @param itemHtml the item's HTML
* @return the item that was added
* @throws IndexOutOfBoundsException if the index is out of range
diff --git a/user/test/com/google/gwt/user/client/ui/TreeItemTest.java b/user/test/com/google/gwt/user/client/ui/TreeItemTest.java
index 2d724de..aa2be8d 100644
--- a/user/test/com/google/gwt/user/client/ui/TreeItemTest.java
+++ b/user/test/com/google/gwt/user/client/ui/TreeItemTest.java
@@ -34,13 +34,13 @@
TreeItem item = new TreeItem();
// Add the only child back to its parent.
- TreeItem a = item.addItem("a");
+ TreeItem a = item.addItem(SafeHtmlUtils.fromSafeConstant("a"));
item.addItem(a);
assertEquals(1, item.getChildCount());
assertEquals(a, item.getChild(0));
// Add a child back to its parent that has multiple children.
- TreeItem b = item.addItem("b");
+ TreeItem b = item.addItem(SafeHtmlUtils.fromSafeConstant("b"));
item.addItem(a);
assertEquals(2, item.getChildCount());
assertEquals(b, item.getChild(0));
@@ -51,15 +51,15 @@
* Test for {@link TreeItem#addItem(IsTreeItem)}.
*/
public void testAddItemIsTreeItem() {
- TreeItem root = new TreeItem("foo");
- TreeItem item = new TreeItem("hello");
+ TreeItem root = new TreeItem(SafeHtmlUtils.fromSafeConstant("foo"));
+ TreeItem item = new TreeItem(SafeHtmlUtils.fromSafeConstant("hello"));
root.addItem((IsTreeItem) item);
assertEquals(1, root.getChildCount());
assertSame(item, root.getChild(0));
}
public void testAddItemSafeHtml() {
- TreeItem item = new TreeItem("foo");
+ TreeItem item = new TreeItem(SafeHtmlUtils.fromSafeConstant("foo"));
TreeItem child = item.addItem(SafeHtmlUtils.fromSafeConstant(HTML));
assertEquals(HTML, child.getHTML().toLowerCase());
}
@@ -68,7 +68,7 @@
* Test for {@link Tree#addTextItem(String)}.
*/
public void testAddTextItem() {
- TreeItem root = new TreeItem("foo");
+ TreeItem root = new TreeItem(SafeHtmlUtils.fromSafeConstant("foo"));
String text = "Some<br>text";
TreeItem item = root.addTextItem(text);
assertEquals(text, item.getText());
@@ -78,18 +78,19 @@
}
public void testAsTreeItem() {
- TreeItem item = new TreeItem("foo");
+ TreeItem item = new TreeItem(SafeHtmlUtils.fromSafeConstant("foo"));
assertSame(item, item.asTreeItem());
}
public void testInsert() {
TreeItem item = new TreeItem();
- TreeItem b = item.addItem("b");
+ TreeItem b = item.addItem(SafeHtmlUtils.fromSafeConstant("b"));
assertEquals(1, item.getChildCount());
assertEquals(b, item.getChild(0));
// Insert at zero.
- TreeItem a = item.insertItem(0, "a");
+ TreeItem a = item.insertItem(0, SafeHtmlUtils.fromSafeConstant("a"));
+ assertEquals("a", a.getHTML().toLowerCase());
assertEquals(2, item.getChildCount());
assertEquals(a, item.getChild(0));
assertEquals(b, item.getChild(1));
@@ -104,7 +105,7 @@
assertEquals(b.getElement().getNextSiblingElement(), d.getElement());
// Insert in the middle.
- TreeItem c = new TreeItem("c");
+ TreeItem c = new TreeItem(SafeHtmlUtils.fromSafeConstant("c"));
item.insertItem(2, c);
assertEquals(4, item.getChildCount());
assertEquals(a, item.getChild(0));
@@ -119,9 +120,9 @@
*/
public void testInsertIntoSameItem() {
TreeItem item = new TreeItem();
- TreeItem a = item.addItem("a");
- item.addItem("b");
- item.addItem("c");
+ TreeItem a = item.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ item.addItem(SafeHtmlUtils.fromSafeConstant("b"));
+ item.addItem(SafeHtmlUtils.fromSafeConstant("c"));
// Reinsert at the end.
item.insertItem(2, a);
@@ -138,13 +139,13 @@
public void testInsertInvalidIndex() {
TreeItem item = new TreeItem();
- item.addItem("a");
- item.addItem("b");
- item.addItem("c");
+ item.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ item.addItem(SafeHtmlUtils.fromSafeConstant("b"));
+ item.addItem(SafeHtmlUtils.fromSafeConstant("c"));
// Insert at -1.
try {
- item.insertItem(-1, "illegal");
+ item.insertItem(-1, SafeHtmlUtils.fromSafeConstant("illegal"));
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// Expected.
@@ -152,21 +153,15 @@
// Insert past the end.
try {
- item.insertItem(4, "illegal");
+ item.insertItem(4, SafeHtmlUtils.fromSafeConstant("illegal"));
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
}
- public void testInsertItemSafeHtml() {
- TreeItem item = new TreeItem("foo");
- TreeItem child = item.insertItem(0, SafeHtmlUtils.fromSafeConstant(HTML));
- assertEquals(HTML, child.getHTML().toLowerCase());
- }
-
public void testInsertTextItem() {
- TreeItem root = new TreeItem("foo");
+ TreeItem root = new TreeItem(SafeHtmlUtils.fromSafeConstant("foo"));
String text = "Some<br>text";
TreeItem item = root.insertTextItem(0, text);
assertEquals(text, item.getText());
@@ -179,9 +174,9 @@
* Test for {@link TreeItem#removeItem(IsTreeItem)}.
*/
public void testRemoveIsTreeItem() {
- TreeItem root = new TreeItem("root");
- TreeItem itemA = root.addItem("a");
- TreeItem itemB = root.addItem("b");
+ TreeItem root = new TreeItem(SafeHtmlUtils.fromSafeConstant("root"));
+ TreeItem itemA = root.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem itemB = root.addItem(SafeHtmlUtils.fromSafeConstant("b"));
// initial state
assertEquals(2, root.getChildCount());
assertSame(itemA, root.getChild(0));
@@ -198,9 +193,9 @@
* Test for {@link TreeItem#removeItems()}.
*/
public void testRemoveItems() {
- TreeItem root = new TreeItem("root");
- TreeItem itemA = root.addItem("a");
- TreeItem itemB = root.addItem("b");
+ TreeItem root = new TreeItem(SafeHtmlUtils.fromSafeConstant("root"));
+ TreeItem itemA = root.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem itemB = root.addItem(SafeHtmlUtils.fromSafeConstant("b"));
// initial state
assertEquals(2, root.getChildCount());
assertSame(itemA, root.getChild(0));
@@ -217,7 +212,7 @@
}
public void testSetSafeHtml() {
- TreeItem item = new TreeItem("foo");
+ TreeItem item = new TreeItem(SafeHtmlUtils.fromSafeConstant("foo"));
item.setHTML(SafeHtmlUtils.fromSafeConstant(HTML));
assertEquals(HTML, item.getHTML().toLowerCase());
}
diff --git a/user/test/com/google/gwt/user/client/ui/TreeTest.java b/user/test/com/google/gwt/user/client/ui/TreeTest.java
index dfcda3a..8d170e6 100644
--- a/user/test/com/google/gwt/user/client/ui/TreeTest.java
+++ b/user/test/com/google/gwt/user/client/ui/TreeTest.java
@@ -76,7 +76,7 @@
*/
public void testAddItemIsTreeItem() {
Tree t = createTree();
- TreeItem item = new TreeItem("hello");
+ TreeItem item = new TreeItem(SafeHtmlUtils.fromSafeConstant("hello"));
t.addItem((IsTreeItem) item);
assertEquals(1, t.getItemCount());
assertSame(item, t.getItem(0));
@@ -109,9 +109,9 @@
Tree t = createTree();
// Adding widget to end of tree, widgets still have their parents set
// correctly.
- TreeItem a = new TreeItem("a");
- TreeItem b = new TreeItem("b");
- TreeItem c = new TreeItem("c");
+ TreeItem a = new TreeItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem b = new TreeItem(SafeHtmlUtils.fromSafeConstant("b"));
+ TreeItem c = new TreeItem(SafeHtmlUtils.fromSafeConstant("c"));
TreeItem d = new TreeItem();
TreeItem e = new TreeItem();
Label dLabel = new Label("d");
@@ -122,7 +122,7 @@
b.addItem(c);
a.addItem(b);
t.addItem(a);
- t.addItem("hello");
+ t.addItem(SafeHtmlUtils.fromSafeConstant("hello"));
t.addItem(eLabel);
t.clear();
assertFalse(t.treeItemIterator().hasNext());
@@ -131,13 +131,13 @@
public void testDebugId() {
Tree tree = createTree();
- TreeItem top0 = tree.addItem("top0");
- TreeItem top1 = tree.addItem("top1");
- TreeItem top2 = tree.addItem("top2");
- TreeItem top3 = tree.addItem("top3");
- TreeItem bottom0 = top3.addItem("bottom0");
- TreeItem bottom1 = top3.addItem("bottom1");
- TreeItem bottom2 = top3.addItem("bottom2");
+ TreeItem top0 = tree.addItem(SafeHtmlUtils.fromSafeConstant("top0"));
+ TreeItem top1 = tree.addItem(SafeHtmlUtils.fromSafeConstant("top1"));
+ TreeItem top2 = tree.addItem(SafeHtmlUtils.fromSafeConstant("top2"));
+ TreeItem top3 = tree.addItem(SafeHtmlUtils.fromSafeConstant("top3"));
+ TreeItem bottom0 = top3.addItem(SafeHtmlUtils.fromSafeConstant("bottom0"));
+ TreeItem bottom1 = top3.addItem(SafeHtmlUtils.fromSafeConstant("bottom1"));
+ TreeItem bottom2 = top3.addItem(SafeHtmlUtils.fromSafeConstant("bottom2"));
// Check tree items deep
tree.ensureDebugId("myTree");
@@ -195,9 +195,9 @@
Tree tree = createTree();
Iterator<TreeItem> iter = tree.treeItemIterator();
assertFalse(iter.hasNext());
- TreeItem a = tree.addItem("a");
- TreeItem b = tree.addItem("b");
- TreeItem c = tree.addItem("c");
+ TreeItem a = tree.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem b = tree.addItem(SafeHtmlUtils.fromSafeConstant("b"));
+ TreeItem c = tree.addItem(SafeHtmlUtils.fromSafeConstant("c"));
Iterator<TreeItem> iter2 = tree.treeItemIterator();
assertEquals(a, iter2.next());
@@ -205,9 +205,9 @@
assertEquals(c, iter2.next());
assertFalse(iter2.hasNext());
- TreeItem a_a = a.addItem("a_a");
- TreeItem a_a_a = a_a.addItem("a_a_a");
- TreeItem a_a_b = a_a.addItem("a_a_b");
+ TreeItem a_a = a.addItem(SafeHtmlUtils.fromSafeConstant("a_a"));
+ TreeItem a_a_a = a_a.addItem(SafeHtmlUtils.fromSafeConstant("a_a_a"));
+ TreeItem a_a_b = a_a.addItem(SafeHtmlUtils.fromSafeConstant("a_a_b"));
Iterator<TreeItem> iter3 = tree.treeItemIterator();
assertEquals(a, iter3.next());
@@ -226,7 +226,7 @@
item.setWidget(null);
t.clear();
- TreeItem a = t.addItem("");
+ TreeItem a = t.addItem(SafeHtmlUtils.fromSafeConstant(""));
TreeItem b = t.addItem(new Label("b"));
a.setWidget(null);
b.setWidget(null);
@@ -234,8 +234,8 @@
public void testRemove() {
Tree t = createTree();
- TreeItem item = t.addItem("a");
- TreeItem itemb = t.addItem("b");
+ TreeItem item = t.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem itemb = t.addItem(SafeHtmlUtils.fromSafeConstant("b"));
t.setSelectedItem(item);
assertEquals(item, t.getSelectedItem());
item.remove();
@@ -255,8 +255,8 @@
*/
public void testRemoveIsTreeItem() {
Tree t = createTree();
- TreeItem itemA = t.addItem("a");
- TreeItem itemB = t.addItem("b");
+ TreeItem itemA = t.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem itemB = t.addItem(SafeHtmlUtils.fromSafeConstant("b"));
// initial state
assertEquals(2, t.getItemCount());
assertSame(itemA, t.getItem(0));
@@ -274,8 +274,8 @@
*/
public void testRemoveItems() {
Tree t = createTree();
- TreeItem itemA = t.addItem("a");
- TreeItem itemB = t.addItem("b");
+ TreeItem itemA = t.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem itemB = t.addItem(SafeHtmlUtils.fromSafeConstant("b"));
// initial state
assertEquals(2, t.getItemCount());
assertSame(itemA, t.getItem(0));
@@ -294,12 +294,12 @@
public void testRootInsert() {
Tree t = createTree();
- TreeItem b = t.addItem("b");
+ TreeItem b = t.addItem(SafeHtmlUtils.fromSafeConstant("b"));
assertEquals(1, t.getItemCount());
assertEquals(b, t.getItem(0));
// Insert at zero.
- TreeItem a = t.insertItem(0, "a");
+ TreeItem a = t.insertItem(0, SafeHtmlUtils.fromSafeConstant("a"));
assertEquals(2, t.getItemCount());
assertEquals(a, t.getItem(0));
assertEquals(b, t.getItem(1));
@@ -314,7 +314,7 @@
assertEquals(b.getElement().getNextSiblingElement(), d.getElement());
// Insert in the middle.
- TreeItem c = new TreeItem("c");
+ TreeItem c = new TreeItem(SafeHtmlUtils.fromSafeConstant("c"));
t.insertItem(2, c);
assertEquals(4, t.getItemCount());
assertEquals(a, t.getItem(0));
@@ -326,13 +326,13 @@
public void testRootInsertInvalidIndex() {
Tree t = createTree();
- t.addItem("a");
- t.addItem("b");
- t.addItem("c");
+ t.addItem(SafeHtmlUtils.fromSafeConstant("a"));
+ t.addItem(SafeHtmlUtils.fromSafeConstant("b"));
+ t.addItem(SafeHtmlUtils.fromSafeConstant("c"));
// Insert at -1.
try {
- t.insertItem(-1, "illegal");
+ t.insertItem(-1, SafeHtmlUtils.fromSafeConstant("illegal"));
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// Expected.
@@ -340,7 +340,7 @@
// Insert past the end.
try {
- t.insertItem(4, "illegal");
+ t.insertItem(4, SafeHtmlUtils.fromSafeConstant("illegal"));
fail("Expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// Expected.
@@ -399,8 +399,8 @@
public void testSwap() {
Tree t = createTree();
- // Start with text.
- TreeItem item = t.addItem("hello");
+ // Start with html.
+ TreeItem item = t.addItem(SafeHtmlUtils.fromSafeConstant("hello"));
String inner = DOM.getInnerHTML(item.getContentElem());
assertTrue(inner.indexOf("hello") >= 0);
t.addItem(item);
@@ -457,9 +457,9 @@
// Adding widget to end of tree, widgets still have their parents set
// correctly.
- TreeItem a = new TreeItem("a");
- TreeItem b = new TreeItem("b");
- TreeItem c = new TreeItem("c");
+ TreeItem a = new TreeItem(SafeHtmlUtils.fromSafeConstant("a"));
+ TreeItem b = new TreeItem(SafeHtmlUtils.fromSafeConstant("b"));
+ TreeItem c = new TreeItem(SafeHtmlUtils.fromSafeConstant("c"));
TreeItem d = new TreeItem();
TreeItem e = new TreeItem();
Label dLabel = new Label("d");