Reorganize the bikeshed directories
Add a TreeView to the stock sample app
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7625 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/bikeshed/src/com/google/gwt/cells/Cells.gwt.xml b/bikeshed/src/com/google/gwt/bikeshed/cells/Cells.gwt.xml
similarity index 100%
rename from bikeshed/src/com/google/gwt/cells/Cells.gwt.xml
rename to bikeshed/src/com/google/gwt/bikeshed/cells/Cells.gwt.xml
diff --git a/bikeshed/src/com/google/gwt/cells/client/ButtonCell.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/ButtonCell.java
similarity index 96%
rename from bikeshed/src/com/google/gwt/cells/client/ButtonCell.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/ButtonCell.java
index 9aa06cd..48eb1c4 100644
--- a/bikeshed/src/com/google/gwt/cells/client/ButtonCell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/ButtonCell.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
diff --git a/bikeshed/src/com/google/gwt/cells/client/Cell.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/Cell.java
similarity index 96%
rename from bikeshed/src/com/google/gwt/cells/client/Cell.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/Cell.java
index 27f84bb..ccfe97e 100644
--- a/bikeshed/src/com/google/gwt/cells/client/Cell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/Cell.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
diff --git a/bikeshed/src/com/google/gwt/cells/client/CheckboxCell.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/CheckboxCell.java
similarity index 96%
rename from bikeshed/src/com/google/gwt/cells/client/CheckboxCell.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/CheckboxCell.java
index ee711f8..a085f46 100644
--- a/bikeshed/src/com/google/gwt/cells/client/CheckboxCell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/CheckboxCell.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
diff --git a/bikeshed/src/com/google/gwt/cells/client/CurrencyCell.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/CurrencyCell.java
similarity index 95%
rename from bikeshed/src/com/google/gwt/cells/client/CurrencyCell.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/CurrencyCell.java
index 9a7a1fa..02cbbe6 100644
--- a/bikeshed/src/com/google/gwt/cells/client/CurrencyCell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/CurrencyCell.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
/**
* A {@link Cell} used to render currency.
diff --git a/bikeshed/src/com/google/gwt/cells/client/FieldUpdater.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/FieldUpdater.java
similarity index 95%
rename from bikeshed/src/com/google/gwt/cells/client/FieldUpdater.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/FieldUpdater.java
index 84d5a28..2e0fd85 100644
--- a/bikeshed/src/com/google/gwt/cells/client/FieldUpdater.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/FieldUpdater.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
/**
* A {@link FieldUpdater} may be added to a Column to update a particular field
diff --git a/bikeshed/src/com/google/gwt/cells/client/TextCell.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/TextCell.java
similarity index 94%
rename from bikeshed/src/com/google/gwt/cells/client/TextCell.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/TextCell.java
index 5dd5ebe..994e103 100644
--- a/bikeshed/src/com/google/gwt/cells/client/TextCell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/TextCell.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
/**
* A {@link Cell} used to render text.
diff --git a/bikeshed/src/com/google/gwt/cells/client/TextInputCell.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/TextInputCell.java
similarity index 96%
rename from bikeshed/src/com/google/gwt/cells/client/TextInputCell.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/TextInputCell.java
index 96834a6..5257918 100644
--- a/bikeshed/src/com/google/gwt/cells/client/TextInputCell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/TextInputCell.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
diff --git a/bikeshed/src/com/google/gwt/cells/client/ValueUpdater.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/ValueUpdater.java
similarity index 94%
rename from bikeshed/src/com/google/gwt/cells/client/ValueUpdater.java
rename to bikeshed/src/com/google/gwt/bikeshed/cells/client/ValueUpdater.java
index 27c6f51..5ce2587 100644
--- a/bikeshed/src/com/google/gwt/cells/client/ValueUpdater.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/ValueUpdater.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.cells.client;
+package com.google.gwt.bikeshed.cells.client;
/**
* A {@link ValueUpdater} may be added to a Cell to provide updated data.
diff --git a/bikeshed/src/com/google/gwt/list/List.gwt.xml b/bikeshed/src/com/google/gwt/bikeshed/list/List.gwt.xml
similarity index 92%
rename from bikeshed/src/com/google/gwt/list/List.gwt.xml
rename to bikeshed/src/com/google/gwt/bikeshed/list/List.gwt.xml
index 5a4b63d..8fdf178 100644
--- a/bikeshed/src/com/google/gwt/list/List.gwt.xml
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/List.gwt.xml
@@ -15,7 +15,7 @@
-->
<module>
<inherits name='com.google.gwt.user.User'/>
- <inherits name='com.google.gwt.cells.Cells'/>
+ <inherits name='com.google.gwt.bikeshed.cells.Cells'/>
<source path="shared" />
<source path="client" />
</module>
diff --git a/bikeshed/src/com/google/gwt/list/client/Column.java b/bikeshed/src/com/google/gwt/bikeshed/list/client/Column.java
similarity index 87%
rename from bikeshed/src/com/google/gwt/list/client/Column.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/client/Column.java
index c19a7df..dc81c23 100644
--- a/bikeshed/src/com/google/gwt/list/client/Column.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/client/Column.java
@@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.client;
+package com.google.gwt.bikeshed.list.client;
-import com.google.gwt.cells.client.Cell;
-import com.google.gwt.cells.client.ValueUpdater;
-import com.google.gwt.cells.client.FieldUpdater;
+import com.google.gwt.bikeshed.cells.client.Cell;
+import com.google.gwt.bikeshed.cells.client.FieldUpdater;
+import com.google.gwt.bikeshed.cells.client.ValueUpdater;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
diff --git a/bikeshed/src/com/google/gwt/list/client/PagingTableListView.java b/bikeshed/src/com/google/gwt/bikeshed/list/client/PagingTableListView.java
similarity index 94%
rename from bikeshed/src/com/google/gwt/list/client/PagingTableListView.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/client/PagingTableListView.java
index 88ac483..90a9164 100644
--- a/bikeshed/src/com/google/gwt/list/client/PagingTableListView.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/client/PagingTableListView.java
@@ -13,10 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.client;
+package com.google.gwt.bikeshed.list.client;
-import com.google.gwt.cells.client.ButtonCell;
-import com.google.gwt.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.cells.client.ButtonCell;
+import com.google.gwt.bikeshed.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.list.shared.ListEvent;
+import com.google.gwt.bikeshed.list.shared.ListHandler;
+import com.google.gwt.bikeshed.list.shared.ListModel;
+import com.google.gwt.bikeshed.list.shared.ListRegistration;
+import com.google.gwt.bikeshed.list.shared.SizeChangeEvent;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
@@ -27,11 +32,6 @@
import com.google.gwt.dom.client.TableElement;
import com.google.gwt.dom.client.TableRowElement;
import com.google.gwt.dom.client.Style.Display;
-import com.google.gwt.list.shared.ListEvent;
-import com.google.gwt.list.shared.ListHandler;
-import com.google.gwt.list.shared.ListModel;
-import com.google.gwt.list.shared.ListRegistration;
-import com.google.gwt.list.shared.SizeChangeEvent;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
diff --git a/bikeshed/src/com/google/gwt/list/client/SimpleCellList.java b/bikeshed/src/com/google/gwt/bikeshed/list/client/SimpleCellList.java
similarity index 90%
rename from bikeshed/src/com/google/gwt/list/client/SimpleCellList.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/client/SimpleCellList.java
index d283d6a..e1dba47 100644
--- a/bikeshed/src/com/google/gwt/list/client/SimpleCellList.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/client/SimpleCellList.java
@@ -13,17 +13,17 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.client;
+package com.google.gwt.bikeshed.list.client;
-import com.google.gwt.cells.client.Cell;
-import com.google.gwt.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.cells.client.Cell;
+import com.google.gwt.bikeshed.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.list.shared.ListEvent;
+import com.google.gwt.bikeshed.list.shared.ListHandler;
+import com.google.gwt.bikeshed.list.shared.ListModel;
+import com.google.gwt.bikeshed.list.shared.ListRegistration;
+import com.google.gwt.bikeshed.list.shared.SizeChangeEvent;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
-import com.google.gwt.list.shared.ListEvent;
-import com.google.gwt.list.shared.ListHandler;
-import com.google.gwt.list.shared.ListModel;
-import com.google.gwt.list.shared.ListRegistration;
-import com.google.gwt.list.shared.SizeChangeEvent;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
diff --git a/bikeshed/src/com/google/gwt/list/shared/AbstractListModel.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/AbstractListModel.java
similarity index 98%
rename from bikeshed/src/com/google/gwt/list/shared/AbstractListModel.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/AbstractListModel.java
index 7daf7c1..f46dba0 100644
--- a/bikeshed/src/com/google/gwt/list/shared/AbstractListModel.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/AbstractListModel.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
import java.io.Serializable;
import java.util.ArrayList;
diff --git a/bikeshed/src/com/google/gwt/list/shared/AsyncListModel.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/AsyncListModel.java
similarity index 97%
rename from bikeshed/src/com/google/gwt/list/shared/AsyncListModel.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/AsyncListModel.java
index d2124ed..903041e 100644
--- a/bikeshed/src/com/google/gwt/list/shared/AsyncListModel.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/AsyncListModel.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
import java.util.List;
diff --git a/bikeshed/src/com/google/gwt/list/shared/ListEvent.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListEvent.java
similarity index 97%
rename from bikeshed/src/com/google/gwt/list/shared/ListEvent.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/ListEvent.java
index 0986dc4..82ceec6 100644
--- a/bikeshed/src/com/google/gwt/list/shared/ListEvent.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListEvent.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
import com.google.gwt.event.shared.GwtEvent;
diff --git a/bikeshed/src/com/google/gwt/list/shared/ListHandler.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListHandler.java
similarity index 95%
rename from bikeshed/src/com/google/gwt/list/shared/ListHandler.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/ListHandler.java
index 9ccfa1f..fd41884 100644
--- a/bikeshed/src/com/google/gwt/list/shared/ListHandler.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListHandler.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
import com.google.gwt.event.shared.EventHandler;
diff --git a/bikeshed/src/com/google/gwt/list/shared/ListListModel.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListListModel.java
similarity index 97%
rename from bikeshed/src/com/google/gwt/list/shared/ListListModel.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/ListListModel.java
index fa63a24..1327de5 100644
--- a/bikeshed/src/com/google/gwt/list/shared/ListListModel.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListListModel.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
@@ -31,6 +31,8 @@
*/
public class ListListModel<T> extends AbstractListModel<T> {
+ public int insertIndex;
+
/**
* A wrapper around a list that updates the model on any change.
*/
@@ -48,13 +50,14 @@
*/
private Command flushCommand = new Command() {
public void execute() {
- flushPending = false;
int newSize = list.size();
if (curSize != newSize) {
curSize = newSize;
updateDataSize(curSize, true);
}
updateViewData(0, list.size(), list);
+
+ flushPending = false;
}
};
@@ -74,6 +77,7 @@
public void add(int index, T element) {
list.add(index, element);
+ // insert(index);
flush();
}
diff --git a/bikeshed/src/com/google/gwt/list/shared/ListModel.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListModel.java
similarity index 94%
rename from bikeshed/src/com/google/gwt/list/shared/ListModel.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/ListModel.java
index 2a1c521..6bf9ee5 100644
--- a/bikeshed/src/com/google/gwt/list/shared/ListModel.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListModel.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
/**
* A model for a list.
diff --git a/bikeshed/src/com/google/gwt/list/shared/ListRegistration.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListRegistration.java
similarity index 95%
rename from bikeshed/src/com/google/gwt/list/shared/ListRegistration.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/ListRegistration.java
index a0e2761..a417fb1 100644
--- a/bikeshed/src/com/google/gwt/list/shared/ListRegistration.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListRegistration.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
import com.google.gwt.event.shared.HandlerRegistration;
diff --git a/bikeshed/src/com/google/gwt/list/shared/Range.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/Range.java
similarity index 94%
rename from bikeshed/src/com/google/gwt/list/shared/Range.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/Range.java
index e798658..ac9a883 100644
--- a/bikeshed/src/com/google/gwt/list/shared/Range.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/Range.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
/**
* The range of interest for a single handler.
diff --git a/bikeshed/src/com/google/gwt/list/shared/SizeChangeEvent.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/SizeChangeEvent.java
similarity index 97%
rename from bikeshed/src/com/google/gwt/list/shared/SizeChangeEvent.java
rename to bikeshed/src/com/google/gwt/bikeshed/list/shared/SizeChangeEvent.java
index 73b4bf6..bc82706 100644
--- a/bikeshed/src/com/google/gwt/list/shared/SizeChangeEvent.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/SizeChangeEvent.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.list.shared;
+package com.google.gwt.bikeshed.list.shared;
import com.google.gwt.event.shared.GwtEvent;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/Stocks.gwt.xml b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/StockSample.gwt.xml
similarity index 84%
rename from bikeshed/src/com/google/gwt/sample/stocks/Stocks.gwt.xml
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/StockSample.gwt.xml
index 6788e6a..b8af876 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/Stocks.gwt.xml
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/StockSample.gwt.xml
@@ -3,7 +3,8 @@
<module rename-to='stocks'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
- <inherits name='com.google.gwt.list.List'/>
+ <inherits name='com.google.gwt.bikeshed.list.List'/>
+ <inherits name='com.google.gwt.bikeshed.tree.Tree'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
@@ -15,7 +16,7 @@
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
- <entry-point class='com.google.gwt.sample.stocks.client.Stocks'/>
+ <entry-point class='com.google.gwt.bikeshed.sample.stocks.client.StockSample'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/client/BuySellPopup.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/BuySellPopup.java
similarity index 95%
rename from bikeshed/src/com/google/gwt/sample/stocks/client/BuySellPopup.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/BuySellPopup.java
index feeb8c1..c313777 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/client/BuySellPopup.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/BuySellPopup.java
@@ -13,15 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.client;
+package com.google.gwt.bikeshed.sample.stocks.client;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockQuote;
+import com.google.gwt.bikeshed.sample.stocks.shared.Transaction;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.sample.stocks.shared.StockQuote;
-import com.google.gwt.sample.stocks.shared.Transaction;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Window;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/client/StockQuoteCell.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockQuoteCell.java
similarity index 83%
rename from bikeshed/src/com/google/gwt/sample/stocks/client/StockQuoteCell.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockQuoteCell.java
index 38c8eb4..150ac04 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/client/StockQuoteCell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockQuoteCell.java
@@ -13,10 +13,10 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.client;
+package com.google.gwt.bikeshed.sample.stocks.client;
-import com.google.gwt.cells.client.Cell;
-import com.google.gwt.sample.stocks.shared.StockQuote;
+import com.google.gwt.bikeshed.cells.client.Cell;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockQuote;
/**
* A cell that represents a {@link StockQuote}.
diff --git a/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockSample.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockSample.java
new file mode 100644
index 0000000..c7f2be2
--- /dev/null
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockSample.java
@@ -0,0 +1,446 @@
+/*
+ * 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.bikeshed.sample.stocks.client;
+
+import com.google.gwt.bikeshed.cells.client.ButtonCell;
+import com.google.gwt.bikeshed.cells.client.CheckboxCell;
+import com.google.gwt.bikeshed.cells.client.CurrencyCell;
+import com.google.gwt.bikeshed.cells.client.FieldUpdater;
+import com.google.gwt.bikeshed.cells.client.TextCell;
+import com.google.gwt.bikeshed.list.client.Column;
+import com.google.gwt.bikeshed.list.client.PagingTableListView;
+import com.google.gwt.bikeshed.list.shared.AsyncListModel;
+import com.google.gwt.bikeshed.list.shared.ListListModel;
+import com.google.gwt.bikeshed.list.shared.Range;
+import com.google.gwt.bikeshed.list.shared.AsyncListModel.DataSource;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockQuote;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockQuoteList;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockRequest;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockResponse;
+import com.google.gwt.bikeshed.sample.stocks.shared.Transaction;
+import com.google.gwt.bikeshed.tree.client.TreeView;
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.logical.shared.CloseEvent;
+import com.google.gwt.event.logical.shared.CloseHandler;
+import com.google.gwt.i18n.client.NumberFormat;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.TextBox;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Entry point classes define <code>onModuleLoad()</code>.
+ */
+public class StockSample implements EntryPoint {
+
+ static class Columns {
+
+ private static Column<StockQuote, String> buyColumn = new Column<StockQuote, String>(
+ new ButtonCell()) {
+ @Override
+ protected String getValue(StockQuote object) {
+ return "Buy";
+ }
+ };
+
+ private static Column<StockQuote, Boolean> favoriteColumn =
+ new Column<StockQuote, Boolean>(new CheckboxCell()) {
+ @Override
+ protected Boolean getValue(StockQuote object) {
+ return object.isFavorite();
+ }
+ };
+
+ private static Column<StockQuote, String> nameColumn =
+ new Column<StockQuote, String>(new TextCell()) {
+ @Override
+ protected String getValue(StockQuote object) {
+ return object.getName();
+ }
+ };
+
+ private static Column<StockQuote, Integer> priceColumn =
+ new Column<StockQuote, Integer>(new CurrencyCell()) {
+ @Override
+ protected Integer getValue(StockQuote object) {
+ return object.getPrice();
+ }
+ };
+
+ private static Column<StockQuote, String> sellColumn =
+ new Column<StockQuote, String>(new ButtonCell()) {
+ @Override
+ protected String getValue(StockQuote object) {
+ return "Sell";
+ }
+ };
+
+ private static Column<StockQuote, String> sharesColumn =
+ new Column<StockQuote, String>(new TextCell()) {
+ @Override
+ protected String getValue(StockQuote object) {
+ return "" + object.getSharesOwned();
+ }
+ };
+
+ private static Column<Transaction, String> subtotalColumn =
+ new Column<Transaction, String>(new TextCell()) {
+ @Override
+ protected String getValue(Transaction object) {
+ int price = object.getActualPrice() * object.getQuantity();
+ return (object.isBuy() ? " (" : " ") + getFormattedPrice(price) +
+ (object.isBuy() ? ")" : "");
+ }
+ };
+
+ private static Column<StockQuote, String> tickerColumn =
+ new Column<StockQuote, String>(new TextCell()) {
+ @Override
+ protected String getValue(StockQuote object) {
+ return object.getTicker();
+ }
+ };
+
+ private static Column<Transaction, String> transactionColumn =
+ new Column<Transaction, String>(new TextCell()) {
+ @Override
+ protected String getValue(Transaction object) {
+ return object.toString();
+ }
+ };
+ }
+
+ /**
+ * The delay between updates in milliseconds.
+ */
+ private static final int UPDATE_DELAY = 5000;
+
+ private static String getFormattedPrice(int price) {
+ return NumberFormat.getCurrencyFormat("USD").format(price / 100.0);
+ }
+
+ /**
+ * The popup used to purchase stock.
+ */
+ private BuySellPopup buySellPopup = new BuySellPopup();
+
+ private final Label cashLabel = new Label();
+
+ /**
+ * The {@link StockService} used to retrieve data.
+ */
+ private final StockServiceAsync dataService = GWT.create(StockService.class);
+
+ private final Label errorLabel = new Label();
+
+ private AsyncListModel<StockQuote> favoritesListModel;
+
+ private PagingTableListView<StockQuote> favoritesTable;
+
+ private final TextBox queryField = new TextBox();
+
+ private PagingTableListView<StockQuote> resultsTable;
+
+ private AsyncListModel<StockQuote> searchListModel;
+
+ private ListListModel<String> tickersListModel = new ListListModel<String>();
+
+ private Map<String, ListListModel<Transaction>> transactionListListModelsByTicker =
+ new HashMap<String, ListListModel<Transaction>>();
+
+ private ListListModel<Transaction> transactionListModel;
+
+ private List<Transaction> transactions;
+
+ private PagingTableListView<Transaction> transactionTable;
+
+ private TreeView transactionTree;
+
+ private List<String> transactionTreeTickers = tickersListModel.getList();
+
+ /**
+ * The timer used to update the stock quotes.
+ */
+ private Timer updateTimer = new Timer() {
+ @Override
+ public void run() {
+ update();
+ }
+ };
+
+ /**
+ * This is the entry point method.
+ */
+ public void onModuleLoad() {
+ queryField.setText("G");
+
+ // Add the nameField and sendButton to the RootPanel
+ // Use RootPanel.get() to get the entire body element
+ RootPanel.get("queryFieldContainer").add(queryField);
+ RootPanel.get("errorLabelContainer").add(errorLabel);
+
+ // Focus the cursor on the name field when the app loads
+ queryField.setFocus(true);
+ queryField.selectAll();
+
+ // Create the list models
+ searchListModel = new AsyncListModel<StockQuote>(
+ new DataSource<StockQuote>() {
+ public void requestData(AsyncListModel<StockQuote> listModel) {
+ update();
+ }
+ });
+
+ favoritesListModel = new AsyncListModel<StockQuote>(
+ new DataSource<StockQuote>() {
+ public void requestData(AsyncListModel<StockQuote> listModel) {
+ update();
+ }
+ });
+
+ transactionListModel = new ListListModel<Transaction>();
+ transactions = transactionListModel.getList();
+
+ // Create the results table.
+ resultsTable = new PagingTableListView<StockQuote>(searchListModel, 10);
+ resultsTable.addColumn(Columns.favoriteColumn);
+ resultsTable.addColumn(Columns.tickerColumn);
+ resultsTable.addColumn(Columns.nameColumn);
+ resultsTable.addColumn(Columns.priceColumn);
+ resultsTable.addColumn(Columns.buyColumn);
+
+ // Create the favorites table.
+ favoritesTable = new PagingTableListView<StockQuote>(favoritesListModel, 10);
+ favoritesTable.addColumn(Columns.tickerColumn);
+ favoritesTable.addColumn(Columns.priceColumn);
+ favoritesTable.addColumn(Columns.sharesColumn);
+ favoritesTable.addColumn(Columns.buyColumn);
+ favoritesTable.addColumn(Columns.sellColumn);
+
+ // Create the transactions table.
+ transactionTable = new PagingTableListView<Transaction>(transactionListModel, 10);
+ transactionTable.addColumn(Columns.transactionColumn);
+ transactionTable.addColumn(Columns.subtotalColumn);
+
+ // Create the transactions tree.
+ transactionTree = new TreeView(new TransactionTreeViewModel(tickersListModel,
+ transactionListListModelsByTicker), null);
+
+ Columns.favoriteColumn.setFieldUpdater(new FieldUpdater<StockQuote, Boolean>() {
+ public void update(StockQuote object, Boolean value) {
+ setFavorite(object.getTicker(), value);
+ }
+ });
+
+ Columns.buyColumn.setFieldUpdater(new FieldUpdater<StockQuote, String>() {
+ public void update(StockQuote object, String value) {
+ buySellPopup.setStockQuote(object, true);
+ buySellPopup.center();
+ }
+ });
+
+ Columns.sellColumn.setFieldUpdater(new FieldUpdater<StockQuote, String>() {
+ public void update(StockQuote object, String value) {
+ buySellPopup.setStockQuote(object, false);
+ buySellPopup.center();
+ }
+ });
+
+ buySellPopup.addCloseHandler(new CloseHandler<PopupPanel>() {
+ public void onClose(CloseEvent<PopupPanel> event) {
+ Transaction t = buySellPopup.getTransaction();
+ if (t != null) {
+ dataService.transact(t, new AsyncCallback<Transaction>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error: " + caught.getMessage());
+ }
+
+ public void onSuccess(Transaction result) {
+ recordTransaction(result);
+ update();
+ }
+
+ /**
+ * Update transactions (list of all transactions),
+ * transactionTickers (set of all tickers involved in
+ * transactions), and transactionsByTicker (map from
+ * ticker to lists of transactions for that ticker).
+ */
+ private void recordTransaction(Transaction result) {
+ transactions.add(0, result);
+
+ // Add ticker in alphebetical order
+ String ticker = result.getTicker();
+ int index = 0;
+ for (String s : transactionTreeTickers) {
+ int compare = s.compareTo(ticker);
+ if (compare == 0) {
+ // Already have the ticker
+ index = -1;
+ break;
+ } else if (compare > 0) {
+ break;
+ }
+
+ index++;
+ }
+ if (index != -1) {
+ transactionTreeTickers.add(index, ticker);
+ }
+
+ // Update the next level of the transaction tree
+ // for the given ticker
+ ListListModel<Transaction> t =
+ transactionListListModelsByTicker.get(ticker);
+ if (t == null) {
+ t = new ListListModel<Transaction>();
+ transactionListListModelsByTicker.put(ticker, t);
+ }
+ t.getList().add(result);
+ }
+ });
+ }
+ }
+ });
+
+ // Add components to the page.
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.add(new HTML("<b>Available cash:</b>"));
+ hPanel.add(cashLabel);
+ RootPanel.get().add(hPanel);
+
+ RootPanel.get().add(resultsTable);
+ RootPanel.get().add(new HTML("<hr>"));
+ RootPanel.get().add(favoritesTable);
+ RootPanel.get().add(new HTML("<hr>"));
+ RootPanel.get().add(transactionTable);
+ RootPanel.get().add(new HTML("<hr>"));
+ RootPanel.get().add(transactionTree);
+
+ // Add a handler to send the name to the server
+ queryField.addKeyUpHandler(new KeyUpHandler() {
+ public void onKeyUp(KeyUpEvent event) {
+ update();
+ }
+ });
+
+ update();
+ }
+
+ /**
+ * Set or unset a ticker symbol as a 'favorite'.
+ *
+ * @param ticker the ticker symbol
+ * @param favorite if true, make the stock a favorite
+ */
+ public void setFavorite(String ticker, boolean favorite) {
+ if (favorite) {
+ dataService.addFavorite(ticker, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error adding favorite");
+ }
+
+ public void onSuccess(Void result) {
+ // do nothing
+ }
+ });
+ } else {
+ dataService.removeFavorite(ticker, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error removing favorite");
+ }
+
+ public void onSuccess(Void result) {
+ // do nothing
+ }
+ });
+ }
+ }
+
+ /**
+ * Process the {@link StockResponse} from the server.
+ *
+ * @param response the stock response
+ */
+ private void processStockResponse(StockResponse response) {
+ // Update the search list.
+ StockQuoteList searchResults = response.getSearchResults();
+ searchListModel.updateDataSize(response.getNumSearchResults(), true);
+ searchListModel.updateViewData(searchResults.getStartIndex(),
+ searchResults.size(), searchResults);
+
+ // Update the favorites list.
+ StockQuoteList favorites = response.getFavorites();
+ favoritesListModel.updateDataSize(response.getNumFavorites(), true);
+ favoritesListModel.updateViewData(favorites.getStartIndex(),
+ favorites.size(), favorites);
+
+ // Update available cash.
+ int cash = response.getCash();
+ cashLabel.setText(getFormattedPrice(cash));
+ buySellPopup.setAvailableCash(cash);
+
+ // Restart the update timer.
+ updateTimer.schedule(UPDATE_DELAY);
+ }
+
+ /**
+ * Request data from the server using the last query string.
+ */
+ private void update() {
+ updateTimer.cancel();
+
+ Range[] searchRanges = searchListModel.getRanges();
+ Range[] favoritesRanges = favoritesListModel.getRanges();
+
+ if (searchRanges == null || searchRanges.length == 0
+ || favoritesRanges == null || favoritesRanges.length == 0) {
+ return;
+ }
+
+ String searchQuery = queryField.getText();
+ StockRequest request = new StockRequest(searchQuery, searchRanges[0],
+ favoritesRanges[0]);
+ dataService.getStockQuotes(request, new AsyncCallback<StockResponse>() {
+ public void onFailure(Throwable caught) {
+ String message = caught.getMessage();
+ if (message.contains("Not logged in")) {
+ // Force the user to login.
+ Window.Location.reload();
+ } else {
+ Window.alert("ERROR: " + caught.getMessage());
+ updateTimer.schedule(UPDATE_DELAY);
+ }
+ }
+
+ public void onSuccess(StockResponse result) {
+ processStockResponse(result);
+ }
+ });
+ }
+}
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/client/StockService.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockService.java
similarity index 81%
rename from bikeshed/src/com/google/gwt/sample/stocks/client/StockService.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockService.java
index 23299e9..7589ca88 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/client/StockService.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockService.java
@@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.client;
+package com.google.gwt.bikeshed.sample.stocks.client;
-import com.google.gwt.sample.stocks.shared.StockRequest;
-import com.google.gwt.sample.stocks.shared.StockResponse;
-import com.google.gwt.sample.stocks.shared.Transaction;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockRequest;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockResponse;
+import com.google.gwt.bikeshed.sample.stocks.shared.Transaction;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/client/StockServiceAsync.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockServiceAsync.java
similarity index 80%
rename from bikeshed/src/com/google/gwt/sample/stocks/client/StockServiceAsync.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockServiceAsync.java
index 0eda48f..88a6b56 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/client/StockServiceAsync.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/StockServiceAsync.java
@@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.client;
+package com.google.gwt.bikeshed.sample.stocks.client;
-import com.google.gwt.sample.stocks.shared.StockRequest;
-import com.google.gwt.sample.stocks.shared.StockResponse;
-import com.google.gwt.sample.stocks.shared.Transaction;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockRequest;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockResponse;
+import com.google.gwt.bikeshed.sample.stocks.shared.Transaction;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
diff --git a/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/TransactionTreeViewModel.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/TransactionTreeViewModel.java
new file mode 100644
index 0000000..6f95667
--- /dev/null
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/client/TransactionTreeViewModel.java
@@ -0,0 +1,73 @@
+/*
+ * 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.bikeshed.sample.stocks.client;
+
+import com.google.gwt.bikeshed.cells.client.Cell;
+import com.google.gwt.bikeshed.cells.client.TextCell;
+import com.google.gwt.bikeshed.list.shared.ListListModel;
+import com.google.gwt.bikeshed.sample.stocks.shared.Transaction;
+import com.google.gwt.bikeshed.tree.client.TreeNodeView;
+import com.google.gwt.bikeshed.tree.client.TreeViewModel;
+
+import java.util.Map;
+
+/**
+ * A TreeViewModel for a tree with a hidden root node of null,
+ * a first level containing ticker symbol Strings, and a second
+ * level containing Transactions.
+ */
+class TransactionTreeViewModel implements TreeViewModel {
+
+ static class TransactionCell extends Cell<Transaction> {
+
+ @Override
+ public void render(Transaction value, StringBuilder sb) {
+ sb.append(value.toString());
+ }
+ }
+
+ private static final Cell<String> TEXT_CELL = new TextCell();
+
+ private static final Cell<Transaction> TRANSACTION_CELL =
+ new TransactionCell();
+
+ private ListListModel<String> tickersListModel;
+ private Map<String, ListListModel<Transaction>> transactionListListModelsByTicker;
+
+ public TransactionTreeViewModel(ListListModel<String> tickersListModel,
+ Map<String, ListListModel<Transaction>> transactionListListModelsByTicker) {
+ this.tickersListModel = tickersListModel;
+ this.transactionListListModelsByTicker = transactionListListModelsByTicker;
+ }
+
+ public <T> NodeInfo<?> getNodeInfo(T value, TreeNodeView<T> treeNodeView) {
+ if (value == null) {
+ return new TreeViewModel.DefaultNodeInfo<String>(tickersListModel,
+ TEXT_CELL);
+ } else if (value instanceof String) {
+ return new TreeViewModel.DefaultNodeInfo<Transaction>(
+ transactionListListModelsByTicker.get(value), TRANSACTION_CELL);
+ } else if (value instanceof Transaction) {
+ return null;
+ }
+
+ throw new IllegalArgumentException(value.toString());
+ }
+
+ public boolean isLeaf(Object value) {
+ return value instanceof Transaction;
+ }
+}
\ No newline at end of file
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/server/NasdaqStocks.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/NasdaqStocks.java
similarity index 99%
rename from bikeshed/src/com/google/gwt/sample/stocks/server/NasdaqStocks.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/NasdaqStocks.java
index b1671f6..f1c9022 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/server/NasdaqStocks.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/NasdaqStocks.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.server;
+package com.google.gwt.bikeshed.sample.stocks.server;
/**
* The list of all Nasdaq stocks (note: this is a snapshot plus
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/server/PlayerStatus.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/PlayerStatus.java
similarity index 98%
rename from bikeshed/src/com/google/gwt/sample/stocks/server/PlayerStatus.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/PlayerStatus.java
index 1893f56..c9e3dcd 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/server/PlayerStatus.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/PlayerStatus.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.server;
+package com.google.gwt.bikeshed.sample.stocks.server;
import java.util.HashMap;
import java.util.TreeSet;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/server/StockServiceImpl.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/StockServiceImpl.java
similarity index 93%
rename from bikeshed/src/com/google/gwt/sample/stocks/server/StockServiceImpl.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/StockServiceImpl.java
index b268e5b..13672fc 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/server/StockServiceImpl.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/server/StockServiceImpl.java
@@ -13,19 +13,19 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.server;
+package com.google.gwt.bikeshed.sample.stocks.server;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
-import com.google.gwt.list.shared.Range;
-import com.google.gwt.list.shared.AbstractListModel.DefaultRange;
-import com.google.gwt.sample.stocks.client.StockService;
-import com.google.gwt.sample.stocks.shared.StockQuote;
-import com.google.gwt.sample.stocks.shared.StockQuoteList;
-import com.google.gwt.sample.stocks.shared.StockRequest;
-import com.google.gwt.sample.stocks.shared.StockResponse;
-import com.google.gwt.sample.stocks.shared.Transaction;
+import com.google.gwt.bikeshed.list.shared.Range;
+import com.google.gwt.bikeshed.list.shared.AbstractListModel.DefaultRange;
+import com.google.gwt.bikeshed.sample.stocks.client.StockService;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockQuote;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockQuoteList;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockRequest;
+import com.google.gwt.bikeshed.sample.stocks.shared.StockResponse;
+import com.google.gwt.bikeshed.sample.stocks.shared.Transaction;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.io.IOException;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockQuote.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockQuote.java
similarity index 97%
rename from bikeshed/src/com/google/gwt/sample/stocks/shared/StockQuote.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockQuote.java
index 678c752..4e3df91 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockQuote.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockQuote.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.shared;
+package com.google.gwt.bikeshed.sample.stocks.shared;
import java.io.Serializable;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockQuoteList.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockQuoteList.java
similarity index 94%
rename from bikeshed/src/com/google/gwt/sample/stocks/shared/StockQuoteList.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockQuoteList.java
index fff7c51..7fa900a 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockQuoteList.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockQuoteList.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.shared;
+package com.google.gwt.bikeshed.sample.stocks.shared;
import java.util.ArrayList;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockRequest.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockRequest.java
similarity index 92%
rename from bikeshed/src/com/google/gwt/sample/stocks/shared/StockRequest.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockRequest.java
index c76ca2c..d7724b3 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockRequest.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockRequest.java
@@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.shared;
+package com.google.gwt.bikeshed.sample.stocks.shared;
-import com.google.gwt.list.shared.Range;
+import com.google.gwt.bikeshed.list.shared.Range;
import java.io.Serializable;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockResponse.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockResponse.java
similarity index 96%
rename from bikeshed/src/com/google/gwt/sample/stocks/shared/StockResponse.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockResponse.java
index 83091f0..1df16ab 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/shared/StockResponse.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/StockResponse.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.shared;
+package com.google.gwt.bikeshed.sample.stocks.shared;
import java.io.Serializable;
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/shared/Transaction.java b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/Transaction.java
similarity index 96%
rename from bikeshed/src/com/google/gwt/sample/stocks/shared/Transaction.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/Transaction.java
index 10b7df8..0b637a6 100644
--- a/bikeshed/src/com/google/gwt/sample/stocks/shared/Transaction.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/stocks/shared/Transaction.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.stocks.shared;
+package com.google.gwt.bikeshed.sample.stocks.shared;
import com.google.gwt.i18n.client.NumberFormat;
diff --git a/bikeshed/src/com/google/gwt/sample/tree/Tree.gwt.xml b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/TreeSample.gwt.xml
similarity index 84%
rename from bikeshed/src/com/google/gwt/sample/tree/Tree.gwt.xml
rename to bikeshed/src/com/google/gwt/bikeshed/sample/tree/TreeSample.gwt.xml
index 31e9531..802fdd7 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/Tree.gwt.xml
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/TreeSample.gwt.xml
@@ -3,7 +3,8 @@
<module rename-to='tree'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
- <inherits name='com.google.gwt.list.List'/>
+ <inherits name='com.google.gwt.bikeshed.list.List'/>
+ <inherits name='com.google.gwt.bikeshed.tree.Tree'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
@@ -15,7 +16,7 @@
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
- <entry-point class='com.google.gwt.sample.tree.client.TreeEntryPoint'/>
+ <entry-point class='com.google.gwt.bikeshed.sample.tree.client.TreeSample'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/MyTreeViewModel.java b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/MyTreeViewModel.java
similarity index 89%
rename from bikeshed/src/com/google/gwt/sample/tree/client/MyTreeViewModel.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/MyTreeViewModel.java
index d0bda7a..89474f5 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/client/MyTreeViewModel.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/MyTreeViewModel.java
@@ -13,14 +13,16 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.client;
+package com.google.gwt.bikeshed.sample.tree.client;
-import com.google.gwt.cells.client.ButtonCell;
-import com.google.gwt.cells.client.Cell;
-import com.google.gwt.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.cells.client.ButtonCell;
+import com.google.gwt.bikeshed.cells.client.Cell;
+import com.google.gwt.bikeshed.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.list.shared.AsyncListModel;
+import com.google.gwt.bikeshed.list.shared.ListModel;
+import com.google.gwt.bikeshed.tree.client.TreeNodeView;
+import com.google.gwt.bikeshed.tree.client.TreeViewModel;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.list.shared.AsyncListModel;
-import com.google.gwt.list.shared.ListModel;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/TreeEntryPoint.java b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeSample.java
similarity index 85%
rename from bikeshed/src/com/google/gwt/sample/tree/client/TreeEntryPoint.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeSample.java
index 90d1372..5a59f8b 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/client/TreeEntryPoint.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeSample.java
@@ -13,15 +13,16 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.client;
+package com.google.gwt.bikeshed.sample.tree.client;
+import com.google.gwt.bikeshed.tree.client.TreeView;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
/**
* A demo of the asynchronous Tree model.
*/
-public class TreeEntryPoint implements EntryPoint {
+public class TreeSample implements EntryPoint {
public void onModuleLoad() {
TreeView tree = new TreeView(new MyTreeViewModel(), "...");
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/TreeService.java b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeService.java
similarity index 94%
rename from bikeshed/src/com/google/gwt/sample/tree/client/TreeService.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeService.java
index 473be0e..2b2f7ae 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/client/TreeService.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeService.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.client;
+package com.google.gwt.bikeshed.sample.tree.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/TreeServiceAsync.java b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeServiceAsync.java
similarity index 93%
rename from bikeshed/src/com/google/gwt/sample/tree/client/TreeServiceAsync.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeServiceAsync.java
index 71d3bee..8f1bc03 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/client/TreeServiceAsync.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/client/TreeServiceAsync.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.client;
+package com.google.gwt.bikeshed.sample.tree.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
diff --git a/bikeshed/src/com/google/gwt/sample/tree/server/Dictionary.java b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/server/Dictionary.java
similarity index 99%
rename from bikeshed/src/com/google/gwt/sample/tree/server/Dictionary.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/tree/server/Dictionary.java
index 0a1b0eb..8e5b4e6 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/server/Dictionary.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/server/Dictionary.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.server;
+package com.google.gwt.bikeshed.sample.tree.server;
import java.util.ArrayList;
import java.util.List;
diff --git a/bikeshed/src/com/google/gwt/sample/tree/server/TreeServiceImpl.java b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/server/TreeServiceImpl.java
similarity index 89%
rename from bikeshed/src/com/google/gwt/sample/tree/server/TreeServiceImpl.java
rename to bikeshed/src/com/google/gwt/bikeshed/sample/tree/server/TreeServiceImpl.java
index b1c585d..5c468b7 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/server/TreeServiceImpl.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/sample/tree/server/TreeServiceImpl.java
@@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.server;
+package com.google.gwt.bikeshed.sample.tree.server;
-import com.google.gwt.sample.tree.client.TreeService;
+import com.google.gwt.bikeshed.sample.tree.client.TreeService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.util.List;
diff --git a/bikeshed/src/com/google/gwt/list/List.gwt.xml b/bikeshed/src/com/google/gwt/bikeshed/tree/Tree.gwt.xml
similarity index 85%
copy from bikeshed/src/com/google/gwt/list/List.gwt.xml
copy to bikeshed/src/com/google/gwt/bikeshed/tree/Tree.gwt.xml
index 5a4b63d..2bddb52 100644
--- a/bikeshed/src/com/google/gwt/list/List.gwt.xml
+++ b/bikeshed/src/com/google/gwt/bikeshed/tree/Tree.gwt.xml
@@ -15,7 +15,8 @@
-->
<module>
<inherits name='com.google.gwt.user.User'/>
- <inherits name='com.google.gwt.cells.Cells'/>
+ <inherits name='com.google.gwt.bikeshed.cells.Cells'/>
+ <inherits name='com.google.gwt.bikeshed.list.List'/>
<source path="shared" />
<source path="client" />
</module>
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/TreeNodeView.java b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java
similarity index 95%
rename from bikeshed/src/com/google/gwt/sample/tree/client/TreeNodeView.java
rename to bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java
index e159107..c82a8f3 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/client/TreeNodeView.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java
@@ -13,21 +13,21 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.client;
+package com.google.gwt.bikeshed.tree.client;
-import com.google.gwt.cells.client.Cell;
+import com.google.gwt.bikeshed.cells.client.Cell;
+import com.google.gwt.bikeshed.list.shared.ListEvent;
+import com.google.gwt.bikeshed.list.shared.ListHandler;
+import com.google.gwt.bikeshed.list.shared.ListModel;
+import com.google.gwt.bikeshed.list.shared.ListRegistration;
+import com.google.gwt.bikeshed.list.shared.SizeChangeEvent;
+import com.google.gwt.bikeshed.tree.client.TreeViewModel.NodeInfo;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.Style.Position;
-import com.google.gwt.list.shared.ListEvent;
-import com.google.gwt.list.shared.ListHandler;
-import com.google.gwt.list.shared.ListModel;
-import com.google.gwt.list.shared.ListRegistration;
-import com.google.gwt.list.shared.SizeChangeEvent;
-import com.google.gwt.sample.tree.client.TreeViewModel.NodeInfo;
import com.google.gwt.user.client.ui.Composite;
import java.util.ArrayList;
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/TreeView.java b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeView.java
similarity index 99%
rename from bikeshed/src/com/google/gwt/sample/tree/client/TreeView.java
rename to bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeView.java
index b640ef4..62b128b 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/client/TreeView.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeView.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.client;
+package com.google.gwt.bikeshed.tree.client;
import com.google.gwt.animation.client.Animation;
import com.google.gwt.core.client.GWT;
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/TreeViewModel.java b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeViewModel.java
similarity index 93%
rename from bikeshed/src/com/google/gwt/sample/tree/client/TreeViewModel.java
rename to bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeViewModel.java
index d45a9e9..78dc7e1 100644
--- a/bikeshed/src/com/google/gwt/sample/tree/client/TreeViewModel.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeViewModel.java
@@ -13,13 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.sample.tree.client;
+package com.google.gwt.bikeshed.tree.client;
-import com.google.gwt.cells.client.Cell;
-import com.google.gwt.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.cells.client.Cell;
+import com.google.gwt.bikeshed.cells.client.ValueUpdater;
+import com.google.gwt.bikeshed.list.shared.ListModel;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.list.shared.ListModel;
/**
* A model of a tree.
@@ -116,6 +116,5 @@
* @param value the value at the node
* @return true if the node is known to be a leaf node, false if not
*/
-
boolean isLeaf(Object value);
}
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/treeClosed.gif b/bikeshed/src/com/google/gwt/bikeshed/tree/client/treeClosed.gif
similarity index 100%
rename from bikeshed/src/com/google/gwt/sample/tree/client/treeClosed.gif
rename to bikeshed/src/com/google/gwt/bikeshed/tree/client/treeClosed.gif
Binary files differ
diff --git a/bikeshed/src/com/google/gwt/sample/tree/client/treeOpen.gif b/bikeshed/src/com/google/gwt/bikeshed/tree/client/treeOpen.gif
similarity index 100%
rename from bikeshed/src/com/google/gwt/sample/tree/client/treeOpen.gif
rename to bikeshed/src/com/google/gwt/bikeshed/tree/client/treeOpen.gif
Binary files differ
diff --git a/bikeshed/src/com/google/gwt/sample/stocks/client/Stocks.java b/bikeshed/src/com/google/gwt/sample/stocks/client/Stocks.java
deleted file mode 100644
index e995851..0000000
--- a/bikeshed/src/com/google/gwt/sample/stocks/client/Stocks.java
+++ /dev/null
@@ -1,383 +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.stocks.client;
-
-import com.google.gwt.cells.client.ButtonCell;
-import com.google.gwt.cells.client.CheckboxCell;
-import com.google.gwt.cells.client.CurrencyCell;
-import com.google.gwt.cells.client.FieldUpdater;
-import com.google.gwt.cells.client.TextCell;
-import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.KeyUpEvent;
-import com.google.gwt.event.dom.client.KeyUpHandler;
-import com.google.gwt.event.logical.shared.CloseEvent;
-import com.google.gwt.event.logical.shared.CloseHandler;
-import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.list.client.Column;
-import com.google.gwt.list.client.PagingTableListView;
-import com.google.gwt.list.shared.AsyncListModel;
-import com.google.gwt.list.shared.ListListModel;
-import com.google.gwt.list.shared.Range;
-import com.google.gwt.list.shared.AsyncListModel.DataSource;
-import com.google.gwt.sample.stocks.shared.StockQuote;
-import com.google.gwt.sample.stocks.shared.StockQuoteList;
-import com.google.gwt.sample.stocks.shared.StockRequest;
-import com.google.gwt.sample.stocks.shared.StockResponse;
-import com.google.gwt.sample.stocks.shared.Transaction;
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.TextBox;
-
-import java.util.List;
-
-/**
- * Entry point classes define <code>onModuleLoad()</code>.
- */
-public class Stocks implements EntryPoint {
-
- /**
- * The delay between updates in milliseconds.
- */
- private static final int UPDATE_DELAY = 5000;
-
- private Column<StockQuote, String> buyColumn = new Column<StockQuote, String>(
- new ButtonCell()) {
- @Override
- protected String getValue(StockQuote object) {
- return "Buy";
- }
- };
-
- /**
- * The popup used to purchase stock.
- */
- private BuySellPopup buySellPopup = new BuySellPopup();
-
- private final Label cashLabel = new Label();
-
- /**
- * The {@link StockService} used to retrieve data.
- */
- private final StockServiceAsync dataService = GWT.create(StockService.class);
-
- private final Label errorLabel = new Label();
-
- private Column<StockQuote, Boolean> favoriteColumn = new Column<StockQuote, Boolean>(
- new CheckboxCell()) {
- @Override
- protected Boolean getValue(StockQuote object) {
- return object.isFavorite();
- }
- };
-
- private AsyncListModel<StockQuote> favoritesListModel;
-
- private PagingTableListView<StockQuote> favoritesTable;
- private Column<StockQuote, String> nameColumn = new Column<StockQuote, String>(
- new TextCell()) {
- @Override
- protected String getValue(StockQuote object) {
- return object.getName();
- }
- };
-
- private Column<StockQuote, Integer> priceColumn = new Column<StockQuote, Integer>(
- new CurrencyCell()) {
- @Override
- protected Integer getValue(StockQuote object) {
- return object.getPrice();
- }
- };
-
- private final TextBox queryField = new TextBox();
-
- private PagingTableListView<StockQuote> resultsTable;
-
- private AsyncListModel<StockQuote> searchListModel;
-
- private Column<StockQuote, String> sellColumn = new Column<StockQuote, String>(
- new ButtonCell()) {
- @Override
- protected String getValue(StockQuote object) {
- return "Sell";
- }
- };
-
- private Column<StockQuote, String> sharesColumn = new Column<StockQuote, String>(
- new TextCell()) {
- @Override
- protected String getValue(StockQuote object) {
- return "" + object.getSharesOwned();
- }
- };
-
- private Column<Transaction, String> subtotalColumn = new Column<Transaction, String>(
- new TextCell()) {
- @Override
- protected String getValue(Transaction object) {
- int price = object.getActualPrice() * object.getQuantity();
- return (object.isBuy() ? " (" : " ") + getFormattedPrice(price) +
- (object.isBuy() ? ")" : "");
- }
- };
-
- private Column<StockQuote, String> tickerColumn = new Column<StockQuote, String>(
- new TextCell()) {
- @Override
- protected String getValue(StockQuote object) {
- return object.getTicker();
- }
- };
-
- private Column<Transaction, String> transactionColumn = new Column<Transaction, String>(
- new TextCell()) {
- @Override
- protected String getValue(Transaction object) {
- return object.toString();
- }
- };
-
- private ListListModel<Transaction> transactionListModel;
-
- private List<Transaction> transactions;
-
- private PagingTableListView<Transaction> transactionTable;
-
- /**
- * The timer used to update the stock quotes.
- */
- private Timer updateTimer = new Timer() {
- @Override
- public void run() {
- update();
- }
- };
-
- /**
- * This is the entry point method.
- */
- public void onModuleLoad() {
- queryField.setText("G");
-
- // Add the nameField and sendButton to the RootPanel
- // Use RootPanel.get() to get the entire body element
- RootPanel.get("queryFieldContainer").add(queryField);
- RootPanel.get("errorLabelContainer").add(errorLabel);
-
- // Focus the cursor on the name field when the app loads
- queryField.setFocus(true);
- queryField.selectAll();
-
- // Create the list models
- searchListModel = new AsyncListModel<StockQuote>(
- new DataSource<StockQuote>() {
- public void requestData(AsyncListModel<StockQuote> listModel) {
- update();
- }
- });
-
- favoritesListModel = new AsyncListModel<StockQuote>(
- new DataSource<StockQuote>() {
- public void requestData(AsyncListModel<StockQuote> listModel) {
- update();
- }
- });
-
- transactionListModel = new ListListModel<Transaction>();
- transactions = transactionListModel.getList();
-
- // Create the results table.
- resultsTable = new PagingTableListView<StockQuote>(searchListModel, 10);
- resultsTable.addColumn(favoriteColumn);
- resultsTable.addColumn(tickerColumn);
- resultsTable.addColumn(nameColumn);
- resultsTable.addColumn(priceColumn);
- resultsTable.addColumn(buyColumn);
-
- favoritesTable = new PagingTableListView<StockQuote>(favoritesListModel, 10);
- favoritesTable.addColumn(tickerColumn);
- favoritesTable.addColumn(priceColumn);
- favoritesTable.addColumn(sharesColumn);
- favoritesTable.addColumn(buyColumn);
- favoritesTable.addColumn(sellColumn);
-
- transactionTable = new PagingTableListView<Transaction>(transactionListModel, 10);
- transactionTable.addColumn(transactionColumn);
- transactionTable.addColumn(subtotalColumn);
-
- favoriteColumn.setFieldUpdater(new FieldUpdater<StockQuote, Boolean>() {
- public void update(StockQuote object, Boolean value) {
- setFavorite(object.getTicker(), value);
- }
- });
-
- buyColumn.setFieldUpdater(new FieldUpdater<StockQuote, String>() {
- public void update(StockQuote object, String value) {
- buySellPopup.setStockQuote(object, true);
- buySellPopup.center();
- }
- });
-
- sellColumn.setFieldUpdater(new FieldUpdater<StockQuote, String>() {
- public void update(StockQuote object, String value) {
- buySellPopup.setStockQuote(object, false);
- buySellPopup.center();
- }
- });
-
- buySellPopup.addCloseHandler(new CloseHandler<PopupPanel>() {
- public void onClose(CloseEvent<PopupPanel> event) {
- Transaction t = buySellPopup.getTransaction();
- if (t != null) {
- dataService.transact(t, new AsyncCallback<Transaction>() {
- public void onFailure(Throwable caught) {
- Window.alert("Error: " + caught.getMessage());
- }
-
- public void onSuccess(Transaction result) {
- transactions.add(0, result);
- update();
- }
- });
- }
- }
- });
-
- // Add components to the page.
- HorizontalPanel hPanel = new HorizontalPanel();
- hPanel.add(new HTML("<b>Available cash:</b>"));
- hPanel.add(cashLabel);
- RootPanel.get().add(hPanel);
-
- RootPanel.get().add(resultsTable);
- RootPanel.get().add(new HTML("<hr>"));
- RootPanel.get().add(favoritesTable);
- RootPanel.get().add(new HTML("<hr>"));
- RootPanel.get().add(transactionTable);
-
- // Add a handler to send the name to the server
- queryField.addKeyUpHandler(new KeyUpHandler() {
- public void onKeyUp(KeyUpEvent event) {
- update();
- }
- });
-
- update();
- }
-
- /**
- * Set or unset a ticker symbol as a 'favorite'.
- *
- * @param ticker the ticker symbol
- * @param favorite if true, make the stock a favorite
- */
- public void setFavorite(String ticker, boolean favorite) {
- if (favorite) {
- dataService.addFavorite(ticker, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- Window.alert("Error adding favorite");
- }
-
- public void onSuccess(Void result) {
- // do nothing
- }
- });
- } else {
- dataService.removeFavorite(ticker, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- Window.alert("Error removing favorite");
- }
-
- public void onSuccess(Void result) {
- // do nothing
- }
- });
- }
- }
-
- private String getFormattedPrice(int price) {
- return NumberFormat.getCurrencyFormat("USD").format(price / 100.0);
- }
-
- /**
- * Process the {@link StockResponse} from the server.
- *
- * @param response the stock response
- */
- private void processStockResponse(StockResponse response) {
- // Update the search list.
- StockQuoteList searchResults = response.getSearchResults();
- searchListModel.updateDataSize(response.getNumSearchResults(), true);
- searchListModel.updateViewData(searchResults.getStartIndex(),
- searchResults.size(), searchResults);
-
- // Update the favorites list.
- StockQuoteList favorites = response.getFavorites();
- favoritesListModel.updateDataSize(response.getNumFavorites(), true);
- favoritesListModel.updateViewData(favorites.getStartIndex(),
- favorites.size(), favorites);
-
- // Update available cash.
- int cash = response.getCash();
- cashLabel.setText(getFormattedPrice(cash));
- buySellPopup.setAvailableCash(cash);
-
- // Restart the update timer.
- updateTimer.schedule(UPDATE_DELAY);
- }
-
- /**
- * Request data from the server using the last query string.
- */
- private void update() {
- updateTimer.cancel();
-
- Range[] searchRanges = searchListModel.getRanges();
- Range[] favoritesRanges = favoritesListModel.getRanges();
-
- if (searchRanges == null || searchRanges.length == 0
- || favoritesRanges == null || favoritesRanges.length == 0) {
- return;
- }
-
- String searchQuery = queryField.getText();
- StockRequest request = new StockRequest(searchQuery, searchRanges[0],
- favoritesRanges[0]);
- dataService.getStockQuotes(request, new AsyncCallback<StockResponse>() {
- public void onFailure(Throwable caught) {
- String message = caught.getMessage();
- if (message.contains("Not logged in")) {
- // Force the user to login.
- Window.Location.reload();
- } else {
- Window.alert("ERROR: " + caught.getMessage());
- updateTimer.schedule(UPDATE_DELAY);
- }
- }
-
- public void onSuccess(StockResponse result) {
- processStockResponse(result);
- }
- });
- }
-}
diff --git a/bikeshed/war/WEB-INF/web.xml b/bikeshed/war/WEB-INF/web.xml
index a2c7cb2..0c3db41 100644
--- a/bikeshed/war/WEB-INF/web.xml
+++ b/bikeshed/war/WEB-INF/web.xml
@@ -8,12 +8,12 @@
<!-- Servlets -->
<servlet>
<servlet-name>stockServlet</servlet-name>
- <servlet-class>com.google.gwt.sample.stocks.server.StockServiceImpl</servlet-class>
+ <servlet-class>com.google.gwt.bikeshed.sample.stocks.server.StockServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>treeServlet</servlet-name>
- <servlet-class>com.google.gwt.sample.tree.server.TreeServiceImpl</servlet-class>
+ <servlet-class>com.google.gwt.bikeshed.sample.tree.server.TreeServiceImpl</servlet-class>
</servlet>
<servlet-mapping>