Permalink
Browse files

Merge remote-tracking branch 'ahhughes/ahhughes-WelcomeWidgetUiBinder…

…Port'

Fixed apparent conflicts in (seems to just be import issues)
	tvguide-client/src/main/java/com/acme/gwt/client/widget/WelcomeWidget.java
  • Loading branch information...
2 parents 57f724e + a3eb501 commit 9458cfff90675b9df13aa6eb6a1a3fb0e60959bf @niloc132 committed May 11, 2011
@@ -16,15 +16,20 @@
*/
package com.acme.gwt.client.widget;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
import com.acme.gwt.shared.TvViewerProxy;
import com.google.gwt.activity.shared.ActivityManager;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasOneWidget;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.LayoutPanel;
+import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -39,15 +44,44 @@
interface Binder extends UiBinder<Widget, TvGuideAppShell> {
}
private Binder uiBinder = GWT.create(Binder.class);
+
+ private static final Logger logger = Logger.getLogger(TvGuideAppShell.class.getName());
@UiField
LayoutPanel display;
-
+
+ @UiField
+ MenuItem profileMenuItem, logoutMenuItem, aboutMenuItem, helpMenuItem;
+
@Inject
public TvGuideAppShell(ActivityManager activityManager, TvViewerProxy user) {
initWidget(uiBinder.createAndBindUi(this));
-
activityManager.setDisplay(this);
+ //set all the menuItem Commands.. do stuff when they are clicked.
+ profileMenuItem.setCommand(new Command() {
+ @Override
+ public void execute() {
+ logger.log(Level.FINE,"TODO, fire the real command...");
+ }
+ });
+ logoutMenuItem.setCommand(new Command() {
+ @Override
+ public void execute() {
+ logger.log(Level.FINE,"TODO, fire the real command...");
+ }
+ });
+ aboutMenuItem.setCommand(new Command() {
+ @Override
+ public void execute() {
+ logger.log(Level.FINE,"TODO, fire the real command...");
+ }
+ });
+ helpMenuItem.setCommand(new Command() {
+ @Override
+ public void execute() {
+ logger.log(Level.FINE,"TODO, fire the real command...");
+ }
+ });
}
@Override
@@ -7,9 +7,17 @@
<g:DockLayoutPanel unit="PX">
<g:north size="25">
<g:HTMLPanel>
- TvGuide Sample GWT App | profile | logout | help
+ TvGuide Sample GWT App
</g:HTMLPanel>
</g:north>
+ <g:north size="25">
+ <g:MenuBar>
+ <g:MenuItem ui:field="profileMenuItem">Profile</g:MenuItem>
+ <g:MenuItem ui:field="logoutMenuItem">Logout</g:MenuItem>
+ <g:MenuItem ui:field="aboutMenuItem">About</g:MenuItem>
+ <g:MenuItem ui:field="helpMenuItem">Help</g:MenuItem>
+ </g:MenuBar>
+ </g:north>
<g:center>
<g:LayoutPanel ui:field="display" />
</g:center>
@@ -22,18 +22,19 @@
import com.acme.gwt.client.view.WelcomeView;
import com.acme.gwt.shared.TvShowProxy;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.RequiresResize;
+import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver;
/**
* @author colin
- *
+ *
*/
@Singleton
public class WelcomeWidget extends Composite
@@ -45,22 +46,28 @@
RequestFactoryEditorDriver<List<TvShowProxy>, FavoriteShowsListWidget> {
}
+ private static WelcomeWidgetUiBinder uiBinder = GWT
+ .create(WelcomeWidgetUiBinder.class);
+
+ interface WelcomeWidgetUiBinder extends UiBinder<Widget, WelcomeWidget> {
+ }
+
FavoritesDriver driver = GWT.create(FavoritesDriver.class);
+
+ @UiField
+ LayoutPanel layoutPanel;
+
+ @UiField(provided = true)
+ FavoriteShowsListWidget listView;
+
@Inject
public WelcomeWidget(TvGuideRequestFactory rf,
FavoriteShowsListWidget listView) {
- LayoutPanel panel = new LayoutPanel();
- initWidget(panel);
-
- panel
- .add(new Label(
- "Welcome, rest of app will be here soon. (Delivery in 4-6 weeks)"));
- panel.add(listView);
- //BAD: all layout done by hand, and quick, without UiBinder's help or CssResource
- panel.setWidgetTopHeight(listView, 0, Unit.PX, 100, Unit.PCT);
- listView.getElement().setAttribute("margin-top", "25px");
+ this.listView = listView;
+ initWidget(uiBinder.createAndBindUi(this));
- // Attach the data - easy way to bind a views editor to something accessible from a presenter
+ // Attach the data - easy way to bind a views editor to something
+ // accessible from a presenter
driver.initialize(rf, listView);
}
@@ -70,7 +77,7 @@ public WelcomeWidget(TvGuideRequestFactory rf,
@Override
public void onResize() {
- //?
+ // ?
}
@Override
@@ -0,0 +1,15 @@
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui"
+ xmlns:tvg="urn:import:com.acme.gwt.client.widget">
+ <ui:style>
+ .important {
+ font-weight: bold;
+ }
+ </ui:style>
+ <g:LayoutPanel ui:field="layoutPanel">
+ <g:layer>
+ <tvg:FavoriteShowsListWidget ui:field="listView"/>
+ </g:layer>
+ </g:LayoutPanel>
+</ui:UiBinder>

0 comments on commit 9458cff

Please sign in to comment.