Hi Bob,

I'd like for you to review this patch that replaces the "Hello Gadgets"
sample with a prettier/simpler "Hello World" based on the sample app that
comes up when you create a new project with projectCreator.

One unresolved issue is that the standard GWT themes don't work with
gadgets, as the image references in the stylesheets end up referencing the
wrong server (they aren't redirected through the proxy.)   To get around
this, I copied the styles I needed from the standard stylesheet, removed the
image references, and patched up the dialog box a bit.

I also prepped the ModulePrefs to upload to the Google content directory.

M
samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloGadgets.java
M
samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloPreferences.java
A
samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle-thumb.png
A
samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle.png
M
samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/hello.css

-- 
Eric Z. Ayers - GWT Team - Atlanta, GA USA
http://code.google.com/webtoolkit/

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

M      samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloGadgets.java
M      samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloPreferences.java
A      samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle-thumb.png
A      samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle.png
M      samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/hello.css

Index: samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloGadgets.java
===================================================================
--- samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloGadgets.java	(revision 922)
+++ samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloGadgets.java	(working copy)
@@ -15,129 +15,76 @@
  */
 package com.google.gwt.gadgets.sample.hellogadgets.client;
 
-import com.google.gwt.core.client.GWT;
 import com.google.gwt.gadgets.client.Gadget;
-import com.google.gwt.gadgets.client.IntrinsicFeature;
-import com.google.gwt.gadgets.client.NeedsIntrinsics;
 import com.google.gwt.gadgets.client.NeedsSetPrefs;
-import com.google.gwt.gadgets.client.NeedsSetTitle;
 import com.google.gwt.gadgets.client.SetPrefsFeature;
-import com.google.gwt.gadgets.client.SetTitleFeature;
 import com.google.gwt.gadgets.client.Gadget.ModulePrefs;
-import com.google.gwt.gadgets.sample.hellogadgets.client.HelloPreferences.ButtonPosition;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
 
 /**
  * HelloWorld Gadget.
  */
-// NB: The __UP_title__ will cause the value of the title preference to be
-// substituted automatically
[EMAIL PROTECTED](title = "__UP_title__", author = "BobV", author_email = "[EMAIL PROTECTED]")
-public class HelloGadgets extends Gadget<HelloPreferences> implements NeedsIntrinsics,
-    NeedsSetPrefs, NeedsSetTitle {
-  IntrinsicFeature intrinsics;
[EMAIL PROTECTED](//
+    title = "Hello GWT for gadgets!", //
+    directory_title = "HelloGadgets - Google APIs for GWT", //
+    author = "Eric Ayers", //
+    author_email = "[EMAIL PROTECTED]", //
+    author_affiliation = "Google", //
+    height = 210, //
+    thumbnail = "gwt-hello-gadgets-igoogle-thumb.png", //
+    screenshot = "gwt-hello-gadgets-igoogle.png")
+public class HelloGadgets extends Gadget<HelloPreferences> implements
+    NeedsSetPrefs {
   SetPrefsFeature setPrefs;
-  SetTitleFeature setTitle;
 
-  public void initializeFeature(IntrinsicFeature feature) {
-    intrinsics = feature;
-  }
+  protected void init(final HelloPreferences prefs) {
+    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png";);
+    Button button = new Button("Click me");
 
-  public void initializeFeature(SetPrefsFeature feature) {
-    this.setPrefs = feature;
-  }
+    VerticalPanel vPanel = new VerticalPanel();
+    vPanel.setWidth("100%");
+    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
+    vPanel.add(img);
+    vPanel.add(button);
 
-  public void initializeFeature(SetTitleFeature feature) {
-    this.setTitle = feature;
-  }
+    RootPanel.get().add(vPanel);
 
-  public void tryXHR(RequestBuilder.Method method, boolean useCached) {
-    String url = GWT.getModuleBaseURL() + "hello.css";
-    if (useCached) {
-      url = intrinsics.getCachedUrl(url);
-    }
-    RequestBuilder rb = new RequestBuilder(method, url);
-    try {
-      rb.sendRequest("This is content", new RequestCallback() {
-        public void onError(Request request, Throwable exception) {
-          exception.printStackTrace();
-          Window.alert("onError: " + exception.getMessage());
-        }
+    // Create the dialog box
+    final DialogBox dialogBox = new DialogBox();
+    dialogBox.setText(prefs.promptSomethingElse().getValue());
+    dialogBox.setAnimationEnabled(true);
+    Button closeButton = new Button("close");
+    VerticalPanel dialogVPanel = new VerticalPanel();
+    dialogVPanel.setWidth("100%");
+    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
+    dialogVPanel.add(closeButton);
 
-        public void onResponseReceived(Request request, Response response) {
-          Window.alert("Success! " + response.getText());
-        }
-      });
-    } catch (RequestException e) {
-      e.printStackTrace();
-      Window.alert("new RequestBuilder failed: " + e.getMessage());
-    }
-  }
+    vPanel.getOffsetHeight();
 
-  protected void init(final HelloPreferences prefs) {
-    Button b = new Button("Set my title", new ClickListener() {
+    closeButton.addClickListener(new ClickListener() {
       public void onClick(Widget sender) {
-        String title = Window.prompt("What is the new title?",
-            prefs.promptSomethingElse().getValue());
-        if (title != null) {
-          setTitle.setTitle(title);
-
-          /*
-           * Save the title for next time. Because the module's title is defined
-           * in terms of the user preference, the value will be displayed
-           * whenever the module starts.
-           */
-          setPrefs.set(prefs.title(), title);
-        }
+        dialogBox.hide();
       }
     });
-    b.setWidth("100%");
 
-    ButtonPosition buttonPosition = prefs.buttonPosition().getValue();
-    b.addStyleName(buttonPosition.getAlign());
+    // Set the contents of the Widget
+    dialogBox.setWidget(dialogVPanel);
 
-    RootPanel.get().add(b);
-    if (prefs.showMessage().getValue()) {
-      RootPanel.get().add(new Label("Try changing the module's settings"));
-    }
-
-    Button tryXHRGet = new Button("Try GET", new ClickListener() {
+    button.addClickListener(new ClickListener() {
       public void onClick(Widget sender) {
-        tryXHR(RequestBuilder.GET, false);
+        dialogBox.center();
+        dialogBox.show();
       }
     });
-    RootPanel.get().add(tryXHRGet);
+  }
 
-    Button tryXHRPost = new Button("Try POST", new ClickListener() {
-      public void onClick(Widget sender) {
-        tryXHR(RequestBuilder.POST, false);
-      }
-    });
-    RootPanel.get().add(tryXHRPost);
-
-    Button tryXHRGetCached = new Button("Try cached GET", new ClickListener() {
-      public void onClick(Widget sender) {
-        tryXHR(RequestBuilder.GET, true);
-      }
-    });
-    RootPanel.get().add(tryXHRGetCached);
-
-    Button tryXHRPostCached = new Button("Try cached POST",
-        new ClickListener() {
-          public void onClick(Widget sender) {
-            tryXHR(RequestBuilder.POST, true);
-          }
-        });
-    RootPanel.get().add(tryXHRPostCached);
+  public void initializeFeature(SetPrefsFeature feature) {
+    this.setPrefs = feature;
   }
 }
Index: samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloPreferences.java
===================================================================
--- samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloPreferences.java	(revision 922)
+++ samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/client/HelloPreferences.java	(working copy)
@@ -15,50 +15,15 @@
  */
 package com.google.gwt.gadgets.sample.hellogadgets.client;
 
-import com.google.gwt.gadgets.client.BooleanPreference;
-import com.google.gwt.gadgets.client.EnumPreference;
 import com.google.gwt.gadgets.client.StringPreference;
 import com.google.gwt.gadgets.client.UserPreferences;
-import com.google.gwt.gadgets.client.EnumPreference.EnumDisplayValue;
 import com.google.gwt.gadgets.client.UserPreferences.PreferenceAttributes.Options;
 
 /**
  * The preferences for the HelloWorld Gadget.
  */
 public interface HelloPreferences extends UserPreferences {
-  /**
-   * The horizontal alignment of the button.
-   */
-  public static enum ButtonPosition {
-    @EnumDisplayValue("Left")
-    LEFT("left"),
-
-    @EnumDisplayValue("Center")
-    CENTER("center"),
-
-    @EnumDisplayValue("Right")
-    RIGHT("right");
-
-    private final String align;
-
-    private ButtonPosition(String align) {
-      this.align = align;
-    }
-
-    public String getAlign() {
-      return align;
-    }
-  }
-
-  @PreferenceAttributes(display_name = "Button text position", default_value = "CENTER")
-  EnumPreference<ButtonPosition> buttonPosition();
-
+  
   @PreferenceAttributes(display_name = "Alert prompt", default_value = "Hello, Gadgets!", options = Options.REQUIRED)
   StringPreference promptSomethingElse();
-
-  @PreferenceAttributes(display_name = "Show settings message", default_value = "true")
-  BooleanPreference showMessage();
-
-  @PreferenceAttributes(options = Options.HIDDEN, default_value = "Hello World (GWT)")
-  StringPreference title();
 }
Index: samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle-thumb.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/png

Property changes on: samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle-thumb.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Index: samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/png

Property changes on: samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/gwt-hello-gadgets-igoogle.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Index: samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/hello.css
===================================================================
--- samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/hello.css	(revision 922)
+++ samples/hellogadgets/src/com/google/gwt/gadgets/sample/hellogadgets/public/hello.css	(working copy)
@@ -1,6 +1,103 @@
+/**
+ * The file contains styles for a sample gadget derived from the
+ * GWT standard theme.
+ * Images in the stylesheet have been removed, as well as styles for widgets
+ * not currently in use.
+ */
+
+body, table td, select {
+  font-family: Arial Unicode MS, Arial, sans-serif;
+  font-size: small;
+}
+pre {
+  font-family: "courier new", courier;
+  font-size: small;
+}
 body {
-  background: silver;
+  color: black;
+  margin: 0px;
+  border: 0px;
+  padding: 0px;
+  background: #fff;
+  direction: ltr;
 }
-.left { text-align: left }
-.center { text-align: center }
-.right { text-align: right }
\ No newline at end of file
+a, a:visited, a:hover {
+  color: #0000AA;
+}
+
+/**
+ * The reference theme can be used to determine when this style sheet has
+ * loaded.  Create a hidden div element with absolute position, assign the style
+ * name below, and attach it to the DOM.  Use a timer to detect when the
+ * element's height and width are set to 5px.
+ */
+.gwt-Reference-standard {
+  height: 5px;
+  width: 5px;
+  zoom: 1;
+}
+
+.gwt-Button {
+  margin: 0;
+  padding: 3px 5px;
+  text-decoration: none;
+  font-size: small;
+  cursor: pointer;
+  cursor: hand;
+  border: 1px outset #ccc;
+}
+.gwt-Button:active {
+  border: 1px inset #ccc;
+}
+.gwt-Button:hover {
+  border-color: #9cf #69e #69e #7af;
+}
+.gwt-Button[disabled] {
+  cursor: default;
+  color: #888;
+}
+.gwt-Button[disabled]:hover {
+  border: 1px outset #ccc;
+}
+
+.gwt-DialogBox .Caption {
+  background: #e3e8f3;
+  padding: 4px 4px 4px 8px;
+  cursor: default;
+  border-bottom: 1px solid #bbbbbb;
+  border-top: 5px solid #d0e4f6;
+  border-left: 5px solid #d0e4f6;
+  border-right: 5px solid #d0e4f6;
+}
+
+.gwt-DialogBox .dialogContent {
+}
+
+.gwt-DialogBox .dialogMiddleCenter {
+  padding: 3px;
+  background: white;
+  border-left: 5px solid #d0e4f6;
+  border-right: 5px solid #d0e4f6;
+  border-bottom: 5px solid #d0e4f6;
+}
+
+.gwt-DialogBox .dialogTopLeftInner {
+  width: 5px;
+  zoom: 1;
+}
+.gwt-DialogBox .dialogTopRightInner {
+  width: 8px;
+  zoom: 1;
+}
+.gwt-DialogBox .dialogBottomLeftInner {
+  width: 5px;
+  height: 8px;
+  zoom: 1;
+}
+
+.gwt-DialogBox .dialogBottomRightInner {
+  width: 5px;
+  height: 8px;
+  zoom: 1;
+}
+

<<inline: gwt-hello-gadgets-igoogle.png>>

<<inline: gwt-hello-gadgets-igoogle-thumb.png>>

Reply via email to