rollback of Introduces ValueListBox, due to test failures.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8585 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/Scaffold.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/Scaffold.java
index 430426c..b4552f7 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/Scaffold.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/Scaffold.java
@@ -97,7 +97,7 @@
/* Left side lets us pick from all the types of entities */
HasConstrainedValue<ProxyListPlace> listPlacePickerView = shell.getPlacesBox();
- listPlacePickerView.setAcceptableValues(getTopPlaces());
+ listPlacePickerView.setValues(getTopPlaces());
factory.getListPlacePicker().register(eventBus, listPlacePickerView);
/*
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/ScaffoldMobile.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/ScaffoldMobile.java
index 03317ed..022b688 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/ScaffoldMobile.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/ScaffoldMobile.java
@@ -81,7 +81,7 @@
/* Left side lets us pick from all the types of entities */
HasConstrainedValue<ProxyListPlace> placePickerView = shell.getPlacesBox();
- placePickerView.setAcceptableValues(getTopPlaces());
+ placePickerView.setValues(getTopPlaces());
factory.getListPlacePicker().register(eventBus, placePickerView);
/*
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.java
index f270976..6bc8acb 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeDetailsView.java
@@ -95,7 +95,7 @@
displayName.setInnerText(record.getDisplayName());
userName.setInnerText(record.getUserName());
password.setInnerText(record.getPassword());
- supervisor.setInnerText(EmployeeRenderer.instance().render(record.getSupervisor()));
+ supervisor.setInnerText(String.valueOf(record.getSupervisor() == null ? null : record.getSupervisor().getId()));
idSpan.setInnerText(record.getId().toString());
versionSpan.setInnerText(record.getVersion().toString());
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditActivity.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditActivity.java
index 75b9e96..25bfc93 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditActivity.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditActivity.java
@@ -18,19 +18,12 @@
import com.google.gwt.app.place.AbstractRecordEditActivity;
import com.google.gwt.app.place.PlaceController;
import com.google.gwt.app.place.RecordEditView;
-import com.google.gwt.event.shared.EventBus;
import com.google.gwt.requestfactory.shared.Receiver;
import com.google.gwt.requestfactory.shared.RequestObject;
import com.google.gwt.sample.expenses.gwt.request.EmployeeRecord;
import com.google.gwt.sample.expenses.gwt.request.ExpensesRequestFactory;
-import com.google.gwt.valuestore.shared.SyncResult;
import com.google.gwt.valuestore.shared.Value;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
/**
* An activity that requests all info on an employee, allows the user to edit
* it, and persists the results.
@@ -63,32 +56,11 @@
public EmployeeEditActivity(RecordEditView<EmployeeRecord> view,
EmployeeRecord proxy, ExpensesRequestFactory requests,
PlaceController placeController, boolean creating) {
- super(view, proxy, EmployeeRecord.class, creating, requests,
- placeController);
+ super(view, proxy, EmployeeRecord.class, creating, requests, placeController);
this.requests = requests;
}
@Override
- public void start(Display display, EventBus eventBus) {
- getEmployeeEditView().setEmployeePickerValues(
- Collections.<EmployeeRecord> emptyList());
-
- requests.employeeRequest().findEmployeeEntries(0, 50).with(
- EmployeeRenderer.instance().getPaths()).fire(
- new Receiver<List<EmployeeRecord>>() {
- public void onSuccess(List<EmployeeRecord> response,
- Set<SyncResult> syncResults) {
- List<EmployeeRecord> values = new ArrayList<EmployeeRecord>();
- values.add(null);
- values.addAll(response);
- getEmployeeEditView().setEmployeePickerValues(values);
- }
-
- });
- super.start(display, eventBus);
- }
-
- @Override
protected void fireFindRequest(Value<Long> id,
Receiver<EmployeeRecord> callback) {
requests.employeeRequest().findEmployee(id).fire(callback);
@@ -97,8 +69,4 @@
protected RequestObject<Void> getPersistRequest(EmployeeRecord record) {
return requests.employeeRequest().persist(record);
}
-
- private EmployeeEditView getEmployeeEditView() {
- return ((EmployeeEditView) getView());
- }
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.java
index 729e01b..d85da94 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.java
@@ -16,6 +16,7 @@
package com.google.gwt.sample.expenses.gwt.ui.employee;
import com.google.gwt.app.client.EditorSupport;
+import com.google.gwt.app.client.LongBox;
import com.google.gwt.app.place.RecordEditView;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
@@ -31,10 +32,10 @@
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.ValueListBox;
+import com.google.gwt.valuestore.shared.Property;
-import java.util.Collection;
import java.util.Map;
+import java.util.Set;
/**
* Edit view for employee records.
@@ -50,31 +51,18 @@
private static final Binder BINDER = GWT.create(Binder.class);
private static final DataBinder DATA_BINDER = GWT.create(DataBinder.class);
- @UiField
- TextBox displayName;
- @UiField
- TextBox password;
- @UiField(provided = true)
- ValueListBox<EmployeeRecord> supervisor = new ValueListBox<EmployeeRecord>(
- EmployeeRenderer.instance());
-
- @UiField
- TextBox userName;
- @UiField
- Button cancel;
- @UiField
- Button save;
- @UiField
- InlineLabel id;
- @UiField
- InlineLabel version;
- @UiField
- DivElement errors;
-
- @UiField
- Element editTitle;
- @UiField
- Element createTitle;
+ @UiField TextBox displayName;
+ @UiField TextBox password;
+ @UiField LongBox supervisorKey;
+ @UiField TextBox userName;
+ @UiField Button cancel;
+ @UiField Button save;
+ @UiField InlineLabel id;
+ @UiField InlineLabel version;
+ @UiField DivElement errors;
+
+ @UiField Element editTitle;
+ @UiField Element createTitle;
private Delegate delegate;
private EmployeeRecord record;
@@ -88,8 +76,8 @@
return this;
}
- public String[] getPaths() {
- return DATA_BINDER.getPaths();
+ public Set<Property<?>> getProperties() {
+ return DATA_BINDER.getProperties();
}
public EmployeeRecord getValue() {
@@ -114,10 +102,6 @@
this.delegate = delegate;
}
- public void setEmployeePickerValues(Collection<EmployeeRecord> values) {
- supervisor.setAcceptableValues(values);
- }
-
public void setEnabled(boolean enabled) {
DATA_BINDER.setEnabled(this, enabled);
save.setEnabled(enabled);
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.ui.xml b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.ui.xml
index 1f836af..ccfba3e 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.ui.xml
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeEditView.ui.xml
@@ -40,7 +40,7 @@
<table class='{style.fields}'>
<tr><td><div class='{style.label}'>Display Name:</div></td><td><g:TextBox ui:field='displayName'></g:TextBox></td></tr>
<tr><td><div class='{style.label}'>User Name:</div></td><td><g:TextBox ui:field='userName'></g:TextBox></td></tr>
- <tr><td><div class='{style.label}'>Supervisor:</div></td><td><g:ValueListBox ui:field='supervisor'></g:ValueListBox></td></tr>
+ <tr><td><div class='{style.label}'>Supervisor Key:</div></td><td><a:LongBox ui:field='supervisorKey'></a:LongBox></td></tr>
<tr><td><div class='{style.label}'>Password:</div></td><td><g:PasswordTextBox ui:field='password'></g:PasswordTextBox></td></tr>
</table>
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeListView.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeListView.java
index 523ad87..e481300 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeListView.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeListView.java
@@ -15,6 +15,7 @@
*/
package com.google.gwt.sample.expenses.gwt.ui.employee;
+import com.google.gwt.app.client.ProxyIdRenderer;
import com.google.gwt.app.place.AbstractRecordListView;
import com.google.gwt.app.place.PropertyColumn;
import com.google.gwt.core.client.GWT;
@@ -50,14 +51,10 @@
List<PropertyColumn<EmployeeRecord, ?>> columns = new ArrayList<PropertyColumn<EmployeeRecord, ?>>();
columns.add(PropertyColumn.<EmployeeRecord> getStringPropertyColumn(EmployeeRecord.userName));
-
columns.add(PropertyColumn.<EmployeeRecord> getStringPropertyColumn(EmployeeRecord.displayName));
-
columns.add(PropertyColumn.<EmployeeRecord> getStringPropertyColumn(EmployeeRecord.password));
-
columns.add(new PropertyColumn<EmployeeRecord, EmployeeRecord>(
- EmployeeRecord.supervisor, EmployeeRenderer.instance()));
-
+ EmployeeRecord.supervisor, ProxyIdRenderer.<EmployeeRecord>instance()));
return columns;
}
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeRenderer.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeRenderer.java
deleted file mode 100644
index b20897c..0000000
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/employee/EmployeeRenderer.java
+++ /dev/null
@@ -1,46 +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.gwt.ui.employee;
-
-import com.google.gwt.app.place.ProxyRenderer;
-import com.google.gwt.sample.expenses.gwt.request.EmployeeRecord;
-
-/**
- * Renders {@link EmployeeRecord}s for display to the user. Requires the
- * displayName property to have been fetched.
- */
-public class EmployeeRenderer extends ProxyRenderer<EmployeeRecord> {
- private static EmployeeRenderer INSTANCE;
-
- public static EmployeeRenderer instance() {
- if (INSTANCE == null) {
- INSTANCE = new EmployeeRenderer();
- }
-
- return INSTANCE;
- }
-
- protected EmployeeRenderer() {
- super(new String[] { "displayName"} );
- }
-
- public String render(EmployeeRecord object) {
- if (object == null) {
- return "";
- }
- return object.getDisplayName() + " (" + object.getId() + ")";
- }
-}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.java
index ed49bae..7c2fed6 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportDetailsView.java
@@ -22,7 +22,6 @@
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.i18n.client.DateTimeFormatRenderer;
import com.google.gwt.sample.expenses.gwt.request.ReportRecord;
-import com.google.gwt.sample.expenses.gwt.ui.employee.EmployeeRenderer;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
@@ -100,7 +99,7 @@
created.setInnerText(new DateTimeFormatRenderer().render(record.getCreated()));
idSpan.setInnerText(record.getId().toString());
versionSpan.setInnerText(record.getVersion().toString());
- reporterKey.setInnerText(EmployeeRenderer.instance().render(record.getReporter()));
- approvedSupervisorKey.setInnerText(EmployeeRenderer.instance().render(record.getApprovedSupervisor()));
+ reporterKey.setInnerText(String.valueOf(record.getReporter()));
+ approvedSupervisorKey.setInnerText(String.valueOf(record.getApprovedSupervisor()));
}
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditActivity.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditActivity.java
index 91586c6..572fe9f 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditActivity.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditActivity.java
@@ -18,21 +18,12 @@
import com.google.gwt.app.place.AbstractRecordEditActivity;
import com.google.gwt.app.place.PlaceController;
import com.google.gwt.app.place.RecordEditView;
-import com.google.gwt.event.shared.EventBus;
import com.google.gwt.requestfactory.shared.Receiver;
import com.google.gwt.requestfactory.shared.RequestObject;
-import com.google.gwt.sample.expenses.gwt.request.EmployeeRecord;
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.ui.employee.EmployeeRenderer;
-import com.google.gwt.valuestore.shared.SyncResult;
import com.google.gwt.valuestore.shared.Value;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
/**
* An activity that requests all info on a report, allows the user to edit it,
* and persists the results.
@@ -68,26 +59,7 @@
super(view, proxy, ReportRecord.class, creating, requests, placeController);
this.requests = requests;
}
- @Override
- public void start(Display display, EventBus eventBus) {
- getReportEditView().setEmployeePickerValues(
- Collections.<EmployeeRecord> emptyList());
-
- requests.employeeRequest().findEmployeeEntries(0, 50).with(
- EmployeeRenderer.instance().getPaths()).fire(
- new Receiver<List<EmployeeRecord>>() {
- public void onSuccess(List<EmployeeRecord> response,
- Set<SyncResult> syncResults) {
- List<EmployeeRecord> values = new ArrayList<EmployeeRecord>();
- values.add(null);
- values.addAll(response);
- getReportEditView().setEmployeePickerValues(values);
- }
- });
- super.start(display, eventBus);
- }
-
@Override
protected void fireFindRequest(Value<Long> id, Receiver<ReportRecord> callback) {
requests.reportRequest().findReport(id).fire(callback);
@@ -96,8 +68,4 @@
protected RequestObject<Void> getPersistRequest(ReportRecord record) {
return requests.reportRequest().persist(record);
}
-
- private ReportEditView getReportEditView() {
- return ((ReportEditView) getView());
- }
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.java
index 1b85958..c0a5dfb 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.java
@@ -16,15 +16,14 @@
package com.google.gwt.sample.expenses.gwt.ui.report;
import com.google.gwt.app.client.EditorSupport;
+import com.google.gwt.app.client.LongBox;
import com.google.gwt.app.place.RecordEditView;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.sample.expenses.gwt.request.EmployeeRecord;
import com.google.gwt.sample.expenses.gwt.request.ReportRecord;
-import com.google.gwt.sample.expenses.gwt.ui.employee.EmployeeRenderer;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
@@ -33,11 +32,11 @@
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.ValueListBox;
import com.google.gwt.user.datepicker.client.DateBox;
+import com.google.gwt.valuestore.shared.Property;
-import java.util.Collection;
import java.util.Map;
+import java.util.Set;
/**
* Edit view for employee records.
@@ -55,10 +54,8 @@
@UiField TextBox notes;
@UiField TextBox purpose;
- @UiField(provided = true) ValueListBox<EmployeeRecord> reporter =
- new ValueListBox<EmployeeRecord>(EmployeeRenderer.instance());
- @UiField(provided = true) ValueListBox<EmployeeRecord> approvedSupervisor =
- new ValueListBox<EmployeeRecord>(EmployeeRenderer.instance());
+ @UiField LongBox reporterKey;
+ @UiField LongBox approvedSupervisorKey;
@UiField DateBox created;
@UiField Button cancel;
@UiField Button save;
@@ -71,18 +68,18 @@
private Delegate delegate;
private ReportRecord record;
-
+
public ReportEditView() {
initWidget(BINDER.createAndBindUi(this));
DATA_BINDER.init(this);
}
-
+
public ReportEditView asWidget() {
return this;
}
- public String[] getPaths() {
- return DATA_BINDER.getPaths();
+ public Set<Property<?>> getProperties() {
+ return DATA_BINDER.getProperties();
}
public ReportRecord getValue() {
@@ -107,11 +104,6 @@
this.delegate = delegate;
}
- public void setEmployeePickerValues(Collection<EmployeeRecord> values) {
- approvedSupervisor.setAcceptableValues(values);
- reporter.setAcceptableValues(values);
- }
-
public void setEnabled(boolean enabled) {
DATA_BINDER.setEnabled(this, enabled);
save.setEnabled(enabled);
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.ui.xml b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.ui.xml
index 98c8743..2120839 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.ui.xml
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportEditView.ui.xml
@@ -42,8 +42,8 @@
<tr><td><div class='{style.label}'>Purpose:</div></td><td><g:TextBox ui:field='purpose'></g:TextBox></td></tr>
<tr><td><div class='{style.label}'>Notes:</div></td><td><g:TextBox ui:field='notes'></g:TextBox></td></tr>
<tr><td><div class='{style.label}'>Created:</div></td><td><d:DateBox ui:field='created'></d:DateBox></td></tr>
- <tr><td><div class='{style.label}'>Reporter:</div></td><td><g:ValueListBox ui:field='reporter'></g:ValueListBox></td></tr>
- <tr><td><div class='{style.label}'>Approved Supervisor:</div></td><td><g:ValueListBox ui:field='approvedSupervisor'></g:ValueListBox></td></tr>
+ <tr><td><div class='{style.label}'>Reporter Key:</div></td><td><a:LongBox ui:field='reporterKey'></a:LongBox></td></tr>
+ <tr><td><div class='{style.label}'>Approved Supervisor Key:</div></td><td><a:LongBox ui:field='approvedSupervisorKey'></a:LongBox></td></tr>
</table>
<div class='{style.bar}'>
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportListView.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportListView.java
index 302fd15..0c4c0ac 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportListView.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/ui/report/ReportListView.java
@@ -15,6 +15,7 @@
*/
package com.google.gwt.sample.expenses.gwt.ui.report;
+import com.google.gwt.app.client.ProxyIdRenderer;
import com.google.gwt.app.place.AbstractRecordListView;
import com.google.gwt.app.place.PropertyColumn;
import com.google.gwt.core.client.GWT;
@@ -22,7 +23,6 @@
import com.google.gwt.i18n.client.DateTimeFormatRenderer;
import com.google.gwt.sample.expenses.gwt.request.EmployeeRecord;
import com.google.gwt.sample.expenses.gwt.request.ReportRecord;
-import com.google.gwt.sample.expenses.gwt.ui.employee.EmployeeRenderer;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellTable;
@@ -58,15 +58,11 @@
columns.add(new PropertyColumn<ReportRecord, Date>(ReportRecord.created,
new DateTimeFormatRenderer(DateTimeFormat.getShortDateFormat())));
-
columns.add(PropertyColumn.<ReportRecord> getStringPropertyColumn(ReportRecord.purpose));
-
columns.add(new PropertyColumn<ReportRecord, EmployeeRecord>(
- ReportRecord.reporter, EmployeeRenderer.instance()));
-
+ ReportRecord.reporter, ProxyIdRenderer.<EmployeeRecord>instance()));
columns.add(new PropertyColumn<ReportRecord, EmployeeRecord>(
- ReportRecord.approvedSupervisor, EmployeeRenderer.instance()));
-
+ ReportRecord.approvedSupervisor, ProxyIdRenderer.<EmployeeRecord>instance()));
return columns;
}
}
diff --git a/user/src/com/google/gwt/app/client/EditorSupport.java b/user/src/com/google/gwt/app/client/EditorSupport.java
index 2180a85..fb26b55 100644
--- a/user/src/com/google/gwt/app/client/EditorSupport.java
+++ b/user/src/com/google/gwt/app/client/EditorSupport.java
@@ -16,9 +16,11 @@
package com.google.gwt.app.client;
import com.google.gwt.app.place.RecordEditView;
+import com.google.gwt.valuestore.shared.Property;
import com.google.gwt.valuestore.shared.Record;
import java.util.Map;
+import java.util.Set;
/**
* <p>
@@ -33,7 +35,7 @@
* @param <V> the View type
*/
public interface EditorSupport<R extends Record, V extends RecordEditView<R>> {
- String[] getPaths();
+ Set<Property<?>> getProperties();
void init(final V view);
diff --git a/user/src/com/google/gwt/app/client/ProxyBox.java b/user/src/com/google/gwt/app/client/ProxyBox.java
new file mode 100644
index 0000000..30410a9
--- /dev/null
+++ b/user/src/com/google/gwt/app/client/ProxyBox.java
@@ -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.app.client;
+
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.user.client.ui.ValueBox;
+import com.google.gwt.valuestore.shared.Record;
+
+/**
+ * <span style="color:red">Experimental API: This class is still under rapid
+ * development, and is very likely to be deleted. Use it at your own risk.
+ * </span>
+ * <p>
+ * A ValueBox that uses {@link com.google.gwt.app.client.ProxyParser} and
+ * {@link com.google.gwt.app.client.ProxyRenderer}.
+ *
+ * @param <T> a proxy record
+ */
+public class ProxyBox<T extends Record> extends ValueBox<T> {
+
+ public ProxyBox() {
+ super(Document.get().createTextInputElement(), ProxyRenderer.<T>instance(),
+ ProxyParser.<T>instance());
+ }
+
+ public T getValue() {
+ // Until a sensible ProxyParser can be written
+ return null;
+ }
+}
diff --git a/user/src/com/google/gwt/app/client/ProxyIdRenderer.java b/user/src/com/google/gwt/app/client/ProxyIdRenderer.java
new file mode 100644
index 0000000..239ecf8
--- /dev/null
+++ b/user/src/com/google/gwt/app/client/ProxyIdRenderer.java
@@ -0,0 +1,49 @@
+/*
+ * 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.client;
+
+import com.google.gwt.text.shared.AbstractRenderer;
+import com.google.gwt.text.shared.Renderer;
+import com.google.gwt.valuestore.shared.Record;
+
+/**
+ * <span style="color:red">Experimental API: This class is still under rapid
+ * development, and is very likely to be deleted. Use it at your own risk.
+ * </span>
+ * <p>
+ * Renderer of Record values
+ * @param <T> a record type
+ */
+public class ProxyIdRenderer<T extends Record> extends AbstractRenderer<T> {
+ private static ProxyIdRenderer INSTANCE;
+
+ /**
+ * @return the instance
+ */
+ public static <T extends Record> Renderer<T> instance() {
+ if (INSTANCE == null) {
+ INSTANCE = new ProxyIdRenderer<T>();
+ }
+ return INSTANCE;
+ }
+
+ protected ProxyIdRenderer() {
+ }
+
+ public String render(T object) {
+ return toString(object == null ? null : object.getId());
+ }
+}
diff --git a/user/src/com/google/gwt/app/client/ProxyParser.java b/user/src/com/google/gwt/app/client/ProxyParser.java
new file mode 100644
index 0000000..221a4f0
--- /dev/null
+++ b/user/src/com/google/gwt/app/client/ProxyParser.java
@@ -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.app.client;
+
+import com.google.gwt.text.shared.Parser;
+import com.google.gwt.valuestore.shared.Record;
+
+import java.text.ParseException;
+
+/**
+ * <span style="color:red">Experimental API: This class is still under rapid
+ * development, and is very likely to be deleted. Use it at your own risk.
+ * </span>
+ * <p>
+ * A no-op renderer.
+ * @param <T> a Record type.
+ */
+public class ProxyParser<T extends Record> implements Parser<T> {
+
+ private static ProxyParser INSTANCE;
+
+ /**
+ * @return the instance of the no-op renderer
+ */
+ public static <T extends Record> Parser<T> instance() {
+ if (INSTANCE == null) {
+ INSTANCE = new ProxyParser<T>();
+ }
+ return INSTANCE;
+ }
+
+ protected ProxyParser() {
+ }
+
+ public T parse(CharSequence object) throws ParseException {
+ try {
+ // TODO: how can we map an id back into a record synchronously? Use
+ // ValueStore?
+ return null;
+ } catch (NumberFormatException e) {
+ throw new ParseException(e.getMessage(), 0);
+ }
+ }
+}
diff --git a/user/src/com/google/gwt/app/client/ProxyRenderer.java b/user/src/com/google/gwt/app/client/ProxyRenderer.java
new file mode 100644
index 0000000..5ea3d4f
--- /dev/null
+++ b/user/src/com/google/gwt/app/client/ProxyRenderer.java
@@ -0,0 +1,49 @@
+/*
+ * 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.client;
+
+import com.google.gwt.text.shared.AbstractRenderer;
+import com.google.gwt.text.shared.Renderer;
+import com.google.gwt.valuestore.shared.Record;
+
+/**
+ * <span style="color:red">Experimental API: This class is still under rapid
+ * development, and is very likely to be deleted. Use it at your own risk.
+ * </span>
+ * <p>
+ * Renderer of Record values
+ * @param <T> a record type
+ */
+public class ProxyRenderer<T extends Record> extends AbstractRenderer<T> {
+ private static ProxyRenderer INSTANCE;
+
+ /**
+ * @return the instance
+ */
+ public static <T extends Record> Renderer<T> instance() {
+ if (INSTANCE == null) {
+ INSTANCE = new ProxyRenderer<T>();
+ }
+ return INSTANCE;
+ }
+
+ protected ProxyRenderer() {
+ }
+
+ public String render(T object) {
+ return toString(object == null ? null : object.getId());
+ }
+}
diff --git a/user/src/com/google/gwt/app/client/ReadonlyProxyBox.java b/user/src/com/google/gwt/app/client/ReadonlyProxyBox.java
new file mode 100644
index 0000000..cafe722
--- /dev/null
+++ b/user/src/com/google/gwt/app/client/ReadonlyProxyBox.java
@@ -0,0 +1,51 @@
+/*
+ * 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.client;
+
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.user.client.ui.ValueBox;
+import com.google.gwt.valuestore.shared.Record;
+
+/**
+ * <span style="color:red">Experimental API: This class is still under rapid
+ * development, and is very likely to be deleted. Use it at your own risk.
+ * </span>
+ * <p>
+ * A ValueBox that uses {@link NullParser} and
+ * {@link ProxyIdRenderer}. It is a display only placeholder class for now;
+ *
+ * @param <T> a proxy record
+ */
+public class ReadonlyProxyBox<T extends Record> extends ValueBox<T> {
+
+ private T currentValue;
+
+ public ReadonlyProxyBox() {
+ super(Document.get().createTextInputElement(), ProxyIdRenderer.<T>instance(),
+ NullParser.<T>instance());
+ setReadOnly(true);
+ }
+
+ public T getValue() {
+ // The display value cannot be modified;
+ return currentValue;
+ }
+
+ public void setValue(T value) {
+ this.currentValue = value;
+ super.setValue(value);
+ }
+}
diff --git a/user/src/com/google/gwt/app/place/AbstractRecordEditActivity.java b/user/src/com/google/gwt/app/place/AbstractRecordEditActivity.java
index a6e8ded..72cd001 100644
--- a/user/src/com/google/gwt/app/place/AbstractRecordEditActivity.java
+++ b/user/src/com/google/gwt/app/place/AbstractRecordEditActivity.java
@@ -81,10 +81,6 @@
return record;
}
- public RecordEditView<R> getView() {
- return view;
- }
-
public String mayStop() {
if (requestObject != null && requestObject.isChanged()) {
return "Are you sure you want to abandon your changes?";
@@ -92,7 +88,7 @@
return null;
}
-
+
public void onCancel() {
onStop();
}
diff --git a/user/src/com/google/gwt/app/place/AbstractRecordListActivity.java b/user/src/com/google/gwt/app/place/AbstractRecordListActivity.java
index cef8237..d13b57f 100644
--- a/user/src/com/google/gwt/app/place/AbstractRecordListActivity.java
+++ b/user/src/com/google/gwt/app/place/AbstractRecordListActivity.java
@@ -225,7 +225,7 @@
/**
* Called when the user chooses a record to view. This default implementation
* sends the {@link PlaceController} to an appropriate {@link ProxyPlace}.
- *
+ *
* @param record the chosen record
*/
protected void showDetails(R record) {
@@ -234,7 +234,7 @@
private void fireRangeRequest(final Range range,
final Receiver<List<R>> callback) {
- createRangeRequest(range).with(getView().getPaths()).fire(
+ createRangeRequest(range).forProperties(getView().getProperties()).fire(
callback);
}
diff --git a/user/src/com/google/gwt/app/place/AbstractRecordListView.java b/user/src/com/google/gwt/app/place/AbstractRecordListView.java
index 34590fd..fd33ea8 100644
--- a/user/src/com/google/gwt/app/place/AbstractRecordListView.java
+++ b/user/src/com/google/gwt/app/place/AbstractRecordListView.java
@@ -21,10 +21,10 @@
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.valuestore.shared.Property;
import com.google.gwt.valuestore.shared.Record;
import com.google.gwt.view.client.HasData;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -45,7 +45,7 @@
Composite implements RecordListView<R> {
private CellTable<R> table;
- private Set<String> paths = new HashSet<String>();
+ private Set<Property<?>> properties = new HashSet<Property<?>>();
private Delegate<R> delegate;
public HasData<R> asHasData() {
@@ -56,8 +56,8 @@
return this;
}
- public String[] getPaths() {
- return paths.toArray(new String[paths.size()]);
+ public Set<Property<?>> getProperties() {
+ return properties;
}
public void setDelegate(final Delegate<R> delegate) {
@@ -70,8 +70,8 @@
this.table = table;
for (PropertyColumn<R, ?> column : columns) {
- table.addColumn(column, column.getDisplayName());
- paths.addAll(Arrays.asList(column.getPaths()));
+ table.addColumn(column, column.getProperty().getDisplayName());
+ properties.add(column.getProperty());
}
newButton.addClickHandler(new ClickHandler() {
diff --git a/user/src/com/google/gwt/app/place/PropertyColumn.java b/user/src/com/google/gwt/app/place/PropertyColumn.java
index 66d498e..1cc44d4 100644
--- a/user/src/com/google/gwt/app/place/PropertyColumn.java
+++ b/user/src/com/google/gwt/app/place/PropertyColumn.java
@@ -27,9 +27,7 @@
* development, and is very likely to be deleted. Use it at your own risk.
* </span>
* </p>
- * A column that displays a record property as a string. NB: Property objects
- * will soon go away, and this column class will hopefully replaced by a (much
- * simpler to use) code generated system.
+ * A column that displays a record property as a string.
*
* @param <R> the type of record in this table
* @param <T> value type of the property
@@ -40,43 +38,21 @@
return new PropertyColumn<R, String>(property,
PassthroughRenderer.instance());
}
-
private final Renderer<T> renderer;
- private final Property<T> property;
- private final String[] paths;
- public PropertyColumn(Property<T> property, ProxyRenderer<T> renderer) {
- this.property = property;
- this.renderer = renderer;
- this.paths = pathinate(property, renderer);
- }
+ private final Property<T> property;
public PropertyColumn(Property<T> property, Renderer<T> renderer) {
this.property = property;
this.renderer = renderer;
- this.paths = new String[] {property.getName()};
}
- public String getDisplayName() {
- return property.getDisplayName();
- }
-
- public String[] getPaths() {
- return paths;
+ public Property<T> getProperty() {
+ return property;
}
@Override
public String getValue(R object) {
return renderer.render(object.get(property));
}
-
- private String[] pathinate(Property<T> property, ProxyRenderer<T> renderer) {
- String[] rtn = new String[renderer.getPaths().length];
- int i = 0;
- for (String rendererPath : renderer.getPaths()) {
- rtn[i++] = property.getName() + "." + rendererPath;
- }
-
- return rtn;
- }
}
diff --git a/user/src/com/google/gwt/app/place/PropertyView.java b/user/src/com/google/gwt/app/place/PropertyView.java
index 6e150f2..81f34da 100644
--- a/user/src/com/google/gwt/app/place/PropertyView.java
+++ b/user/src/com/google/gwt/app/place/PropertyView.java
@@ -15,22 +15,27 @@
*/
package com.google.gwt.app.place;
+import com.google.gwt.valuestore.shared.Property;
import com.google.gwt.valuestore.shared.Record;
+import java.util.Set;
+
/**
* <p>
* <span style="color:red">Experimental API: This class is still under rapid
* development, and is very likely to be deleted. Use it at your own risk.
* </span>
* </p>
- * A view that displays a set of property values for a type of {@link Record}.
+ * A view that displays a set of {@link Property} values for a type of
+ * {@link Record}.
*
* @param <R> the type of the record
*/
public interface PropertyView<R extends Record> {
/**
- * @return the set of properties this view displays
+ * @return the set of properties this view displays, which are guaranteed to
+ * be properties of R
*/
- String[] getPaths();
+ Set<Property<?>> getProperties();
}
diff --git a/user/src/com/google/gwt/app/place/ProxyRenderer.java b/user/src/com/google/gwt/app/place/ProxyRenderer.java
deleted file mode 100644
index 3b7ce42..0000000
--- a/user/src/com/google/gwt/app/place/ProxyRenderer.java
+++ /dev/null
@@ -1,41 +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.app.place;
-
-import com.google.gwt.text.shared.AbstractRenderer;
-
-/**
- * Renders a proxy object, and reports the properties it requires to do that
- * rendering.
- *
- * @param <R> the type to render
- */
-public abstract class ProxyRenderer<R> extends
- AbstractRenderer<R> {
-
- private final String[] paths;
-
- public ProxyRenderer(String[] strings) {
- this.paths = strings;
- }
-
- /**
- * The properties required by this renderer.
- */
- public String[] getPaths() {
- return paths;
- }
-}
diff --git a/user/src/com/google/gwt/app/rebind/EditorSupportGenerator.java b/user/src/com/google/gwt/app/rebind/EditorSupportGenerator.java
index 67cba53..d487d5d 100644
--- a/user/src/com/google/gwt/app/rebind/EditorSupportGenerator.java
+++ b/user/src/com/google/gwt/app/rebind/EditorSupportGenerator.java
@@ -183,8 +183,8 @@
String.class.getName());
jrecordType = generatorContext.getTypeOracle().findType(
Record.class.getName());
- writeGetPathsMethod(sw, recordType);
- writeInit(sw, viewType);
+ writeGetPropertiesMethod(sw, recordType);
+ writeInit(sw, viewType, recordType);
writeIsChangedMethod(sw, recordType, viewType);
writeSetEnabledMethod(sw, viewType);
writeSetValueMethod(sw, recordType, viewType, logger);
@@ -417,27 +417,28 @@
}
/**
- * Write the implementation for the getPaths() method.
+ * Write the implementation for the getProperties() method.
*/
- private void writeGetPathsMethod(SourceWriter sw, JClassType recordType) {
+ private void writeGetPropertiesMethod(SourceWriter sw, JClassType recordType) {
sw.indent();
- sw.println("public String[] getPaths() {");
+ sw.println("public Set<Property<?>> getProperties() {");
sw.indent();
- sw.println("Set<String> rtn = new HashSet<String>();");
+ sw.println("Set<Property<?>> rtn = new HashSet<Property<?>>();");
for (JField field : recordType.getFields()) {
if (field.getType().getQualifiedSourceName().equals(
Property.class.getName())) {
sw.println("rtn.add(" + recordType.getName() + "." + field.getName()
- + ".getName());");
+ + ");");
}
}
- sw.println("return rtn.toArray(new String[rtn.size()]);");
+ sw.println("return rtn;");
sw.outdent();
sw.println("}");
sw.outdent();
}
- private void writeInit(SourceWriter sw, JClassType viewType) {
+ private void writeInit(SourceWriter sw, JClassType viewType,
+ JClassType recordType) {
sw.indent();
sw.println("public void init(final " + viewType.getName() + " view) {");
sw.indent();
diff --git a/user/src/com/google/gwt/user/client/ui/HasConstrainedValue.java b/user/src/com/google/gwt/user/client/ui/HasConstrainedValue.java
index a725855..235aa26 100644
--- a/user/src/com/google/gwt/user/client/ui/HasConstrainedValue.java
+++ b/user/src/com/google/gwt/user/client/ui/HasConstrainedValue.java
@@ -19,20 +19,15 @@
/**
* Implemented by widgets that pick from a set of values.
- * <p>
- * It is up to the implementation to decide (and document) how to behave when
- * {@link #setValue(Object)} is called with a value that is not in the
- * acceptable set. For example, throwing an {@link IllegalArgumentException}, or
- * quietly adding the value to the acceptable set, are both reasonable choices.
*
* @param <T> the type of value
*/
public interface HasConstrainedValue<T> extends HasValue<T> {
/**
- * Set the acceptable values.
+ * Set the acceptible values.
*
* @param values the acceptible values
*/
- void setAcceptableValues(Collection<T> values);
+ void setValues(Collection<T> values);
}
diff --git a/user/src/com/google/gwt/user/client/ui/ValueListBox.java b/user/src/com/google/gwt/user/client/ui/ValueListBox.java
deleted file mode 100644
index 23ea523..0000000
--- a/user/src/com/google/gwt/user/client/ui/ValueListBox.java
+++ /dev/null
@@ -1,134 +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.user.client.ui;
-
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.text.shared.Renderer;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Implementation of {@link HasConstrainedValue} based on a
- * {@link com.google.gwt.dom.client.SelectElement}.
- * <p>
- * A {@link Renderer<T>} is used to get user presentable strings to display in
- * the select element. It is an error for two values to render to the same
- * string.
- *
- * @param <T> the value type
- */
-public class ValueListBox<T> extends Composite implements
- HasConstrainedValue<T> {
-
- private final List<T> values = new ArrayList<T>();
- private final Map<T, Integer> valueToIndex = new HashMap<T, Integer>();
- private final Renderer<T> renderer;
-
- private T value;
-
- public ValueListBox(Renderer<T> renderer) {
- this.renderer = renderer;
- initWidget(new ListBox());
-
- getListBox().addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- int selectedIndex = getListBox().getSelectedIndex();
-
- if (selectedIndex < 0) {
- return; // Not sure why this happens during addValue
- }
- T newValue = values.get(selectedIndex);
- setValue(newValue, true);
- }
- });
- }
-
- public HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler) {
- return addHandler(handler, ValueChangeEvent.getType());
- }
-
- public T getValue() {
- return value;
- }
-
- public void setAcceptableValues(Collection<T> newValues) {
- values.clear();
- valueToIndex.clear();
- ListBox listBox = getListBox();
- listBox.clear();
-
- for (T nextNewValue : newValues) {
- addValue(nextNewValue);
- }
-
- updateListBox();
- }
-
- /**
- * Set the value and display it in the select element. Add the value to the
- * acceptable set if it is not already there.
- */
- public void setValue(T value) {
- setValue(value, false);
- }
-
- public void setValue(T value, boolean fireEvents) {
- if (value == this.value || (this.value != null && this.value.equals(value))) {
- return;
- }
-
- T before = this.value;
- this.value = value;
- updateListBox();
-
- if (fireEvents) {
- ValueChangeEvent.fireIfNotEqual(this, before, value);
- }
- }
-
- private void addValue(T value) {
- if (valueToIndex.containsKey(value)) {
- throw new IllegalArgumentException("Duplicate value: " + value);
- }
-
- valueToIndex.put(value, values.size());
- values.add(value);
- getListBox().addItem(renderer.render(value));
- assert values.size() == getListBox().getItemCount();
- }
-
- private ListBox getListBox() {
- return (ListBox) getWidget();
- }
-
- private void updateListBox() {
- Integer index = valueToIndex.get(value);
- if (index == null) {
- addValue(value);
- }
-
- index = valueToIndex.get(value);
- getListBox().setSelectedIndex(index);
- }
-}
diff --git a/user/src/com/google/gwt/user/client/ui/ValuePicker.java b/user/src/com/google/gwt/user/client/ui/ValuePicker.java
index a433144..1a92b38 100644
--- a/user/src/com/google/gwt/user/client/ui/ValuePicker.java
+++ b/user/src/com/google/gwt/user/client/ui/ValuePicker.java
@@ -92,10 +92,6 @@
return value;
}
- public void setAcceptableValues(Collection<T> places) {
- cellList.setRowData(0, new ArrayList<T>(places));
- }
-
public void setPageSize(int size) {
cellList.setPageSize(size);
}
@@ -115,4 +111,8 @@
ValueChangeEvent.fire(this, value);
}
}
+
+ public void setValues(Collection<T> places) {
+ cellList.setRowData(0, new ArrayList<T>(places));
+ }
}
diff --git a/user/test/com/google/gwt/requestfactory/server/SimpleFoo.java b/user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
index 4792ee9..7a6c504 100644
--- a/user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
+++ b/user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
@@ -29,7 +29,7 @@
return null;
}
- public static SimpleFoo findSimpleFooById(@SuppressWarnings("unused") Long id) {
+ public static SimpleFoo findSimpleFooById(Long id) {
return null;
}
diff --git a/user/test/com/google/gwt/user/UISuite.java b/user/test/com/google/gwt/user/UISuite.java
index e31de10..06960cc 100644
--- a/user/test/com/google/gwt/user/UISuite.java
+++ b/user/test/com/google/gwt/user/UISuite.java
@@ -88,8 +88,6 @@
import com.google.gwt.user.client.ui.TreeItemTest;
import com.google.gwt.user.client.ui.TreeTest;
import com.google.gwt.user.client.ui.UIObjectTest;
-import com.google.gwt.user.client.ui.ValueBoxBaseTest;
-import com.google.gwt.user.client.ui.ValueListBoxTest;
import com.google.gwt.user.client.ui.VerticalPanelTest;
import com.google.gwt.user.client.ui.VerticalSplitPanelTest;
import com.google.gwt.user.client.ui.WidgetCollectionTest;
@@ -184,8 +182,6 @@
suite.addTestSuite(TreeTest.class);
suite.addTestSuite(TreeItemTest.class);
suite.addTestSuite(UIObjectTest.class);
- suite.addTestSuite(ValueBoxBaseTest.class);
- suite.addTestSuite(ValueListBoxTest.class);
suite.addTestSuite(VerticalPanelTest.class);
suite.addTestSuite(VerticalSplitPanelTest.class);
suite.addTestSuite(WidgetCollectionTest.class);
diff --git a/user/test/com/google/gwt/user/client/ui/ValueBoxBaseTest.java b/user/test/com/google/gwt/user/client/ui/ValueBoxBaseTest.java
index da8d0ff..0face04 100644
--- a/user/test/com/google/gwt/user/client/ui/ValueBoxBaseTest.java
+++ b/user/test/com/google/gwt/user/client/ui/ValueBoxBaseTest.java
@@ -40,7 +40,7 @@
parser.throwException = true;
valueBoxBase.setText("");
try {
- valueBoxBase.getValueOrThrow();
+ String string = valueBoxBase.getValueOrThrow();
fail("Should have thrown ParseException");
} catch (ParseException e) {
// exception was correctly thrown
@@ -62,7 +62,7 @@
parser.throwException = true;
valueBoxBase.setText("simple string");
try {
- valueBoxBase.getValueOrThrow();
+ String string = valueBoxBase.getValueOrThrow();
fail("Should have thrown ParseException");
} catch (ParseException e) {
// exception was correctly thrown
@@ -73,7 +73,7 @@
}
// Test that a string with padding spaces correctly passes through
- public void testSpaces() throws ParseException {
+ public void testSpaces() {
Element elm = Document.get().createTextInputElement();
Renderer<String> renderer = PassthroughRenderer.instance();
MockParser parser = new MockParser();
@@ -81,9 +81,12 @@
ValueBoxBase<String> valueBoxBase =
new ValueBoxBase<String>(elm, renderer, parser);
- String text = " two space padding test ";
- valueBoxBase.setText(text);
- assertEquals(text, valueBoxBase.getValueOrThrow());
+ valueBoxBase.setText(" two space padding test ");
+ try {
+ assertEquals(" two space padding ", valueBoxBase.getValueOrThrow());
+ } catch (ParseException e) {
+ fail("Should not have thrown ParseException");
+ }
if (!parser.parseCalled) {
fail("Parser was not run");
}
diff --git a/user/test/com/google/gwt/user/client/ui/ValueListBoxTest.java b/user/test/com/google/gwt/user/client/ui/ValueListBoxTest.java
deleted file mode 100644
index 741aada..0000000
--- a/user/test/com/google/gwt/user/client/ui/ValueListBoxTest.java
+++ /dev/null
@@ -1,118 +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.user.client.ui;
-
-import com.google.gwt.dom.client.SelectElement;
-import com.google.gwt.junit.client.GWTTestCase;
-import com.google.gwt.text.shared.AbstractRenderer;
-
-import java.util.Arrays;
-
-/**
- * Eponymous unit test.
- */
-public class ValueListBoxTest extends GWTTestCase {
- static class Foo {
- final String value;
-
- Foo(String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return "Foo [value=" + value + "]";
- }
- }
-
- static class FooRenderer extends AbstractRenderer<Foo> {
- public String render(Foo object) {
- if (object == null) {
- return "";
- }
- return "Foo: " + object.value;
- }
- }
-
- private static final FooRenderer renderer = new FooRenderer();
-
- ValueListBox<Foo> subject;
-
- @Override
- public String getModuleName() {
- return "com.google.gwt.user.User";
- }
-
- public void testExtraValueSet() {
- Foo[] values = new Foo[] {new Foo("able"), new Foo("baker")};
- Foo baz = new Foo("baz");
-
- subject.setAcceptableValues(Arrays.asList(values));
- assertEquals(2, getSelect().getLength());
-
- subject.setValue(baz);
- assertEquals(baz, subject.getValue());
- assertEquals(3, getSelect().getLength());
- }
-
- public void testNakedSet() {
- assertNull(subject.getValue());
-
- SelectElement elm = getSelect();
- assertEquals(0, elm.getLength());
-
- Foo barFoo = new Foo("bar");
-
- setAndCheck(barFoo);
-
- assertEquals(1, elm.getLength());
- assertEquals(renderer.render(barFoo), elm.getValue());
- }
-
- public void testNormalSet() {
- Foo[] values = new Foo[] {new Foo("able"), new Foo("baker")};
- subject.setAcceptableValues(Arrays.asList(values));
-
- assertEquals(2, getSelect().getLength());
-
- setAndCheck(values[0]);
- setAndCheck(values[1]);
- setAndCheck(values[0]);
-
- assertEquals(2, getSelect().getLength());
- }
-
- @Override
- protected void gwtSetUp() {
- subject = new ValueListBox<Foo>(renderer);
- RootPanel.get().add(subject);
- }
-
- @Override
- protected void gwtTearDown() {
- RootPanel.get().remove(subject);
- }
-
- private SelectElement getSelect() {
- return subject.getWidget().getElement().cast();
- }
-
- private void setAndCheck(Foo value) {
- subject.setValue(value);
- assertEquals(value, subject.getValue());
- assertEquals(renderer.render(value), getSelect().getValue());
- }
-}