Revision: 7781
Author: [email protected]
Date: Wed Mar 24 12:16:12 2010
Log: Adds details place to scaffold app, and deletes unused
EntityPlaceVisitor, EntityPlaceFilter.

Review at http://gwt-code-reviews.appspot.com/251801

Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=7781

Added:
 /trunk/bikeshed/src/com/google/gwt/app/place/GoToPlaceCommand.java
/trunk/bikeshed/src/com/google/gwt/sample/expenses/client/DetailsRequester.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityListPresenter.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityNameRenderer.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ListPlaceRenderer.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/AbstractExpensesPlace.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/EditEntityPlace.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/EntityDetailsPlace.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpenseEntityPlace.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpensesEntityFilter.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpensesEntityKey.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpensesEntityVisitor.java
 /trunk/bikeshed/src/com/google/gwt/user/client/ui/Renderer.java
Deleted:
 /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityList.java
/trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpensesScaffoldPlace.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpensesScaffoldPlaceFilter.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpensesScaffoldPlaceVisitor.java
Modified:
 /trunk/bikeshed/src/com/google/gwt/app/place/PlacePicker.java
/trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityListView.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ExpensesScaffold.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ExpensesScaffoldShell.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ListRequester.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/TableEntityListView.java /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/EntityListPlace.java
 /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/Places.java
 /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/EmployeeKey.java
 /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ReportKey.java
 /trunk/bikeshed/src/com/google/gwt/valuestore/client/ValuesImpl.java
 /trunk/bikeshed/src/com/google/gwt/valuestore/shared/Values.java

=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/app/place/GoToPlaceCommand.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.app.place;
+
+import com.google.gwt.user.client.Command;
+
+/**
+ * Command to change the app location.
+ *
+ * @param <P> the type of place managed by the {...@link PlaceController}
+ */
+public class GoToPlaceCommand<P extends Place> implements Command {
+  private final P place;
+  private final PlaceController<? super P> placeController;
+
+  /**
+   * @param place
+   * @param placeController
+   */
+ public GoToPlaceCommand(P place, PlaceController<? super P> placeController) {
+    this.place = place;
+    this.placeController = placeController;
+  }
+
+  public void execute() {
+    placeController.goTo(place);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/DetailsRequester.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client;
+
+import com.google.gwt.app.place.PlaceChanged;
+import com.google.gwt.sample.expenses.client.place.EntityDetailsPlace;
+import com.google.gwt.sample.expenses.shared.EmployeeKey;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityVisitor;
+import com.google.gwt.sample.expenses.shared.ReportKey;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.google.gwt.valuestore.shared.Values;
+
+/**
+ * In charge of requesting and displaying all info when the user goes to an
+ * {...@link EntityDetailsPlace}.
+ */
+public final class DetailsRequester implements PlaceChanged.Handler {
+
+  private final EntityNameRenderer entityNamer;
+  private final SimplePanel panel;
+  private final HTML detailsView;
+
+  public DetailsRequester(EntityNameRenderer entityNamer,
+      SimplePanel simplePanel, HTML detailsView) {
+    this.entityNamer = entityNamer;
+    this.panel = simplePanel;
+    this.detailsView = detailsView;
+  }
+
+  public void onPlaceChanged(PlaceChanged event) {
+    if (!(event.getNewPlace() instanceof EntityDetailsPlace)) {
+      return;
+    }
+    EntityDetailsPlace newPlace = (EntityDetailsPlace) event.getNewPlace();
+ final Values<? extends ExpensesEntityKey<?>> entity = newPlace.getEntity();
+    ExpensesEntityKey<?> key = entity.getEntityKey();
+
+    // TODO make a pretty uibinder page, not least because we're rendering
+    // user strings here, which is dangerous
+
+    final String title = new StringBuilder("<h1>").append(
+        entityNamer.render(key)).append("</h1>").toString();
+
+    final StringBuilder list = new StringBuilder();
+
+    // TODO would actually issue request to get details here, but
+    // at the moment we know we already have them, such as they are.
+    // And we haven't implemented the fake findEmployee call yet, ahem.
+
+    key.accept(new ExpensesEntityVisitor() {
+
+      @SuppressWarnings("unchecked")
+      public void visit(EmployeeKey employeeKey) {
+        // wow, this cast is nasty. Perhaps visitor should actually
+        // be on the Values themselves?
+        Values<EmployeeKey> eValues = (Values<EmployeeKey>) entity;
+        String user = eValues.get(EmployeeKey.get().getUserName());
+        list.append("<div>");
+        list.append("<label>").append("User Name: ").append("</label>");
+        list.append("<span>").append(user).append("</span>");
+        list.append("</div>");
+
+        list.append("<div>");
+        String display = eValues.get(EmployeeKey.get().getDisplayName());
+        list.append("<label>").append("Display Name: ").append("</label>");
+        list.append("<span>").append(display).append("</span>");
+        list.append("</div>");
+      }
+
+      @SuppressWarnings("unchecked")
+      public void visit(ReportKey reportKey) {
+        Values<ReportKey> rValues = (Values<ReportKey>) entity;
+        String purpose = rValues.get(ReportKey.get().getPurpose());
+        list.append("<div>");
+        list.append("<label>").append("Purpose: ").append("</label>");
+        list.append("<span>").append(purpose).append("</span>");
+        list.append("</div>");
+
+        list.append("<div>");
+ String created = rValues.get(ReportKey.get().getCreated()).toString();
+        list.append("<label>").append("Created: ").append("</label>");
+        list.append("<span>").append(created).append("</span>");
+        list.append("</div>");
+      }
+    });
+
+    detailsView.setHTML(title + list.toString());
+
+    if (detailsView.getParent() == null) {
+      panel.clear();
+      panel.add(detailsView);
+    }
+  }
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityListPresenter.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client;
+
+import com.google.gwt.sample.expenses.client.place.Places;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.HasValueList;
+import com.google.gwt.valuestore.shared.Property;
+import com.google.gwt.valuestore.shared.Values;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Presenter that shows a list of entities and provides "edit" and "show"
+ * commands for them.
+ *
+ * @param <E> the type of entity listed
+ */
+public class EntityListPresenter<E extends ExpensesEntityKey<?>> implements
+    HasValueList<Values<E>> {
+  private final EntityListView view;
+  private final List<Property<E, ?>> properties;
+  private final Places places;
+
+  public EntityListPresenter(String heading, EntityListView view,
+      List<Property<E, ?>> properties, Places places) {
+    this.view = view;
+    view.setHeading(heading);
+    this.properties = properties;
+    this.places = places;
+
+    List<String> names = new ArrayList<String>();
+    for (Property<E, ?> property : properties) {
+      names.add(property.getName());
+    }
+    this.view.setColumnNames(names);
+  }
+
+  public void editValueList(boolean replace, int index,
+      List<Values<E>> newValues) {
+    throw new UnsupportedOperationException();
+  }
+
+  public void setValueList(List<Values<E>> newValues) {
+    List<EntityListView.Row> rows = new ArrayList<EntityListView.Row>();
+
+    for (final Values<E> values : newValues) {
+      final List<String> strings = new ArrayList<String>();
+      for (Property<E, ?> property : properties) {
+        strings.add(values.get(property).toString());
+      }
+      EntityListView.Row row = new EntityListView.Row() {
+
+        public Command getEditCommand() {
+          return places.getGoToEditFor(values);
+        }
+
+        public Command getShowDetailsCommand() {
+          return places.getGoToDetailsFor(values);
+        }
+
+        public List<String> getValues() {
+          return strings;
+        }
+
+      };
+      rows.add(row);
+    }
+
+    view.setRowData(rows);
+  }
+
+  public void setValueListSize(int size, boolean exact) {
+    throw new UnsupportedOperationException();
+  }
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityNameRenderer.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client;
+
+import com.google.gwt.sample.expenses.shared.EmployeeKey;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityFilter;
+import com.google.gwt.sample.expenses.shared.ReportKey;
+import com.google.gwt.user.client.ui.Renderer;
+
+/**
+ * Renders the name of {...@link ExpensesEntityKey}s.
+ */
+//TODO i18n
+public class EntityNameRenderer implements Renderer<ExpensesEntityKey<?>> {
+ private final ExpensesEntityFilter<String> filter = new ExpensesEntityFilter<String>() {
+    public String filter(EmployeeKey employeeKey) {
+      return "Employees";
+    }
+
+    public String filter(ReportKey reportKey) {
+      return "Reports";
+    }
+  };
+
+  public String render(ExpensesEntityKey<?> entity) {
+    return entity.accept(filter);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ListPlaceRenderer.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client;
+
+import com.google.gwt.sample.expenses.client.place.EntityListPlace;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.user.client.ui.Renderer;
+
+/**
+ * Renders {...@link EntityListPlace}s for display to users.
+ */
+public class ListPlaceRenderer implements Renderer<EntityListPlace> {
+
+  private final Renderer<ExpensesEntityKey<?>> entityRenderer;
+
+  /**
+   * @param entityRenderer
+   */
+  public ListPlaceRenderer(Renderer<ExpensesEntityKey<?>> entityRenderer) {
+    this.entityRenderer = entityRenderer;
+  }
+
+  public String render(EntityListPlace object) {
+    return entityRenderer.render(object.getKey());
+  }
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/AbstractExpensesPlace.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client.place;
+
+import com.google.gwt.app.place.Place;
+
+/**
+ * Base type of places for the Expenses Scaffold app.
+ */
+public abstract class AbstractExpensesPlace extends Place {
+  // TODO is there actual value in this base class?
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/EditEntityPlace.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client.place;
+
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.valuestore.shared.Values;
+
+/**
+ * Place in the app to edit an entity.
+ */
+public class EditEntityPlace extends ExpenseEntityPlace {
+
+  public EditEntityPlace(Values<? extends ExpensesEntityKey<?>> entity) {
+    super(entity);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/EntityDetailsPlace.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client.place;
+
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.valuestore.shared.Values;
+
+/**
+ * Place in the app to see details of an entity.
+ */
+public class EntityDetailsPlace extends ExpenseEntityPlace {
+
+  /**
+   * @param e
+   */
+ public EntityDetailsPlace(Values<? extends ExpensesEntityKey<?>> entity) {
+    // TODO it is bad to be passing the values rather than an id. Want
+    // to force UI code to request the data it needs
+    super(entity);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpenseEntityPlace.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.client.place;
+
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.valuestore.shared.Values;
+
+/**
+ * A place in the app focused on a particular entity.
+ */
+public abstract class ExpenseEntityPlace extends AbstractExpensesPlace {
+
+  private final Values<? extends ExpensesEntityKey<?>> entity;
+
+  /**
+   * @param entity
+   */
+ public ExpenseEntityPlace(Values<? extends ExpensesEntityKey<?>> entity) {
+
+    this.entity = entity;
+  }
+
+  /**
+   * @return the entity
+   */
+  public Values<? extends ExpensesEntityKey<?>> getEntity() {
+    return entity;
+  }
+
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpensesEntityFilter.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.shared;
+
+/**
+ * "API Generated" base interface implemented by filters of {...@link ExpensesEntityKey}.
+ * <p>
+ * IRL this class will be generated by a JPA-savvy tool run before compilation.
+ *
+ * @param <T> the type to filter to
+ */
+public interface ExpensesEntityFilter<T> {
+  T filter(EmployeeKey employeeKey);
+
+  T filter(ReportKey reportKey);
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpensesEntityKey.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.shared;
+
+import com.google.gwt.requestfactory.shared.EntityKey;
+
+/**
+ * "API Generated" base interface for proxy keys to
+ * {...@link com.google.gwt.valuestore.shared.Values Values} of
+ * {...@link com.google.gwt.sample.expenses.server.domain}.
+ * <p>
+ * IRL this class will be generated by a JPA-savvy tool run before compilation.
+ *
+ * @param <K> this entity type
+ */
+public interface ExpensesEntityKey<K extends EntityKey<K>> extends EntityKey<K> {
+  public abstract void accept(ExpensesEntityVisitor visitor);
+
+  public abstract <T> T accept(ExpensesEntityFilter<T> filter);
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpensesEntityVisitor.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.expenses.shared;
+
+/**
+ * "API Generated" base interface implemented by visitors of {...@link ExpensesEntityKey}.
+ * <p>
+ * IRL this class will be generated by a JPA-savvy tool run before compilation.
+ */
+public interface ExpensesEntityVisitor {
+  void visit(EmployeeKey employeeKey);
+  void visit(ReportKey reportKey);
+}
=======================================
--- /dev/null
+++ /trunk/bikeshed/src/com/google/gwt/user/client/ui/Renderer.java Wed Mar 24 12:16:12 2010
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.user.client.ui;
+
+/**
+ * An object that can render other objects of a particular type into plain-text
+ * form.
+ *
+ * @param <T> the type to render
+ */
+public interface Renderer<T> {
+  /**
+   * Renders {...@code object} as plain text.
+   */
+  String render(T object);
+}
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityList.java Fri Mar 19 10:26:09 2010
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.expenses.client;
-
-import com.google.gwt.requestfactory.shared.EntityKey;
-import com.google.gwt.user.client.ui.HasValueList;
-import com.google.gwt.valuestore.shared.Property;
-import com.google.gwt.valuestore.shared.Values;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Base class for showing a list of entities.
- *
- * @param <E> the type of entity listed
- */
-public class EntityList<E extends EntityKey<E>> implements
-    HasValueList<Values<E>> {
-  protected final EntityListView view;
-  protected final List<Property<E, ?>> properties;
-
- public EntityList(String heading, EntityListView view, List<Property<E, ?>> properties) {
-    this.view = view;
-    view.setHeading(heading);
-    this.properties = properties;
-
-    List<String> names = new ArrayList<String>();
-    for (Property<E, ?> property : properties) {
-      names.add(property.getName());
-    }
-    this.view.setColumnNames(names);
-  }
-
-  public void editValueList(boolean replace, int index,
-      List<Values<E>> newValues) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void setValueList(List<Values<E>> newValues) {
-    List<List<String>> strings = new ArrayList<List<String>>();
-
-    for (Values<E> values : newValues) {
-      List<String> row = new ArrayList<String>();
-      for (Property<E, ?> property : properties) {
-        row.add(values.get(property).toString());
-      }
-      strings.add(row);
-    }
-
-    view.setValues(strings);
-  }
-
-  public void setValueListSize(int size, boolean exact) {
-    throw new UnsupportedOperationException();
-  }
-}
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpensesScaffoldPlace.java Wed Mar 17 12:54:18 2010
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.expenses.client.place;
-
-import com.google.gwt.app.place.Place;
-
-/**
- * Base type of places for the Expenses Scaffold app.
- */
-public abstract class ExpensesScaffoldPlace extends Place {
-  public abstract void accept(ExpensesScaffoldPlaceVisitor visitor);
-
-  public abstract <T> T accept(ExpensesScaffoldPlaceFilter<T> filter);
-}
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpensesScaffoldPlaceFilter.java Mon Mar 22 05:12:31 2010
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.expenses.client.place;
-
-/**
- * Implemented by filters of {...@link ExpensesScaffoldPlace}.
- *
- * @param <T> the type to filter to
- */
-public interface ExpensesScaffoldPlaceFilter<T> {
-
-//  /**
-//   * @param editEntityPlace
-//   * @return
-//   */
-//  T filter(EditEntityPlace editEntityPlace);
-//
-//  /**
-//   * @param entityDetailsPlace
-//   * @return
-//   */
-//  T filter(EntityDetailsPlace entityDetailsPlace);
-
-  /**
-   * @param entityListPlace
-   * @return
-   */
-  T filter(EntityListPlace entityListPlace);
-
-}
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/ExpensesScaffoldPlaceVisitor.java Fri Mar 19 10:26:09 2010
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.expenses.client.place;
-
-/**
- *
- */
-public interface ExpensesScaffoldPlaceVisitor {
-
-//  /**
-//   * @param editEntityPlace
-//   */
-//  void visit(EditEntityPlace editEntityPlace);
-//
-//  /**
-//   * @param entityDetailsPlace
-//   */
-//  void visit(EntityDetailsPlace entityDetailsPlace);
-
-  /**
-   * @param entityListPlace
-   */
-  void visit(EntityListPlace entityListPlace);
-
-}
=======================================
--- /trunk/bikeshed/src/com/google/gwt/app/place/PlacePicker.java Wed Mar 17 12:54:18 2010 +++ /trunk/bikeshed/src/com/google/gwt/app/place/PlacePicker.java Wed Mar 24 12:16:12 2010
@@ -15,7 +15,10 @@
  */
 package com.google.gwt.app.place;

-import java.util.Map;
+import com.google.gwt.user.client.ui.Renderer;
+
+import java.util.LinkedHashMap;
+import java.util.List;

 /**
  * Presenter that goes to {...@link Place}s the user picks.
@@ -25,19 +28,27 @@
 public class PlacePicker<P extends Place> implements
     PlacePickerView.Listener<P> {
   private final PlacePickerView<P> view;
-  private final PlaceController<P> placeController;
-
- public PlacePicker(PlacePickerView<P> view, PlaceController<P> placeController) {
+  private final PlaceController<? super P> placeController;
+  private final Renderer<P> renderer;
+
+  public PlacePicker(PlacePickerView<P> view,
+      PlaceController<? super P> placeController, Renderer<P> renderer) {
+    // ? super P to allow us to pick subtypes of the PlaceController's type
     this.view = view;
     this.placeController = placeController;
     this.view.setListener(this);
+    this.renderer = renderer;
   }

   public void placePicked(P place) {
     placeController.goTo(place);
   }

-  public void setPlaces(Map<? extends P, String> places) {
-    view.setValues(places);
+  public void setPlaces(List<? extends P> places) {
+    LinkedHashMap<P, String> map = new LinkedHashMap<P, String>();
+    for (P place : places) {
+      map.put(place, renderer.render(place));
+    }
+    view.setValues(map);
   }
 }
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityListView.java Mon Mar 22 05:12:31 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/EntityListView.java Wed Mar 24 12:16:12 2010
@@ -15,15 +15,38 @@
  */
 package com.google.gwt.sample.expenses.client;

+import com.google.gwt.user.client.Command;
+
 import java.util.List;

 /**
  * Simple display of a list of entities.
  */
 public interface EntityListView {
-  void setHeading(String text);
+
+  /**
+   * Interface implemented by a row of data to display.
+   */
+  interface Row {
+    /**
+     * @return command to edit this row
+     */
+    Command getEditCommand();
+
+    /**
+     * @return command to show the details for this row
+     */
+    Command getShowDetailsCommand();
+
+    /**
+     * @return the strings to render for this row
+     */
+    List<String> getValues();
+  }

   void setColumnNames(List<String> names);

-  void setValues(List<List<String>> values);
-}
+  void setHeading(String text);
+
+  void setRowData(List<Row> rows);
+}
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ExpensesScaffold.java Mon Mar 22 05:12:31 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ExpensesScaffold.java Wed Mar 24 12:16:12 2010
@@ -23,9 +23,11 @@
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.Element;
 import com.google.gwt.event.shared.HandlerManager;
-import com.google.gwt.sample.expenses.client.place.ExpensesScaffoldPlace;
+import com.google.gwt.sample.expenses.client.place.EntityListPlace;
+import com.google.gwt.sample.expenses.client.place.AbstractExpensesPlace;
 import com.google.gwt.sample.expenses.client.place.Places;
 import com.google.gwt.sample.expenses.shared.ExpenseRequestFactory;
+import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.RootLayoutPanel;

 /**
@@ -34,23 +36,38 @@
 public class ExpensesScaffold implements EntryPoint {

   public void onModuleLoad() {
+
+    // App controllers and services
final ExpenseRequestFactory requests = GWT.create(ExpenseRequestFactory.class);
     final HandlerManager eventBus = new HandlerManager(null);
- final PlaceController<ExpensesScaffoldPlace> placeController = new PlaceController<ExpensesScaffoldPlace>( + final PlaceController<AbstractExpensesPlace> placeController = new PlaceController<AbstractExpensesPlace>(
         eventBus);
-
+    final Places places = new Places(placeController);
+
+    // Renderers
+    final EntityNameRenderer entityNamer = new EntityNameRenderer();
+ final ListPlaceRenderer listPlaceNamer = new ListPlaceRenderer(entityNamer);
+
+    // Top level UI
     final ExpensesScaffoldShell shell = new ExpensesScaffoldShell();

- PlacePicker<ExpensesScaffoldPlace> placePicker = new PlacePicker<ExpensesScaffoldPlace>(
-        shell.getPlacesBox(), placeController);
-    placePicker.setPlaces(Places.getListPlacesAndNames());
-
-    // TODO Shouldn't create this until it's actually needed
+    // Left side
+ PlacePicker<EntityListPlace> placePicker = new PlacePicker<EntityListPlace>(
+        shell.getPlacesBox(), placeController, listPlaceNamer);
+    placePicker.setPlaces(places.getListPlaces());
+
+    // Shared view for entity lists. Perhaps real app would have
+    // a separate view per type?
     final TableEntityListView entitiesView = new TableEntityListView();
-
- eventBus.addHandler(PlaceChanged.TYPE, new ListRequester(shell.getBody(),
-        entitiesView, requests));
-
+    eventBus.addHandler(PlaceChanged.TYPE, new ListRequester(places,
+        shell.getBody(), entitiesView, requests, listPlaceNamer));
+
+ // Shared view for entity details. Again, perhaps real app should not share
+    final HTML detailsView = new HTML();
+ eventBus.addHandler(PlaceChanged.TYPE, new DetailsRequester(entityNamer,
+        shell.getBody(), detailsView));
+
+    // Hide the loading method
     Element loading = Document.get().getElementById("loading");
     loading.getParentElement().removeChild(loading);

=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ExpensesScaffoldShell.java Wed Mar 17 12:54:18 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ExpensesScaffoldShell.java Wed Mar 24 12:16:12 2010
@@ -18,7 +18,7 @@
 import com.google.gwt.app.client.ListBoxPlacePickerView;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.dom.client.DivElement;
-import com.google.gwt.sample.expenses.client.place.ExpensesScaffoldPlace;
+import com.google.gwt.sample.expenses.client.place.EntityListPlace;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.Composite;
@@ -34,7 +34,7 @@
   private static final Binder BINDER = GWT.create(Binder.class);

   @UiField SimplePanel body;
-  @UiField ListBoxPlacePickerView<ExpensesScaffoldPlace> placesBox;
+  @UiField ListBoxPlacePickerView<EntityListPlace> placesBox;
   @UiField DivElement error;

   public ExpensesScaffoldShell() {
@@ -51,7 +51,7 @@
   /**
    * @return the banner
    */
-  public ListBoxPlacePickerView<ExpensesScaffoldPlace> getPlacesBox() {
+  public ListBoxPlacePickerView<EntityListPlace> getPlacesBox() {
     return placesBox;
   }

=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ListRequester.java Fri Mar 19 10:26:09 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/ListRequester.java Wed Mar 24 12:16:12 2010
@@ -15,13 +15,15 @@
  */
 package com.google.gwt.sample.expenses.client;

-import com.google.gwt.app.place.Place;
 import com.google.gwt.app.place.PlaceChanged;
 import com.google.gwt.sample.expenses.client.place.EntityListPlace;
 import com.google.gwt.sample.expenses.client.place.Places;
 import com.google.gwt.sample.expenses.shared.EmployeeKey;
 import com.google.gwt.sample.expenses.shared.ExpenseRequestFactory;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityVisitor;
 import com.google.gwt.sample.expenses.shared.ReportKey;
+import com.google.gwt.user.client.ui.Renderer;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.valuestore.shared.Property;

@@ -29,60 +31,73 @@
 import java.util.List;

 /**
- * In charge of requesting and displaying the appropriate entity lists
- * when the user goes to an {...@link EntityListPlace}.
+ * In charge of requesting and displaying the appropriate entity lists when the
+ * user goes to an {...@link EntityListPlace}.
  */
 public final class ListRequester implements PlaceChanged.Handler {

   private final SimplePanel panel;
   private final TableEntityListView entitiesView;
-  private final List<Property<ReportKey, ?>> reportColumns;
   private final ExpenseRequestFactory requests;
-  private final List<Property<EmployeeKey, ?>> employeeColumns;
-
-  /**
-   * @param shell
-   * @param entitiesView
-   * @param requests
-   */
-  public ListRequester(SimplePanel panel, TableEntityListView entitiesView,
-      ExpenseRequestFactory requests) {
+  private final Renderer<EntityListPlace> listNameFilter;
+  private final Places places;
+
+  public ListRequester(Places places, SimplePanel panel,
+      TableEntityListView entitiesView, ExpenseRequestFactory requests,
+      Renderer<EntityListPlace> renderer) {
+    this.places = places;
     this.panel = panel;
     this.entitiesView = entitiesView;
     this.requests = requests;
-
-    employeeColumns = new ArrayList<Property<EmployeeKey, ?>>();
-    employeeColumns.add(EmployeeKey.get().getUserName());
-    employeeColumns.add(EmployeeKey.get().getDisplayName());
-
-    reportColumns = new ArrayList<Property<ReportKey, ?>>();
-    reportColumns.add(ReportKey.get().getCreated());
-    reportColumns.add(ReportKey.get().getPurpose());
+    this.listNameFilter = renderer;
   }

   public void onPlaceChanged(PlaceChanged event) {
-    // TODO all this "instanceof" and "if else" stuff is not so great
-
-    Place newPlace = event.getNewPlace();
-    if (!(newPlace instanceof EntityListPlace)) {
+    if (!(event.getNewPlace() instanceof EntityListPlace)) {
       return;
     }
+    EntityListPlace newPlace = (EntityListPlace) event.getNewPlace();
+    final String name = listNameFilter.render(newPlace);
+
+    final ExpensesEntityKey<?> key = newPlace.getKey();
+
+    // TODO Would be simpler if every entity key knew its find method
+    key.accept(new ExpensesEntityVisitor() {
+
+      public void visit(EmployeeKey employeeKey) {
+        List<Property<EmployeeKey, ?>> columns = getEmployeeColumns();
+ EntityListPresenter<EmployeeKey> presenter = new EntityListPresenter<EmployeeKey>(
+            name, entitiesView, columns, places);
+ requests.employeeRequest().findAllEmployees().forProperties(columns).to(
+            presenter).fire();
+      }
+
+      public void visit(ReportKey reportKey) {
+        List<Property<ReportKey, ?>> columns = getReportColumns();
+ EntityListPresenter<ReportKey> presenter = new EntityListPresenter<ReportKey>(
+            name, entitiesView, columns, places);
+ requests.reportRequest().findAllReports().forProperties(columns).to(
+            presenter).fire();
+      }
+    });

     if (entitiesView.getParent() == null) {
       panel.clear();
       panel.add(entitiesView);
     }
-
-    if (newPlace == Places.EMPLOYEE_LIST) {
- EntityList<EmployeeKey> list = new EntityList<EmployeeKey>("Employees",
-          entitiesView, employeeColumns);
-      requests.employeeRequest().findAllEmployees().forProperties(
-          employeeColumns).to(list).fire();
-    } else if (newPlace == Places.REPORT_LIST) {
-      EntityList<ReportKey> list = new EntityList<ReportKey>("Reports",
-          entitiesView, reportColumns);
- requests.reportRequest().findAllReports().forProperties(reportColumns).to(
-          list).fire();
-    }
+  }
+
+  private List<Property<EmployeeKey, ?>> getEmployeeColumns() {
+ List<Property<EmployeeKey, ?>> columns = new ArrayList<Property<EmployeeKey, ?>>();
+    columns.add(EmployeeKey.get().getUserName());
+    columns.add(EmployeeKey.get().getDisplayName());
+    return columns;
+  }
+
+  private List<Property<ReportKey, ?>> getReportColumns() {
+ List<Property<ReportKey, ?>> columns = new ArrayList<Property<ReportKey, ?>>();
+    columns.add(ReportKey.get().getCreated());
+    columns.add(ReportKey.get().getPurpose());
+    return columns;
   }
 }
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/TableEntityListView.java Wed Mar 17 12:54:18 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/TableEntityListView.java Wed Mar 24 12:16:12 2010
@@ -18,12 +18,15 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.EventTarget;
 import com.google.gwt.dom.client.HeadingElement;
 import com.google.gwt.dom.client.NodeList;
 import com.google.gwt.dom.client.TableCellElement;
 import com.google.gwt.dom.client.TableColElement;
 import com.google.gwt.dom.client.TableElement;
 import com.google.gwt.dom.client.TableRowElement;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.Widget;
@@ -31,7 +34,8 @@
 import java.util.List;

 /**
- * Interim table based implementation of {...@link EntityListView}.
+ * Interim table based implementation of {...@link EntityListView}. Will be replaced + * by some descendant of {...@link com.google.gwt.bikeshed.list.client.PagingTableListView<}
  */
 public class TableEntityListView extends Widget implements EntityListView {
   interface Binder extends UiBinder<Element, TableEntityListView> {
@@ -44,8 +48,27 @@
   @UiField TableRowElement header;
   @UiField TableElement table;

+  private List<Row> values;
+
   public TableEntityListView() {
     setElement(BINDER.createAndBindUi(this));
+    addDomHandler(new ClickHandler() {
+
+      public void onClick(ClickEvent event) {
+        EventTarget target = event.getNativeEvent().getEventTarget();
+        if (Element.is(target)) {
+          Element e = Element.as(target);
+          String tagName = e.getTagName().toLowerCase();
+          if ("td".equals(tagName)) {
+            TableCellElement cell = TableCellElement.as(e);
+ int rowIndex = TableRowElement.as(cell.getParentElement()).getRowIndex();
+//            int cellIndex = cell.getCellIndex();
+            values.get(rowIndex - 1).getShowDetailsCommand().execute();
+          }
+        }
+      }
+
+    }, ClickEvent.getType());
   }

   public void setColumnNames(List<String> names) {
@@ -59,12 +82,13 @@
     heading.setInnerText(text);
   }

-  public void setValues(List<List<String>> newValues) {
+  public void setRowData(List<Row> newValues) {
+    this.values = newValues;
     int r = 1; // skip header
     NodeList<TableRowElement> tableRows = table.getRows();

     for (int i = 0; i < newValues.size(); i++) {
-      List<String> valueRow = newValues.get(i);
+      List<String> valueRow = newValues.get(i).getValues();

       if (r < tableRows.getLength()) {
         reuseRow(r, tableRows, valueRow);
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/EntityListPlace.java Mon Mar 22 05:12:31 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/EntityListPlace.java Wed Mar 24 12:16:12 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- *
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
  * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,16 +15,22 @@
  */
 package com.google.gwt.sample.expenses.client.place;

+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+
 /**
  * Place in the app that lists all Entities of a type.
  */
-public class EntityListPlace extends ExpensesScaffoldPlace {
-
-  public void accept(ExpensesScaffoldPlaceVisitor visitor) {
-    visitor.visit(this);
-  }
-
-  public <T> T accept(ExpensesScaffoldPlaceFilter<T> filter) {
-    return filter.filter(this);
+public class EntityListPlace extends AbstractExpensesPlace {
+  private final ExpensesEntityKey<?> key;
+
+  /**
+   * @param key the schema of the entities at this place
+   */
+  public EntityListPlace(ExpensesEntityKey<?> key) {
+    this.key = key;
+  }
+
+  public ExpensesEntityKey<?> getKey() {
+    return key;
   }
 }
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/Places.java Fri Mar 19 10:26:09 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/client/place/Places.java Wed Mar 24 12:16:12 2010
@@ -15,34 +15,43 @@
  */
 package com.google.gwt.sample.expenses.client.place;

-import java.util.LinkedHashMap;
-import java.util.Map;
+import com.google.gwt.app.place.GoToPlaceCommand;
+import com.google.gwt.app.place.PlaceController;
+import com.google.gwt.sample.expenses.shared.EmployeeKey;
+import com.google.gwt.sample.expenses.shared.ExpensesEntityKey;
+import com.google.gwt.sample.expenses.shared.ReportKey;
+import com.google.gwt.valuestore.shared.Values;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;

 /**
- * The places of the ExpensesScaffold app.
+ * Object with knowledge of the places of the ExpensesScaffold app.
  */
 public class Places {
- public static final EntityListPlace EMPLOYEE_LIST = new EntityListPlace();
-  public static final EntityListPlace REPORT_LIST = new EntityListPlace();
-
-  /**
- * @return the set of places to see lists of entities, and their localized
-   *         names
-   */
-  public static Map<EntityListPlace, String> getListPlacesAndNames() {
- // TODO: i18n, get the Strings from a Messages interface. Really, names don't belong
-    // in this class at all.
- Map<EntityListPlace, String> navPlaces = new LinkedHashMap<EntityListPlace, String>();
-    navPlaces.put(EMPLOYEE_LIST, "Employees");
-    navPlaces.put(REPORT_LIST, "Reports");
-    return navPlaces;
+  private final PlaceController<AbstractExpensesPlace> controller;
+
+  private final List<EntityListPlace> listPlaces;
+
+  public Places(PlaceController<AbstractExpensesPlace> controller) {
+    this.controller = controller;
+
+    ArrayList<EntityListPlace> places = new ArrayList<EntityListPlace>();
+    places.add(new EntityListPlace(EmployeeKey.get()));
+    places.add(new EntityListPlace(ReportKey.get()));
+    listPlaces = Collections.unmodifiableList(places);
+  }
+
+ public GoToPlaceCommand<EntityDetailsPlace> getGoToDetailsFor(Values<? extends ExpensesEntityKey<?>> e) { + return new GoToPlaceCommand<EntityDetailsPlace>(new EntityDetailsPlace(e), controller);
   }

-//  public EntityDetailsPlace getDetailsPlaceFor(ExpensesEntity<?> e) {
-//    return new EntityDetailsPlace(e);
-//  }
-//
-//  public EditEntityPlace getEditPlaceFor(ExpensesEntity<?> e) {
-//    return new EditEntityPlace(e);
-//  }
-}
+ public GoToPlaceCommand<EditEntityPlace> getGoToEditFor(Values<? extends ExpensesEntityKey<?>> e) { + return new GoToPlaceCommand<EditEntityPlace>(new EditEntityPlace(e), controller);
+  }
+
+  public List<EntityListPlace> getListPlaces() {
+    return listPlaces;
+  }
+}
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/EmployeeKey.java Tue Mar 23 12:24:31 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/EmployeeKey.java Wed Mar 24 12:16:12 2010
@@ -15,7 +15,6 @@
  */
 package com.google.gwt.sample.expenses.shared;

-import com.google.gwt.requestfactory.shared.EntityKey;
 import com.google.gwt.requestfactory.shared.Id;
 import com.google.gwt.requestfactory.shared.LongString;
 import com.google.gwt.requestfactory.shared.Version;
@@ -32,7 +31,8 @@
  * IRL this class will be generated by a JPA-savvy tool run before
  * compilation.
  */
-public class EmployeeKey implements EntityKey<EmployeeKey> {
+
+public class EmployeeKey implements ExpensesEntityKey<EmployeeKey> {
   private static EmployeeKey instance;

   public static EmployeeKey get() {
@@ -66,6 +66,14 @@
     properties.add(userName);
     properties.add(version);
   }
+
+  public <T> T accept(ExpensesEntityFilter<T> filter) {
+    return filter.filter(this);
+  }
+
+  public void accept(ExpensesEntityVisitor visitor) {
+    visitor.visit(this);
+  }

   public Property<EmployeeKey, String> getDisplayName() {
     return displayName;
=======================================
--- /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ReportKey.java Tue Mar 23 12:24:31 2010 +++ /trunk/bikeshed/src/com/google/gwt/sample/expenses/shared/ReportKey.java Wed Mar 24 12:16:12 2010
@@ -15,7 +15,6 @@
  */
 package com.google.gwt.sample.expenses.shared;

-import com.google.gwt.requestfactory.shared.EntityKey;
 import com.google.gwt.requestfactory.shared.Id;
 import com.google.gwt.requestfactory.shared.LongString;
 import com.google.gwt.requestfactory.shared.Version;
@@ -33,7 +32,8 @@
  * IRL this class will be generated by a JPA-savvy tool run before
  * compilation.
  */
-public class ReportKey implements EntityKey<ReportKey> {
+
+public class ReportKey implements ExpensesEntityKey<ReportKey> {
   private static ReportKey instance;

   public static ReportKey get() {
@@ -63,6 +63,14 @@
     properties.add(created);
     properties.add(purpose);
   }
+
+  public <T> T accept(ExpensesEntityFilter<T> filter) {
+    return filter.filter(this);
+  }
+
+  public void accept(ExpensesEntityVisitor visitor) {
+    visitor.visit(this);
+  }

   public Property<ReportKey, Date> getCreated() {
     return created;
=======================================
--- /trunk/bikeshed/src/com/google/gwt/valuestore/client/ValuesImpl.java Fri Mar 19 10:26:09 2010 +++ /trunk/bikeshed/src/com/google/gwt/valuestore/client/ValuesImpl.java Wed Mar 24 12:16:12 2010
@@ -61,7 +61,7 @@
     return nativeGet(property);
   }

-  public native T getPropertyHolder() /*-{
+  public native T getEntityKey() /*-{
     return this['__key'];
   }-*/;

=======================================
--- /trunk/bikeshed/src/com/google/gwt/valuestore/shared/Values.java Fri Mar 19 10:26:09 2010 +++ /trunk/bikeshed/src/com/google/gwt/valuestore/shared/Values.java Wed Mar 24 12:16:12 2010
@@ -21,9 +21,7 @@
  * @param <T> value type.
  */
 public interface Values<T> {
-  // TODO At the moment this isn't actually used. If it stays unused
-  // once ValueStore is in place, delete it
-  T getPropertyHolder();
+  T getEntityKey();

   <V, P extends Property<T, V>> V get(P property);

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

To unsubscribe from this group, send email to 
google-web-toolkit-contributors+unsubscribegooglegroups.com or reply to this email with 
the words "REMOVE ME" as the subject.

Reply via email to