Revision: 7989
Author: amitman...@google.com
Date: Mon Apr 26 14:40:26 2010
Log: Updated the app code to use UiBinder for Employee/Report details and
Employee edits.
Patch by: amitmanjhi
Review by: rjrjr (desk review)
http://code.google.com/p/google-web-toolkit/source/detail?r=7989
Added:
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.ui.xml
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.ui.xml
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.ui.xml
Modified:
/branches/2.1/bikeshed/src/com/google/gwt/app/App.gwt.xml
/branches/2.1/bikeshed/src/com/google/gwt/app/place/Activity.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsActivity.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.ui.xml
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsActivity.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditActivity.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportListView.java
=======================================
--- /dev/null
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.java
Mon Apr 26 14:40:26 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.gwt.ui.employee;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.sample.expenses.gwt.request.EmployeeRecord;
+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.HTMLPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Details view for employee records.
+ */
+public class EmployeeDetailsView extends Composite implements
EmployeeDetailsActivity.View {
+ interface Binder extends UiBinder<HTMLPanel, EmployeeDetailsView> {
+ }
+
+ private static final Binder BINDER = GWT.create(Binder.class);
+
+ @UiField
+ SpanElement displayName;
+ @UiField
+ SpanElement userName;
+ @UiField
+ SpanElement idSpan;
+
+ public EmployeeDetailsView() {
+ initWidget(BINDER.createAndBindUi(this));
+ }
+
+ public Widget asWidget() {
+ return this;
+ }
+
+ public void setValue(EmployeeRecord record) {
+ displayName.setInnerText(record.getDisplayName());
+ userName.setInnerText(record.getUserName());
+ idSpan.setInnerText(record.getId());
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.ui.xml
Mon Apr 26 14:40:26 2010
@@ -0,0 +1,11 @@
+<!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'>
+ <g:HTMLPanel>
+ <h3><ui:msg>Employee <span ui:field='idSpan' /></ui:msg></h3>
+
+ <div><span>User Name:</span> <span ui:field='userName'></span></div>
+ <span>Display Name:</span> <span ui:field='displayName'></span>
+
+ </g:HTMLPanel>
+</ui:UiBinder>
=======================================
--- /dev/null
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.java
Mon Apr 26 14:40:26 2010
@@ -0,0 +1,60 @@
+/*
+ * 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.gwt.ui.report;
+
+import com.google.gwt.app.util.DateTimeFormatRenderer;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.sample.expenses.gwt.request.ReportRecord;
+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.HTMLPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Details view for employee records.
+ */
+public class ReportDetailsView extends Composite implements
ReportDetailsActivity.View {
+ interface Binder extends UiBinder<HTMLPanel, ReportDetailsView> {
+ }
+
+ private static final Binder BINDER = GWT.create(Binder.class);
+
+ @UiField
+ SpanElement purpose;
+ @UiField
+ SpanElement created;
+ @UiField
+ SpanElement idSpan;
+
+ public ReportDetailsView() {
+ initWidget(BINDER.createAndBindUi(this));
+ }
+
+ public Widget asWidget() {
+ return this;
+ }
+
+ public void setValue(ReportRecord record) {
+ purpose.setInnerText(record.getPurpose());
+ created.setInnerText(new DateTimeFormatRenderer(
+ DateTimeFormat.getShortDateFormat()).render(record.getCreated()));
+ idSpan.setInnerText(record.getId());
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.ui.xml
Mon Apr 26 14:40:26 2010
@@ -0,0 +1,11 @@
+<!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'>
+ <g:HTMLPanel>
+ <h3><ui:msg>Report <span ui:field='idSpan' /></ui:msg></h3>
+
+ <div><span>Purpose:</span> <span ui:field='purpose'></span></div>
+ <span>Created:</span> <span ui:field='created'></span>
+
+ </g:HTMLPanel>
+</ui:UiBinder>
=======================================
--- /dev/null
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.java
Mon Apr 26 14:40:26 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.gwt.ui.report;
+
+import com.google.gwt.app.util.DateTimeFormatRenderer;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.sample.expenses.gwt.request.ReportRecord;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.valuestore.shared.DeltaValueStore;
+import com.google.gwt.valuestore.shared.Property;
+import com.google.gwt.valuestore.ui.RecordEditView;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Edit view for employee records.
+ */
+public class ReportEditView extends Composite implements
+ RecordEditView<ReportRecord> {
+ interface Binder extends UiBinder<HTMLPanel, ReportEditView> {
+ }
+
+ private static final Binder BINDER = GWT.create(Binder.class);
+
+ @UiField
+ TextBox purpose;
+ @UiField
+ SpanElement created; //TODO: use a DatePicker
+ @UiField
+ Button save;
+ @UiField
+ SpanElement idSpan;
+
+ private Delegate delegate;
+ private DeltaValueStore deltas;
+
+ private ReportRecord record;
+
+ public ReportEditView() {
+ initWidget(BINDER.createAndBindUi(this));
+ }
+
+ public ReportEditView asWidget() {
+ return this;
+ }
+
+ public Set<Property<?>> getProperties() {
+ Set<Property<?>> rtn = new HashSet<Property<?>>();
+ rtn.add(ReportRecord.purpose);
+ rtn.add(ReportRecord.created);
+ return rtn;
+ }
+
+ public void setDelegate(Delegate delegate) {
+ this.delegate = delegate;
+ }
+
+ public void setDeltaValueStore(DeltaValueStore deltas) {
+ this.deltas = deltas;
+ }
+
+ public void setEnabled(boolean enabled) {
+ purpose.setEnabled(enabled);
+ save.setEnabled(enabled);
+ }
+
+ public void setValue(ReportRecord value) {
+ this.record = value;
+ purpose.setValue(record.getPurpose());
+ created.setInnerText(new DateTimeFormatRenderer(
+ DateTimeFormat.getShortDateFormat()).render(record.getCreated()));
+ idSpan.setInnerText(record.getId());
+ }
+
+ @UiHandler("purpose")
+ void onPurposeChange(ValueChangeEvent<String> event) {
+ deltas.set(ReportRecord.purpose, record, event.getValue());
+ }
+
+ @UiHandler("save")
+ void onSave(@SuppressWarnings("unused") ClickEvent event) {
+ delegate.saveClicked();
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.ui.xml
Mon Apr 26 14:40:26 2010
@@ -0,0 +1,12 @@
+<!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' >
+ <g:HTMLPanel>
+ <h3><ui:msg>Edit Report<span ui:field='idSpan' /></ui:msg></h3>
+
+ <span>Purpose:</span> <g:TextBox ui:field='purpose'></g:TextBox>
+ <span>Created:</span> <span ui:field='created'></span>
+
+ <g:Button ui:field='save'>Save</g:Button>
+ </g:HTMLPanel>
+</ui:UiBinder>
=======================================
--- /branches/2.1/bikeshed/src/com/google/gwt/app/App.gwt.xml Mon Apr 26
13:43:11 2010
+++ /branches/2.1/bikeshed/src/com/google/gwt/app/App.gwt.xml Mon Apr 26
14:40:26 2010
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Could not determine the version of your GWT SDK; using the module DTD
from GWT 1.6.4. You may want to change this. -->
-<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit
1.6.4//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd">
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit
0.0.999//EN" "http://google-web-toolkit.googlecode.com/svn/tags/0.0.999/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.valuestore.ValueStore'/>
- <source path="misc"/>
<source path="place"/>
<source path="client"/>
<source path="util"/>
=======================================
--- /branches/2.1/bikeshed/src/com/google/gwt/app/place/Activity.java Mon
Apr 26 09:13:06 2010
+++ /branches/2.1/bikeshed/src/com/google/gwt/app/place/Activity.java Mon
Apr 26 14:40:26 2010
@@ -37,19 +37,19 @@
* Called when {...@link #start} has not yet replied to its callback, but
the
* user has lost interest.
*/
- public void onCancel();
+ void onCancel();
/**
* Called when the Activity's widget has been removed from view.
*/
- public void onStop();
+ void onStop();
/**
* Called when the Activity should prepare its {...@link Widget} to the
user.
*
* @param callback allows the widget to be presented asynchronously
*/
- public void start(Callback callback);
-
- public boolean willStop();
-}
+ void start(Callback callback);
+
+ boolean willStop();
+}
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsActivity.java
Mon Apr 26 09:13:06 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsActivity.java
Mon Apr 26 14:40:26 2010
@@ -16,51 +16,58 @@
package com.google.gwt.sample.expenses.gwt.ui.employee;
import com.google.gwt.app.place.AbstractActivity;
+import com.google.gwt.app.util.IsWidget;
import com.google.gwt.sample.expenses.gwt.request.EmployeeRecord;
import com.google.gwt.sample.expenses.gwt.request.ExpensesRequestFactory;
-import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.TakesValue;
import com.google.gwt.user.client.ui.TakesValueList;
import com.google.gwt.valuestore.shared.Value;
import java.util.List;
/**
- * An {...@link com.google.gwt.app.place.Activity Activity} that requests and
displays detailed information on a
- * given employee.
+ * An {...@link com.google.gwt.app.place.Activity Activity} that requests and
+ * displays detailed information on a given employee.
*/
public class EmployeeDetailsActivity extends AbstractActivity {
class RequestCallBack implements TakesValueList<EmployeeRecord> {
public void setValueList(List<EmployeeRecord> listOfOne) {
- EmployeeRecord record = listOfOne.get(0);
-
- StringBuilder list = new StringBuilder("<h3>Employee " +
record.getId()
- + "</h3>");
-
- String user = record.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 = record.getDisplayName();
- list.append("<label>").append("Display Name: ").append("</label>");
- list.append("<span>").append(display).append("</span>");
- list.append("</div>");
-
- callback.onStarted(new HTML(list.toString()));
- }
+ view.setValue(listOfOne.get(0));
+ callback.onStarted(view.asWidget());
+ }
+ }
+
+ interface View extends TakesValue<EmployeeRecord>, IsWidget {
+ }
+
+ private static View defaultView;
+
+ private static View getDefaultView() {
+ if (defaultView == null) {
+ defaultView = new EmployeeDetailsView();
+ }
+ return defaultView;
}
private final ExpensesRequestFactory requests;
-
+ private final View view;
private String id;
-
private Callback callback;
+ /**
+ * Creates an activity that uses the default singleton view instance.
+ */
public EmployeeDetailsActivity(String id, ExpensesRequestFactory
requests) {
- this.requests = requests;
+ this(id, requests, getDefaultView());
+ }
+
+ /**
+ * Creates an activity that uses its own view instance.
+ */
+ public EmployeeDetailsActivity(String id, ExpensesRequestFactory
requests, View view) {
this.id = id;
+ this.requests = requests;
+ this.view = view;
}
public void start(Callback callback) {
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.ui.xml
Mon Apr 26 09:13:06 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.ui.xml
Mon Apr 26 14:40:26 2010
@@ -1,6 +1,6 @@
<!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:b='urn:import:com.google.gwt.bikeshed.list.client'>
+ xmlns:g='urn:import:com.google.gwt.user.client.ui' >
<g:HTMLPanel>
<h3><ui:msg>Edit Employee <span ui:field='idSpan' /></ui:msg></h3>
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsActivity.java
Mon Apr 26 09:13:06 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsActivity.java
Mon Apr 26 14:40:26 2010
@@ -16,9 +16,10 @@
package com.google.gwt.sample.expenses.gwt.ui.report;
import com.google.gwt.app.place.AbstractActivity;
+import com.google.gwt.app.util.IsWidget;
import com.google.gwt.sample.expenses.gwt.request.ExpensesRequestFactory;
import com.google.gwt.sample.expenses.gwt.request.ReportRecord;
-import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.TakesValue;
import com.google.gwt.user.client.ui.TakesValueList;
import com.google.gwt.valuestore.shared.Value;
@@ -31,36 +32,42 @@
public class ReportDetailsActivity extends AbstractActivity {
class RequestCallBack implements TakesValueList<ReportRecord> {
public void setValueList(List<ReportRecord> listOfOne) {
- ReportRecord record = listOfOne.get(0);
-
- StringBuilder list = new StringBuilder("<h3>Employee " +
record.getId()
- + "</h3>");
-
- String purpose = record.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 = record.getCreated().toString();
- list.append("<label>").append("Created: ").append("</label>");
- list.append("<span>").append(created).append("</span>");
- list.append("</div>");
-
- callback.onStarted(new HTML(list.toString()));
- }
+ view.setValue(listOfOne.get(0));
+ callback.onStarted(view.asWidget());
+ }
+ }
+
+ interface View extends TakesValue<ReportRecord>, IsWidget {
+ }
+
+ private static ReportDetailsView defaultView;
+
+ private static ReportDetailsView getDefaultView() {
+ if (defaultView == null) {
+ defaultView = new ReportDetailsView();
+ }
+ return defaultView;
}
private final ExpensesRequestFactory requests;
-
+ private final View view;
private String id;
-
private Callback callback;
+ /**
+ * Creates an activity that uses the default singleton view instance.
+ */
public ReportDetailsActivity(String id, ExpensesRequestFactory requests)
{
- this.requests = requests;
+ this(id, requests, getDefaultView());
+ }
+
+ /**
+ * Creates an activity that uses its own view instance.
+ */
+ public ReportDetailsActivity(String id, ExpensesRequestFactory requests,
View view) {
this.id = id;
+ this.requests = requests;
+ this.view = view;
}
public void start(Callback callback) {
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditActivity.java
Mon Apr 26 09:13:06 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditActivity.java
Mon Apr 26 14:40:26 2010
@@ -18,22 +18,92 @@
import com.google.gwt.app.place.AbstractActivity;
import com.google.gwt.app.place.PlaceController;
import com.google.gwt.sample.expenses.gwt.request.ExpensesRequestFactory;
+import com.google.gwt.sample.expenses.gwt.request.ReportRecord;
+import com.google.gwt.sample.expenses.gwt.scaffold.place.ListScaffoldPlace;
import com.google.gwt.sample.expenses.gwt.scaffold.place.ScaffoldPlace;
-import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.TakesValueList;
+import com.google.gwt.valuestore.shared.DeltaValueStore;
+import com.google.gwt.valuestore.shared.Value;
+import com.google.gwt.valuestore.ui.RecordEditView;
+
+import java.util.List;
/**
* An activity that requests all info on a report, allows the user to edit
it,
* and persists the results.
*/
-public class ReportEditActivity extends AbstractActivity {
-
+public class ReportEditActivity extends AbstractActivity implements
+ RecordEditView.Delegate {
+ class RequestCallBack implements TakesValueList<ReportRecord> {
+ public void setValueList(List<ReportRecord> listOfOne) {
+ view.setEnabled(true);
+ ReportRecord record = listOfOne.get(0);
+ view.setValue(record);
+ callback.onStarted(view.asWidget());
+ }
+ }
+
+ private static RecordEditView<ReportRecord> defaultView;
+
+ private static RecordEditView<ReportRecord> getDefaultView() {
+ if (defaultView == null) {
+ defaultView = new ReportEditView();
+ }
+ return defaultView;
+ }
+
+ private final ExpensesRequestFactory requests;
+ private final RecordEditView<ReportRecord> view;
+ private final String id;
+ private final PlaceController<ScaffoldPlace> placeController;
+
+ private DeltaValueStore deltas;
+ private Callback callback;
+
+ /**
+ * Creates an activity that uses the default singleton view instance.
+ */
public ReportEditActivity(String id, ExpensesRequestFactory requests,
PlaceController<ScaffoldPlace> placeController) {
- // TODO Auto-generated constructor stub
+ this(id, getDefaultView(), requests, placeController);
+ }
+
+ /**
+ * Creates an activity that uses its own view instance.
+ */
+ public ReportEditActivity(String id, RecordEditView<ReportRecord> view,
+ ExpensesRequestFactory requests,
+ PlaceController<ScaffoldPlace> placeController) {
+ this.requests = requests;
+ this.id = id;
+ this.view = view;
+ this.deltas = requests.getValueStore().spawnDeltaView();
+ this.placeController = placeController;
+ view.setDelegate(this);
+ view.setDeltaValueStore(deltas);
+ }
+
+ public void saveClicked() {
+ if (deltas.isChanged()) {
+ view.setEnabled(false);
+ DeltaValueStore toCommit = deltas;
+ deltas = null;
+ requests.syncRequest(toCommit).fire(); // TODO Need callback, idiot
+ placeController.goTo(new ListScaffoldPlace(ReportRecord.class));
+ }
}
public void start(Callback callback) {
- callback.onStarted(new Label("tbd"));
+ this.callback = callback;
+ requests.reportRequest().findReport(Value.of(id)).to(
+ new RequestCallBack()).fire();
+ }
+
+ @Override
+ public boolean willStop() {
+ return deltas == null || !deltas.isChanged()
+ || Window.confirm("Dude! Really drop your edits?");
}
}
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportListView.java
Mon Apr 26 09:13:06 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportListView.java
Mon Apr 26 14:40:26 2010
@@ -46,7 +46,6 @@
public ReportListView() {
init(BINDER.createAndBindUi(this), table, getColumns());
}
-
protected List<PropertyColumn<ReportRecord, ?>> getColumns() {
// TODO These should be <g:col> elements in a <g:table> in the ui.xml
file
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors