diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-09-12 07:41:36 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-09-12 07:41:36 +0000 |
commit | 466a74baf50267a896cb3446e82879004989455d (patch) | |
tree | 42795fe94a73960f6445a8c621a5593117cac0c8 | |
parent | f6a7772532969c3267abb9c045c046292237ffe9 (diff) | |
download | vaadin-framework-466a74baf50267a896cb3446e82879004989455d.tar.gz vaadin-framework-466a74baf50267a896cb3446e82879004989455d.zip |
Reservr updates
svn changeset:2282/svn branch:trunk
3 files changed, 74 insertions, 30 deletions
diff --git a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java index e0f7ae4574..9e6363427a 100644 --- a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java +++ b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java @@ -34,7 +34,8 @@ public class ReservationApplication extends Application { private TextField description;
private Button reservationButton;
- Table allReservations;
+ private Table allTable;
+ private CalendarField allCalendar;
public void init() {
db = new SampleDB(true);
@@ -67,10 +68,10 @@ public class ReservationApplication extends Application { OrderedLayout infoLayout = new OrderedLayout();
reservationPanel.addComponent(infoLayout);
resourceName = new Label("Choose resource");
- resourceName.setCaption("Selected resource");
+ resourceName.setCaption("Reserving resource");
infoLayout.addComponent(resourceName);
description = new TextField();
- description.setColumns(30);
+ description.setColumns(40);
description.setRows(5);
infoLayout.addComponent(description);
reservationButton = new Button("Make reservation", this,
@@ -111,9 +112,22 @@ public class ReservationApplication extends Application { });
reservedFrom.setImmediate(true);
reservedFrom.setValue(now);
-
- allReservations = new Table();
- mainTabs.addTab(allReservations, "All reservations", null);
+ reservedTo.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ refreshSelectedResources();
+ resetStatus();
+ }
+ });
+ reservedTo.setImmediate(true);
+ reservedTo.setValue(now);
+
+ OrderedLayout allLayout = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
+ allCalendar = new CalendarField();
+ initCalendarFieldPropertyIds(allCalendar);
+ allLayout.addComponent(allCalendar);
+ allTable = new Table();
+ allLayout.addComponent(allTable);
+ mainTabs.addTab(allLayout, "All reservations", null);
mainTabs.addListener(new TabSheet.SelectedTabChangeListener() {
public void selectedTabChange(SelectedTabChangeEvent event) {
refreshReservations();
@@ -166,7 +180,10 @@ public class ReservationApplication extends Application { reservedFrom.setContainerDataSource(reservations);
reservedTo.setContainerDataSource(reservations);
refreshSelectedResources();
- allReservations.setContainerDataSource(db.getReservations(null));
+ Container allReservations = db.getReservations(null);
+ allTable.setContainerDataSource(allReservations);
+ allCalendar.setContainerDataSource(allReservations);
+
}
private void refreshSelectedResources() {
diff --git a/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java b/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java index 170a53c984..744447d240 100644 --- a/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java +++ b/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java @@ -53,7 +53,7 @@ public class ResourceSelectorPanel extends Panel implements resourceList = new LinkedList();
categoryResources.put(category, resourceList);
Button cButton = new Button(category + " (any)", this);
- cButton.setStyle("link");
+ cButton.setStyle("important-link");
cButton.setData(category);
resourceLayout.addComponent(cButton);
}
@@ -77,6 +77,7 @@ public class ResourceSelectorPanel extends Panel implements if (source instanceof Button) {
Object data = ((Button) source).getData();
String name = ((Button) source).getCaption();
+ resetStyles();
if (data instanceof Item) {
LinkedList rlist = new LinkedList();
rlist.add(data);
@@ -87,9 +88,25 @@ public class ResourceSelectorPanel extends Panel implements .get(category);
setSelectedResources(resources);
}
+ ((Button)source).setStyle("selected-link");
}
}
+
+ private void resetStyles() {
+ for (Iterator it = categoryLayouts.values().iterator();it.hasNext();) {
+ Layout lo = (Layout)it.next();
+ for (Iterator bit = lo.getComponentIterator();bit.hasNext();) {
+ Button b = (Button)bit.next();
+ if (b.getData() instanceof Item) {
+ b.setStyle("link");
+ } else {
+ b.setStyle("important-link");
+ }
+ }
+ }
+
+ }
public class SelectedResourcesChangedEvent extends Event {
public SelectedResourcesChangedEvent() {
diff --git a/src/com/itmill/toolkit/demo/reservation/SampleDB.java b/src/com/itmill/toolkit/demo/reservation/SampleDB.java index f5482e70b0..bc1f5b04e9 100644 --- a/src/com/itmill/toolkit/demo/reservation/SampleDB.java +++ b/src/com/itmill/toolkit/demo/reservation/SampleDB.java @@ -17,34 +17,42 @@ import com.itmill.toolkit.data.util.QueryContainer; public class SampleDB { public class User { public static final String TABLE = "USER"; - public static final String PROPERTY_ID_ID = TABLE+"_ID"; - public static final String PROPERTY_ID_FULLNAME = TABLE+"_FULLNAME"; - public static final String PROPERTY_ID_EMAIL = TABLE+"_EMAIL"; - public static final String PROPERTY_ID_PASSWORD = TABLE+"_PASSWORD"; - public static final String PROPERTY_ID_DELETED = TABLE+"_DELETED"; + public static final String PROPERTY_ID_ID = TABLE + "_ID"; + public static final String PROPERTY_ID_FULLNAME = TABLE + "_FULLNAME"; + public static final String PROPERTY_ID_EMAIL = TABLE + "_EMAIL"; + public static final String PROPERTY_ID_PASSWORD = TABLE + "_PASSWORD"; + public static final String PROPERTY_ID_DELETED = TABLE + "_DELETED"; } public class Resource { public static final String TABLE = "RESOURCE"; - public static final String PROPERTY_ID_ID = TABLE+"_ID"; - public static final String PROPERTY_ID_NAME = TABLE+"_NAME"; - public static final String PROPERTY_ID_DESCRIPTION = TABLE+"_DESCRIPTION"; - public static final String PROPERTY_ID_LOCATIONX = TABLE+"_LOCATION_X"; - public static final String PROPERTY_ID_LOCATIONY = TABLE+"_LOCATION_Y"; - public static final String PROPERTY_ID_CATEGORY = TABLE+"_CATEGORY"; - public static final String PROPERTY_ID_DELETED = TABLE+"_DELETED"; + public static final String PROPERTY_ID_ID = TABLE + "_ID"; + public static final String PROPERTY_ID_NAME = TABLE + "_NAME"; + public static final String PROPERTY_ID_DESCRIPTION = TABLE + + "_DESCRIPTION"; + public static final String PROPERTY_ID_LOCATIONX = TABLE + + "_LOCATION_X"; + public static final String PROPERTY_ID_LOCATIONY = TABLE + + "_LOCATION_Y"; + public static final String PROPERTY_ID_CATEGORY = TABLE + "_CATEGORY"; + public static final String PROPERTY_ID_DELETED = TABLE + "_DELETED"; } public class Reservation { public static final String TABLE = "RESERVATION"; - public static final String PROPERTY_ID_ID = TABLE+"_ID"; - public static final String PROPERTY_ID_DESCRIPTION = TABLE+"_DESCRIPTION"; - public static final String PROPERTY_ID_RESOURCE_ID = TABLE+"_RESOURCE_ID"; - public static final String PROPERTY_ID_RESERVED_BY_ID = TABLE+"_RESERVED_BY_USER_ID"; - public static final String PROPERTY_ID_RESERVED_FROM = TABLE+"_RESERVED_FROM"; - public static final String PROPERTY_ID_RESERVED_TO = TABLE+"_RESERVED_TO"; + public static final String PROPERTY_ID_ID = TABLE + "_ID"; + public static final String PROPERTY_ID_DESCRIPTION = TABLE + + "_DESCRIPTION"; + public static final String PROPERTY_ID_RESOURCE_ID = TABLE + + "_RESOURCE_ID"; + public static final String PROPERTY_ID_RESERVED_BY_ID = TABLE + + "_RESERVED_BY_USER_ID"; + public static final String PROPERTY_ID_RESERVED_FROM = TABLE + + "_RESERVED_FROM"; + public static final String PROPERTY_ID_RESERVED_TO = TABLE + + "_RESERVED_TO"; } - + // TODO -> param private static final String DB_URL = "jdbc:hsqldb:file:reservation.db"; @@ -247,8 +255,9 @@ public class SampleDB { // TODO where from=? // TODO where to=? // TODO where deleted=? - String q = "SELECT * FROM " + Reservation.TABLE + "," +Resource.TABLE; - q += " WHERE " + Reservation.PROPERTY_ID_RESOURCE_ID+"="+Resource.PROPERTY_ID_ID; + String q = "SELECT * FROM " + Reservation.TABLE + "," + Resource.TABLE; + q += " WHERE " + Reservation.PROPERTY_ID_RESOURCE_ID + "=" + + Resource.PROPERTY_ID_ID; if (resources != null && resources.size() > 0) { StringBuilder s = new StringBuilder(); for (Iterator it = resources.iterator(); it.hasNext();) { @@ -295,7 +304,8 @@ public class SampleDB { synchronized (DB_URL) { try { if (!isAvailableResource(resourceId, reservedFrom, reservedTo)) { - throw new ResourceNotAvailableException("The resource is not available at that time."); + throw new ResourceNotAvailableException( + "The resource is not available at that time."); } PreparedStatement p = connection.prepareStatement(q); p.setInt(1, resourceId); |