My favorites
|
Sign in
gwtsite
The source code from the demos hosted at gwtsite.com
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
‹r9
r25
Source path:
svn
/
trunk
/
ShoppingCart
/
src
/
com
/
gwtsite
/
dnd
/
client
/
ShoppingCartDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Copyright 2008 Chris Fong
*
* 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.gwtsite.dnd.client;
import java.math.BigDecimal;
import java.util.Iterator;
import com.allen_sauer.gwt.dnd.client.DragContext;
import com.allen_sauer.gwt.dnd.client.PickupDragController;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class ShoppingCartDemo implements EntryPoint {
private final static Book[] books = new Book[] {
new Book("GWT In Action", new BigDecimal("31.49"), "gwt_in_action.jpg"),
new Book("GWT in Practice", new BigDecimal("31.49"), "gwt_in_practice.jpg"),
new Book("Google Web Toolkit Solutions", new BigDecimal("33.10"), "gwt_solutions.jpg"),
new Book("Accelerated GWT", new BigDecimal("24.41"), "accelerated_gwt.jpg"),
new Book("GWT Java Ajax Programming", new BigDecimal("44.99"), "gwt_java_ajax.jpg"),
new Book("Google Web Toolkit Applications", new BigDecimal("41.10"), "gwtapps.jpg"),
new Book("Google Web Toolkit: Taking the Pain Out of Ajax", new BigDecimal("8.50"), "taking_the_pain.jpg")
};
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
AbsolutePanel containingPanel = new AbsolutePanel();
containingPanel.setPixelSize(650, 600);
PickupDragController dragController = new PickupDragController(containingPanel, false) {
protected Widget newDragProxy(DragContext context) {
AbsolutePanel container = new AbsolutePanel();
DOM.setStyleAttribute(container.getElement(), "overflow", "visible");
for (Iterator iterator = context.selectedWidgets.iterator(); iterator.hasNext();) {
Widget widget = (Widget) iterator.next();
Book book = (Book)widget;
container.add(new Image(book.getImageUrl()));
}
return container;
}
};
dragController.setBehaviorDragProxy(true);
FlowPanel flowPanel = new FlowPanel();
flowPanel.addStyleName("flowPanel");
for (int i = 0; i < books.length; i++)
{
Book book = books[i];
dragController.makeDraggable(book, book.getImage());
flowPanel.add(book);
}
ShoppingCart cart = new ShoppingCart();
CartDropController dropController = new CartDropController(cart);
dragController.registerDropController(dropController);
containingPanel.add(cart);
containingPanel.add(flowPanel);
rootPanel.add(new HTML("<h3>Drag some books to your cart</h3>"));
rootPanel.add(containingPanel);
}
}
Show details
Hide details
Change log
r10
by fongcn on Feb 13, 2008
Diff
Add licensing
Go to:
...com/gwtsite/dnd/client/Book.java
...d/client/CartDropController.java
...ite/dnd/client/ShoppingCart.java
...dnd/client/ShoppingCartDemo.java
...dnd/public/ShoppingCartDemo.html
Project members,
sign in
to write a code review
Older revisions
r9
by fongcn on Feb 13, 2008
Diff
refactoring
r8
by fongcn on Feb 13, 2008
Diff
[No log message]
r7
by fongcn on Feb 13, 2008
Diff
[No log message]
All revisions of this file
File info
Size: 3301 bytes, 85 lines
View raw file
Hosted by