Reviewers: skybrian,

Description:
Removing uses of deprecated Tree code in GWT showcase sample and
TreeExample.


Please review this at http://gwt-code-reviews.appspot.com/1712804/

Affected files:
M samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackLayoutPanel.java M samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackPanel.java M samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwTree.java
  M user/javadoc/com/google/gwt/examples/TreeExample.java


Index: samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackLayoutPanel.java
===================================================================
--- samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackLayoutPanel.java (revision 10982) +++ samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackLayoutPanel.java (working copy)
@@ -105,6 +105,7 @@
     /**
      * Use noimage.png, which is a blank 1x1 image.
      */
+    @Override
     @Source("noimage.png")
     ImageResource treeLeaf();
   }
@@ -163,10 +164,12 @@
   protected void asyncOnInitialize(final AsyncCallback<Widget> callback) {
     GWT.runAsync(CwStackLayoutPanel.class, new RunAsyncCallback() {

+      @Override
       public void onFailure(Throwable caught) {
         callback.onFailure(caught);
       }

+      @Override
       public void onSuccess() {
         callback.onSuccess(onInitialize());
       }
@@ -219,6 +222,7 @@

       // Open the contact info popup when the user clicks a contact
       contactLink.addClickHandler(new ClickHandler() {
+        @Override
         public void onClick(ClickEvent event) {
           // Set the info about the contact
           SafeHtmlBuilder sb = new SafeHtmlBuilder();
@@ -285,7 +289,7 @@
   @ShowcaseSource
   private Widget createMailItem(Images images) {
     Tree mailPanel = new Tree(images);
-    TreeItem mailPanelRoot = mailPanel.addItem("f...@example.com");
+    TreeItem mailPanelRoot = mailPanel.addTextItem("f...@example.com");
     String[] mailFolders = constants.cwStackLayoutPanelMailFolders();
     addItem(mailPanelRoot, images.inbox(), mailFolders[0]);
     addItem(mailPanelRoot, images.drafts(), mailFolders[1]);
Index: samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackPanel.java
===================================================================
--- samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackPanel.java (revision 10982) +++ samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwStackPanel.java (working copy)
@@ -21,6 +21,7 @@
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.i18n.client.Constants;
 import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
 import com.google.gwt.sample.showcase.client.ContentWidget;
import com.google.gwt.sample.showcase.client.ShowcaseAnnotations.ShowcaseData; import com.google.gwt.sample.showcase.client.ShowcaseAnnotations.ShowcaseSource;
@@ -101,6 +102,7 @@
     /**
      * Use noimage.png, which is a blank 1x1 image.
      */
+    @Override
     @Source("noimage.png")
     ImageResource treeLeaf();
   }
@@ -159,10 +161,12 @@
   protected void asyncOnInitialize(final AsyncCallback<Widget> callback) {
     GWT.runAsync(CwStackPanel.class, new RunAsyncCallback() {

+      @Override
       public void onFailure(Throwable caught) {
         callback.onFailure(caught);
       }

+      @Override
       public void onSuccess() {
         callback.onSuccess(onInitialize());
       }
@@ -170,7 +174,10 @@
   }

   private void addItem(TreeItem root, ImageResource image, String label) {
- root.addItem(AbstractImagePrototype.create(image).getHTML() + " " + label);
+    SafeHtmlBuilder itemHtml = new SafeHtmlBuilder();
+    itemHtml.append(AbstractImagePrototype.create(image).getSafeHtml());
+    itemHtml.appendEscaped(" ").appendEscaped(label);
+    root.addItem(itemHtml.toSafeHtml());
   }

   /**
@@ -203,6 +210,7 @@

       // Open the contact info popup when the user clicks a contact
       contactLink.addClickHandler(new ClickHandler() {
+        @Override
         public void onClick(ClickEvent event) {
           // Set the info about the contact
contactInfo.setHTML(contactName + "<br><i>" + contactEmail + "</i>");
@@ -242,7 +250,7 @@
   @ShowcaseSource
   private Tree createMailItem(Images images) {
     Tree mailPanel = new Tree(images);
-    TreeItem mailPanelRoot = mailPanel.addItem("f...@example.com");
+    TreeItem mailPanelRoot = mailPanel.addTextItem("f...@example.com");
     String[] mailFolders = constants.cwStackPanelMailFolders();
     addItem(mailPanelRoot, images.inbox(), mailFolders[0]);
     addItem(mailPanelRoot, images.drafts(), mailFolders[1]);
Index: samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwTree.java
===================================================================
--- samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwTree.java (revision 10982) +++ samples/showcase/src/com/google/gwt/sample/showcase/client/content/lists/CwTree.java (working copy)
@@ -147,10 +147,12 @@
   protected void asyncOnInitialize(final AsyncCallback<Widget> callback) {
     GWT.runAsync(CwTree.class, new RunAsyncCallback() {

+      @Override
       public void onFailure(Throwable caught) {
         callback.onFailure(caught);
       }

+      @Override
       public void onSuccess() {
         callback.onSuccess(onInitialize());
       }
@@ -167,9 +169,9 @@
   @ShowcaseSource
   private void addMusicSection(
       TreeItem parent, String label, String[] composerWorks) {
-    TreeItem section = parent.addItem(label);
+    TreeItem section = parent.addTextItem(label);
     for (String work : composerWorks) {
-      section.addItem(work);
+      section.addTextItem(work);
     }
   }

@@ -186,14 +188,15 @@

     // Add some default tree items
     for (int i = 0; i < 5; i++) {
- TreeItem item = dynamicTree.addItem(constants.cwTreeItem() + " " + i); + TreeItem item = dynamicTree.addTextItem(constants.cwTreeItem() + " " + i);

       // Temporarily add an item so we can expand this node
-      item.addItem("");
+      item.addTextItem("");
     }

     // Add a handler that automatically generates some children
     dynamicTree.addOpenHandler(new OpenHandler<TreeItem>() {
+      @Override
       public void onOpen(OpenEvent<TreeItem> event) {
         TreeItem item = event.getTarget();
         if (item.getChildCount() == 1) {
@@ -204,8 +207,8 @@
           String itemText = item.getText();
           int numChildren = Random.nextInt(5) + 2;
           for (int i = 0; i < numChildren; i++) {
-            TreeItem child = item.addItem(itemText + "." + i);
-            child.addItem("");
+            TreeItem child = item.addTextItem(itemText + "." + i);
+            child.addTextItem("");
           }

           // Remove the temporary item when we finish loading
@@ -237,7 +240,7 @@
     Tree staticTree = new Tree();

     // Add some of Beethoven's music
-    TreeItem beethovenItem = staticTree.addItem(composers[0]);
+    TreeItem beethovenItem = staticTree.addTextItem(composers[0]);
     addMusicSection(beethovenItem, concertosLabel,
         constants.cwTreeBeethovenWorkConcertos());
     addMusicSection(
@@ -248,7 +251,7 @@
         constants.cwTreeBeethovenWorkSymphonies());

     // Add some of Brahms's music
-    TreeItem brahmsItem = staticTree.addItem(composers[1]);
+    TreeItem brahmsItem = staticTree.addTextItem(composers[1]);
     addMusicSection(
         brahmsItem, concertosLabel, constants.cwTreeBrahmsWorkConcertos());
     addMusicSection(
@@ -259,7 +262,7 @@
brahmsItem, symphoniesLabel, constants.cwTreeBrahmsWorkSymphonies());

     // Add some of Mozart's music
-    TreeItem mozartItem = staticTree.addItem(composers[2]);
+    TreeItem mozartItem = staticTree.addTextItem(composers[2]);
     addMusicSection(
         mozartItem, concertosLabel, constants.cwTreeMozartWorkConcertos());

Index: user/javadoc/com/google/gwt/examples/TreeExample.java
===================================================================
--- user/javadoc/com/google/gwt/examples/TreeExample.java       (revision 10982)
+++ user/javadoc/com/google/gwt/examples/TreeExample.java       (working copy)
@@ -23,12 +23,14 @@

 public class TreeExample implements EntryPoint {

+  @Override
   public void onModuleLoad() {
     // Create a tree with a few items in it.
-    TreeItem root = new TreeItem("root");
-    root.addItem("item0");
-    root.addItem("item1");
-    root.addItem("item2");
+    TreeItem root = new TreeItem();
+    root.setText("root");
+    root.addTextItem("item0");
+    root.addTextItem("item1");
+    root.addTextItem("item2");

     // Add a CheckBox to the tree
     TreeItem item = new TreeItem(new CheckBox("item3"));


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to