You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kandula-dev@ws.apache.org by he...@apache.org on 2007/07/13 18:48:24 UTC
svn commit: r556065 [3/3] - in
/webservices/kandula/branches/Kandula_1/src/samples: ba-testsuite/
ba-testsuite/src/ ba-testsuite/src/org/ ba-testsuite/src/org/apache/
ba-testsuite/src/org/apache/kandula/
ba-testsuite/src/org/apache/kandula/test/ ba-tes...
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/Handler.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/Handler.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/Handler.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/Handler.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.rmi.RemoteException;
+import java.util.Calendar;
+
+import org.apache.axis.AxisFault;
+import org.apache.kandula.coordinator.CoordinationContext;
+import org.apache.kandula.demo.ba.holiday.DateSpec;
+import org.apache.kandula.demo.ba.holiday.LocSpec;
+import org.apache.kandula.demo.ba.holiday.car.CarOfferType;
+import org.apache.kandula.demo.ba.holiday.car.CarRentalPersonType;
+import org.apache.kandula.demo.ba.holiday.car.CarRequirements;
+import org.apache.kandula.demo.ba.holiday.car.RentACarBookingRequest;
+import org.apache.kandula.demo.ba.holiday.car.RentACarBookingResponse;
+import org.apache.kandula.demo.ba.holiday.car.RentACarOfferRequest;
+import org.apache.kandula.demo.ba.holiday.car.RentACarOfferResponse;
+import org.apache.kandula.demo.ba.holiday.car.RentACarPortTypeBindingStub;
+import org.apache.kandula.demo.ba.holiday.room.RentARoomBookingRequest;
+import org.apache.kandula.demo.ba.holiday.room.RentARoomBookingResponse;
+import org.apache.kandula.demo.ba.holiday.room.RentARoomOfferRequest;
+import org.apache.kandula.demo.ba.holiday.room.RentARoomOfferResponse;
+import org.apache.kandula.demo.ba.holiday.room.RentARoomPortTypeBindingStub;
+import org.apache.kandula.demo.ba.holiday.room.RoomOfferType;
+import org.apache.kandula.demo.ba.holiday.room.RoomRentalPersonType;
+import org.apache.kandula.demo.ba.holiday.room.RoomRequirements;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class Handler {
+
+ private static TableOfferEntry[] handleCarOffers(CarOfferType[] offers) {
+ int count = offers.length;
+ TableOfferEntry[] offerEntries = new TableOfferEntry[count];
+ for (int i = 0; i < count; i++) {
+ CarOfferType offer = offers[i];
+ offerEntries[i] = new CarTableOfferEntry(
+ offer.getCarBookingReference(), offer.getCarSpec(), offer.getLocSpec(),
+ offer.getDateSpec(), offer.getPrice(), offer.getPayment(), offer.getOfferExpires()
+ );
+ }
+ return offerEntries;
+ }
+
+ private static TableOfferEntry[] handleRoomOffers(RoomOfferType[] offers) {
+ int count = offers.length;
+ TableOfferEntry[] offerEntries = new TableOfferEntry[count];
+ for (int i = 0; i < count; i++) {
+ RoomOfferType offer = offers[i];
+ offerEntries[i] = new RoomTableOfferEntry(
+ offer.getRoomBookingReference(), offer.getRoomSpec(), offer.getLocSpec().getLocation(),
+ offer.getDateSpec(), offer.getPrice(), offer.getPayment(),
+ offer.getOfferExpires()
+ );
+ }
+ return offerEntries;
+ }
+
+ public static TableOfferEntry[] searchForCarOffers(CarRequirements carReq, DateSpec date, LocSpec loc) throws MalformedURLException, RemoteException {
+ RentACarPortTypeBindingStub stub = null;
+ try {
+ // TODO HOLIDAY make service URLs configurable
+ stub = new RentACarPortTypeBindingStub(new URL("http://localhost:8181/axis/services/RentACarServicePort"), null);
+ } catch (AxisFault e) {
+ e.printStackTrace();
+ throw e;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ RentACarOfferRequest params =
+ new RentACarOfferRequest(
+ carReq,
+ date.getCarDateSpec(),
+ loc.getCarLocSpec(),
+ new CarRentalPersonType(),
+ new CarRentalPersonType()
+ );
+
+ try {
+ RentACarOfferResponse resp = stub.getOffers(params);
+ if (resp != null) {
+ return handleCarOffers(resp.getCarOffer());
+ }
+ return new TableOfferEntry[0];
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ public static TableOfferEntry[] searchForRoomOffers(RoomRequirements roomReq, DateSpec date, LocSpec loc) throws MalformedURLException, RemoteException {
+ RentARoomPortTypeBindingStub stub = null;
+ try {
+ // TODO HOLIDAY make service URLs configurable
+ stub = new RentARoomPortTypeBindingStub(new URL("http://localhost:8181/axis/services/RentARoomServicePort"), null);
+ } catch (AxisFault e) {
+ e.printStackTrace();
+ throw e;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ RentARoomOfferRequest params =
+ new RentARoomOfferRequest(
+ roomReq,
+ date.getRoomDateSpec(),
+ loc.getRoomLocSpec(),
+ new RoomRentalPersonType()
+ );
+
+ try {
+ RentARoomOfferResponse resp = stub.getOffers(params);
+ if (resp != null) {
+ return handleRoomOffers(resp.getRoomOffer());
+ }
+ return new TableOfferEntry[0];
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ public static BasketEntry book(
+ final CoordinationContext cc,
+ final String matchcode,
+ final TableOfferEntry toe
+ ) throws AxisFault, RemoteException, MalformedURLException{
+
+ final String bookRef;
+ final Calendar compensateUntil;
+
+ if (toe instanceof CarTableOfferEntry){
+ final RentACarBookingResponse resp = bookCar(cc, (CarTableOfferEntry) toe);
+ bookRef = resp.getCarBookingReference();
+ compensateUntil = resp.getCompensateUntil();
+ }else if (toe instanceof RoomTableOfferEntry){
+ final RentARoomBookingResponse resp = bookRoom(cc, (RoomTableOfferEntry) toe);
+ bookRef= resp.getRoomBookingReference();
+ compensateUntil = resp.getCompensateUntil();
+ }else{
+ throw new IllegalArgumentException("Unknown offer type "+toe.getClass().getName());
+ }
+
+ final BasketEntry be = new BasketEntry(matchcode, null, toe, bookRef, compensateUntil);
+
+ return be;
+ }
+
+ public static RentACarBookingResponse bookCar(
+ final CoordinationContext ctx,
+ final CarTableOfferEntry carOffer
+ ) throws MalformedURLException, RemoteException {
+ RentACarPortTypeBindingStub stub = null;
+ try {
+ // TODO HOLIDAY make service URLs configurable
+ stub = new RentACarPortTypeBindingStub(new URL("http://localhost:8181/axis/services/RentACarServicePort"), null);
+ } catch (AxisFault e) {
+ e.printStackTrace();
+ throw e;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ throw e;
+ }
+
+ final RentACarBookingRequest params =
+ new RentACarBookingRequest(
+ new org.apache.kandula.demo.ba.holiday.car.ContextChoiceType(ctx),
+ carOffer.getBookingReference()
+ );
+ final RentACarBookingResponse resp = stub.doBooking(params);
+ return resp ;
+ }
+
+ private static RentARoomBookingResponse bookRoom(
+ final CoordinationContext ctx,
+ final RoomTableOfferEntry roomOffer
+ ) throws MalformedURLException, RemoteException {
+ RentARoomPortTypeBindingStub stub = null;
+ try {
+ // TODO HOLIDAY make service URLs configurable
+ stub = new RentARoomPortTypeBindingStub(new URL("http://localhost:8181/axis/services/RentARoomServicePort"), null);
+ } catch (AxisFault e) {
+ e.printStackTrace();
+ throw e;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ throw e;
+ }
+
+ final RentARoomBookingRequest params =
+ new RentARoomBookingRequest(
+ new org.apache.kandula.demo.ba.holiday.room.ContextChoiceType(ctx),
+ roomOffer.getBookingReference()
+ );
+ final RentARoomBookingResponse resp = stub.doBooking(params);
+ return resp ;
+ }
+
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterClientJFrame.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterClientJFrame.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterClientJFrame.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterClientJFrame.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.awt.BorderLayout;
+import javax.swing.JPanel;
+import java.awt.GraphicsConfiguration;
+import java.awt.HeadlessException;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JTabbedPane;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class RenterClientJFrame extends JFrame {
+
+ private static final long serialVersionUID = 1L;
+
+ private JPanel jContentPane = null;
+
+ private JTabbedPane jTabbedPane = null;
+
+ private RenterSearchAndResultPanel renterSearchAndResultPanel = null;
+
+ public static BasketPanel basketPanel = null;
+
+ /**
+ * @throws HeadlessException
+ */
+ public RenterClientJFrame() throws HeadlessException {
+ // TODO Auto-generated constructor stub
+ super();
+ initialize();
+ }
+
+ /**
+ * @param gc
+ */
+ public RenterClientJFrame(GraphicsConfiguration gc) {
+ super(gc);
+ // TODO Auto-generated constructor stub
+ initialize();
+ }
+
+ /**
+ * @param title
+ * @throws HeadlessException
+ */
+ public RenterClientJFrame(String title) throws HeadlessException {
+ super(title);
+ // TODO Auto-generated constructor stub
+ initialize();
+ }
+
+ /**
+ * @param title
+ * @param gc
+ */
+ public RenterClientJFrame(String title, GraphicsConfiguration gc) {
+ super(title, gc);
+ // TODO Auto-generated constructor stub
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ super.windowClosing(e);
+ System.exit(0);
+ }
+ });
+ this.setSize(300, 500);
+ this.setContentPane(getJContentPane());
+ }
+
+ /**
+ * This method initializes jContentPane
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane() {
+ if (this.jContentPane == null) {
+ this.jContentPane = new JPanel();
+ this.jContentPane.setLayout(new BorderLayout());
+ this.jContentPane.add(getJTabbedPane(), BorderLayout.CENTER); // Generated
+ }
+ return this.jContentPane;
+ }
+
+ /**
+ * This method initializes jTabbedPane
+ *
+ * @return javax.swing.JTabbedPane
+ */
+ private JTabbedPane getJTabbedPane() {
+ if (this.jTabbedPane == null) {
+ this.jTabbedPane = new JTabbedPane();
+ this.jTabbedPane.addTab("Search for Offers", null, getRenterSearchAndResultPanel(), null); // Generated
+ this.jTabbedPane.addTab("Basket", null, getBasketPanel(), null); // Generated
+ }
+ return this.jTabbedPane;
+ }
+
+ /**
+ * This method initializes renterSearchAndResultPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private RenterSearchAndResultPanel getRenterSearchAndResultPanel() {
+ if (this.renterSearchAndResultPanel == null) {
+ this.renterSearchAndResultPanel = new RenterSearchAndResultPanel();
+ }
+ return this.renterSearchAndResultPanel;
+ }
+
+ /**
+ * This method initializes basketPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private BasketPanel getBasketPanel() {
+ if (basketPanel == null) {
+ basketPanel = new BasketPanel();
+ }
+ return basketPanel;
+ }
+
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchAndResultPanel.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchAndResultPanel.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchAndResultPanel.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchAndResultPanel.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import javax.swing.JPanel;
+import java.awt.BorderLayout;
+import javax.swing.JSplitPane;
+
+public class RenterSearchAndResultPanel extends JPanel implements SearchListener {
+
+ private static final long serialVersionUID = 1L;
+ private JSplitPane jSplitPane = null;
+ private RenterSearchPanel renterSearchPanel = null;
+ public static RenterSearchResultPanel rentersearchResultPanel = null;
+
+ /**
+ * This is the default constructor
+ */
+ public RenterSearchAndResultPanel() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(400, 400);
+ this.setLayout(new BorderLayout());
+ this.add(getJSplitPane(), BorderLayout.CENTER); // Generated
+ }
+
+ /**
+ * This method initializes jSplitPane
+ *
+ * @return javax.swing.JSplitPane
+ */
+ private JSplitPane getJSplitPane() {
+ if (this.jSplitPane == null) {
+ this.jSplitPane = new JSplitPane();
+ this.jSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); // Generated
+ this.jSplitPane.setDividerSize(7); // Generated
+ this.jSplitPane.setTopComponent(getRenterSearchPanel()); // Generated
+ this.jSplitPane.setBottomComponent(getRentersearchResultPanel()); // Generated
+ }
+ return this.jSplitPane;
+ }
+
+ /**
+ * This method initializes rentersearchResultPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private RenterSearchResultPanel getRentersearchResultPanel() {
+ if (rentersearchResultPanel == null) {
+ rentersearchResultPanel = new RenterSearchResultPanel();
+ }
+ return rentersearchResultPanel;
+ }
+
+ /**
+ * This method initializes renterSearchPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private RenterSearchPanel getRenterSearchPanel() {
+ if (this.renterSearchPanel == null) {
+ this.renterSearchPanel = new RenterSearchPanel();
+ this.renterSearchPanel.addListener(this);
+ }
+ return this.renterSearchPanel;
+ }
+
+ public void searchFinished(SearchEvent e) {
+ System.out.println("Search finished!");
+ this.getRentersearchResultPanel().addTableOfferEntries(e.getToe());
+ }
+
+ public void searchClear() {
+ this.getRentersearchResultPanel().clearTableOffers();
+ }
+
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchCarPanel.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchCarPanel.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchCarPanel.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchCarPanel.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,300 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.awt.GridBagLayout;
+
+import javax.swing.JFormattedTextField;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import java.awt.GridBagConstraints;
+import javax.swing.JTextField;
+import javax.swing.JComboBox;
+
+import org.apache.axis.types.PositiveInteger;
+import org.apache.kandula.demo.ba.holiday.car.CarRequirements;
+import org.apache.kandula.demo.ba.holiday.DateSpec;
+import org.apache.kandula.demo.ba.holiday.LocSpec;
+
+import java.awt.Dimension;
+import java.util.Date;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class RenterSearchCarPanel extends JPanel implements SearchDetailInterface {
+
+ private static final long serialVersionUID = 1L;
+ private JLabel jLabel_Who = null;
+ private JLabel jLabel_When = null;
+ private JLabel jLabel_Where = null;
+ private JLabel jLabel_passengerCount = null;
+ private JTextField jTextField_Who = null;
+ private JFormattedTextField jTextField_WhenFrom = null;
+ private JTextField jTextField_Where = null;
+ private JComboBox jComboBox_PassengerCount = null;
+ private JFormattedTextField jTextField_WhenTo = null;
+ private JTextField jTextField_WhereTo = null;
+
+ /**
+ * This is the default constructor
+ */
+ public RenterSearchCarPanel() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
+ gridBagConstraints21.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints21.gridy = 2; // Generated
+ gridBagConstraints21.weightx = 1.0; // Generated
+ gridBagConstraints21.gridx = 2; // Generated
+ GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
+ gridBagConstraints11.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints11.gridy = 1; // Generated
+ gridBagConstraints11.weightx = 1.0; // Generated
+ gridBagConstraints11.gridx = 2; // Generated
+ GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
+ gridBagConstraints7.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints7.gridy = 3; // Generated
+ gridBagConstraints7.weightx = 1.0; // Generated
+ gridBagConstraints7.gridwidth = 2; // Generated
+ gridBagConstraints7.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
+ gridBagConstraints6.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints6.gridy = 2; // Generated
+ gridBagConstraints6.weightx = 1.0; // Generated
+ gridBagConstraints6.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+ gridBagConstraints5.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints5.gridy = 1; // Generated
+ gridBagConstraints5.weightx = 1.0; // Generated
+ gridBagConstraints5.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
+ gridBagConstraints4.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints4.gridy = 0; // Generated
+ gridBagConstraints4.weightx = 1.0; // Generated
+ gridBagConstraints4.gridwidth = 2; // Generated
+ gridBagConstraints4.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+ gridBagConstraints3.anchor = GridBagConstraints.EAST;
+ gridBagConstraints3.gridx = 0; // Generated
+ gridBagConstraints3.gridy = 3; // Generated
+ GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+ gridBagConstraints2.anchor = GridBagConstraints.EAST;
+ gridBagConstraints2.gridx = 0; // Generated
+ gridBagConstraints2.gridy = 2; // Generated
+ GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+ gridBagConstraints1.anchor = GridBagConstraints.EAST;
+ gridBagConstraints1.gridx = 0; // Generated
+ gridBagConstraints1.gridy = 1; // Generated
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.anchor = GridBagConstraints.EAST;
+ gridBagConstraints.gridx = 0; // Generated
+ gridBagConstraints.gridy = 0; // Generated
+ this.setSize(300, 88);
+ this.setLayout(new GridBagLayout());
+ this.setPreferredSize(new Dimension(300, 88)); // Generated
+ this.add(getJLabel_Who(), gridBagConstraints); // Generated
+ this.add(getJLabel_When(), gridBagConstraints1); // Generated
+ this.add(getJLabel_Where(), gridBagConstraints2); // Generated
+ this.add(getJLabel_passengerCount(), gridBagConstraints3); // Generated
+ this.add(getJTextField_Who(), gridBagConstraints4); // Generated
+ this.add(getJTextField_WhenFrom(), gridBagConstraints5); // Generated
+ this.add(getJTextField_Where(), gridBagConstraints6); // Generated
+ this.add(getJComboBox_PassengerCount(), gridBagConstraints7); // Generated
+ this.add(getJTextField_WhenTo(), gridBagConstraints11); // Generated
+ this.add(getJTextField_WhereTo(), gridBagConstraints21); // Generated
+ }
+
+ /**
+ * @return Returns the jLabel_Who.
+ */
+ public JLabel getJLabel_Who() {
+ if (this.jLabel_Who == null) {
+ this.jLabel_Who = new JLabel();
+ this.jLabel_Who.setText("who:"); // Generated
+ jLabel_Who.setVisible(false);
+ }
+ return this.jLabel_Who;
+ }
+
+ /**
+ * This method initializes jTextField_Who
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextField_Who() {
+ if (this.jTextField_Who == null) {
+ this.jTextField_Who = new JTextField();
+ jTextField_Who.setVisible(false);
+ }
+ return this.jTextField_Who;
+ }
+
+ /**
+ * @return Returns the jLabel_When.
+ */
+ public JLabel getJLabel_When() {
+ if (this.jLabel_When == null) {
+ this.jLabel_When = new JLabel();
+ this.jLabel_When.setText("when:"); // Generated
+ }
+ return this.jLabel_When;
+ }
+
+ /**
+ * This method initializes jTextField_WhenFrom
+ *
+ * @return javax.swing.JTextField
+ */
+ private JFormattedTextField getJTextField_WhenFrom() {
+ if (this.jTextField_WhenFrom == null) {
+ this.jTextField_WhenFrom = new JFormattedTextField();
+ this.jTextField_WhenFrom.setValue(new Date());
+ }
+ return this.jTextField_WhenFrom;
+ }
+
+ /**
+ * This method initializes jTextField_WhenTo
+ *
+ * @return javax.swing.JTextField
+ */
+ private JFormattedTextField getJTextField_WhenTo() {
+ if (this.jTextField_WhenTo == null) {
+ this.jTextField_WhenTo = new JFormattedTextField();
+ this.jTextField_WhenTo.setValue(new Date());
+ }
+ return this.jTextField_WhenTo;
+ }
+
+ /**
+ * This method initializes jTextField_Where
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextField_Where() {
+ if (this.jTextField_Where == null) {
+ this.jTextField_Where = new JTextField();
+ }
+ return this.jTextField_Where;
+ }
+
+ /**
+ * @return Returns the jLabel_Where.
+ */
+ public JLabel getJLabel_Where() {
+ if (this.jLabel_Where == null) {
+ this.jLabel_Where = new JLabel();
+ this.jLabel_Where.setText("where:"); // Generated
+ }
+ return this.jLabel_Where;
+ }
+
+ /**
+ * This method initializes jComboBox_PassengerCount
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBox_PassengerCount() {
+ if (this.jComboBox_PassengerCount == null) {
+ this.jComboBox_PassengerCount = new JComboBox();
+ this.jComboBox_PassengerCount.addItem(new String("1"));
+ this.jComboBox_PassengerCount.addItem(new String("2"));
+ this.jComboBox_PassengerCount.addItem(new String("3"));
+ this.jComboBox_PassengerCount.addItem(new String("4"));
+ this.jComboBox_PassengerCount.addItem(new String("5"));
+ this.jComboBox_PassengerCount.addItem(new String("6"));
+ this.jComboBox_PassengerCount.addItem(new String("7"));
+ this.jComboBox_PassengerCount.addItem(new String("8"));
+ }
+ return this.jComboBox_PassengerCount;
+ }
+
+
+ /**
+ * @return Returns the jLabel_passengerCount.
+ */
+ public JLabel getJLabel_passengerCount() {
+ if (this.jLabel_passengerCount == null) {
+ this.jLabel_passengerCount = new JLabel();
+ this.jLabel_passengerCount.setText("min passengercount:"); // Generated
+ }
+ return this.jLabel_passengerCount;
+ }
+
+ /**
+ * This method initializes jTextField_WhereTo
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextField_WhereTo() {
+ if (this.jTextField_WhereTo == null) {
+ this.jTextField_WhereTo = new JTextField();
+ }
+ return this.jTextField_WhereTo;
+ }
+
+ public String getWho() {
+ return this.getJTextField_Who().getText();
+ }
+
+ public String getWhenFrom() {
+ return ((Date)this.getJTextField_WhenFrom().getValue()).toString();
+ }
+
+ public String getWhenTo() {
+ return ((Date)this.getJTextField_WhenTo().getValue()).toString();
+ }
+
+ public String getWhereFrom() {
+ return this.getJTextField_Where().getText();
+ }
+
+ public String getWhereTo() {
+ return this.getJTextField_WhereTo().getText();
+ }
+
+ public String getCount() {
+ return (String)this.getJComboBox_PassengerCount().getSelectedItem();
+ }
+
+ public DateSpec getDateSpec() {
+ return new DateSpec((Date)getJTextField_WhenFrom().getValue(), (Date)getJTextField_WhenTo().getValue());
+ // TODO HOLIDAY use swing calender element or date format to parse
+// return new DateSpec(new Date(getWhenFrom()), new Date(getWhenTo()));
+ }
+
+ public LocSpec getLocSpec() {
+ return new LocSpec(getWhereFrom(), getWhereTo());
+ }
+
+ public CarRequirements getCarRequirements() {
+ return new CarRequirements("carClass", new PositiveInteger(this.getCount()));
+ }
+
+} // @jve:decl-index=0:visual-constraint="10,10"
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchPanel.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchPanel.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchPanel.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchPanel.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.awt.GridBagLayout;
+import javax.swing.JPanel;
+import java.awt.BorderLayout;
+import javax.swing.JLabel;
+import java.awt.GridBagConstraints;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+
+import javax.swing.JComboBox;
+import java.awt.Dimension;
+import java.net.MalformedURLException;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+
+import javax.swing.JButton;
+
+import org.apache.axis.types.PositiveInteger;
+import org.apache.kandula.demo.ba.holiday.car.CarRequirements;
+import org.apache.kandula.demo.ba.holiday.room.RoomRequirements;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class RenterSearchPanel extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ private JPanel jPanel_Type = null;
+ private JPanel jPanel_SearchClear = null;
+ private JLabel jLabel_Type = null;
+ private JComboBox jComboBox_Type = null;
+ private RenterSearchCarPanel renterSearchCarPanel = null; // @jve:decl-index=0:visual-constraint="358,110"
+ protected JPanel jPanel_placeHolder = null;
+ private RenterSearchRoomPanel renterSearchRoomPanel = null; // @jve:decl-index=0:visual-constraint="434,34"
+ private JButton jButton_Search = null;
+ private JButton jButton_Clear = null;
+
+ private ArrayList listeners = new ArrayList(); // @jve:decl-index=0:
+
+ /**
+ * This is the default constructor
+ */
+ public RenterSearchPanel() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(300, 150);
+ this.setMinimumSize(new Dimension(300, 150));
+ this.setMaximumSize(new Dimension(300, 150));
+
+ this.setLayout(new BorderLayout());
+ this.add(getJPanel_Type(), BorderLayout.NORTH); // Generated
+ this.add(getJPanel_placeHolder(), BorderLayout.CENTER); // Generated
+
+ final JPanel searchClear = getJPanel_SearchClear();
+ searchClear.add(getJButton_Search(), BorderLayout.WEST); // Generated
+ searchClear.add(getJButton_Clear(), BorderLayout.EAST); // Generated
+
+ this.add(searchClear, BorderLayout.SOUTH); // Generated
+
+ }
+
+ /**
+ * This method initializes jPanel_Type
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJPanel_Type() {
+ if (this.jPanel_Type == null) {
+ GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+ gridBagConstraints1.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints1.gridy = 0; // Generated
+ gridBagConstraints1.weightx = 1.0; // Generated
+ gridBagConstraints1.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridx = 0; // Generated
+ gridBagConstraints.gridy = 0; // Generated
+ this.jPanel_Type = new JPanel();
+ this.jPanel_Type.setLayout(new GridBagLayout()); // Generated
+ this.jPanel_Type.add(getJLabel_Type(), gridBagConstraints);
+ this.jPanel_Type.add(getJComboBox_Type(), gridBagConstraints1); // Generated
+ }
+ return this.jPanel_Type;
+ }
+ /**
+ * This method initializes jPanel_Type
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJPanel_SearchClear() {
+ if (this.jPanel_SearchClear == null) {
+ this.jPanel_SearchClear = new JPanel();
+ this.jPanel_SearchClear.setLayout(new BorderLayout()); // Generated
+ }
+ return this.jPanel_SearchClear;
+ }
+ /**
+ * @return Returns the jLabel_Type.
+ */
+ public JLabel getJLabel_Type() {
+ if (this.jLabel_Type == null) {
+ this.jLabel_Type = new JLabel();
+ this.jLabel_Type.setText("Type of rental:");
+ }
+ return this.jLabel_Type;
+ }
+
+ /**
+ * This method initializes jComboBox_Type
+ *
+ * @return javax.swing.JComboBox
+ */
+ protected JComboBox getJComboBox_Type() {
+ if (this.jComboBox_Type == null) {
+ this.jComboBox_Type = new JComboBox();
+ this.jComboBox_Type.addItemListener(new java.awt.event.ItemListener() {
+ public void itemStateChanged(java.awt.event.ItemEvent e) {
+ if(e.getStateChange() == ItemEvent.SELECTED) {
+ if( e.getItem().equals("Car")) {
+ System.out.println("Car was choosen");
+// if (jPanel_placeHolder != null) {
+// RenterSearchPanel.this.remove(jPanel_placeHolder);
+// }
+// RenterSearchPanel.this.add(getJPanel_placeHolder(), BorderLayout.CENTER);
+ } else if(e.getItem().equals("Room")) {
+ System.out.println("Room was choosen");
+// if (jPanel_placeHolder != null) {
+// RenterSearchPanel.this.remove(jPanel_placeHolder);
+// }
+// RenterSearchPanel.this.add(getJPanel_placeHolder(), BorderLayout.CENTER);
+ }
+ if (RenterSearchPanel.this.jPanel_placeHolder != null) {
+ RenterSearchPanel.this.remove(RenterSearchPanel.this.jPanel_placeHolder);
+ }
+ RenterSearchPanel.this.add(getJPanel_placeHolder(), BorderLayout.CENTER);
+ RenterSearchPanel.this.revalidate();
+ RenterSearchPanel.this.repaint();
+// RenterSearchPanel.this.jPanel_placeHolder.revalidate();
+// RenterSearchPanel.this.jPanel_placeHolder.repaint();
+ }
+ }
+ });
+ this.jComboBox_Type.addItem("Car");
+ this.jComboBox_Type.addItem("Room");
+ }
+ return this.jComboBox_Type;
+ }
+
+ /**
+ * This method initializes renterSearchCarPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private RenterSearchCarPanel getRenterSearchCarPanel() {
+ if (this.renterSearchCarPanel == null) {
+ this.renterSearchCarPanel = new RenterSearchCarPanel();
+ this.renterSearchCarPanel.setPreferredSize(new Dimension(300, 88)); // Generated
+ this.renterSearchCarPanel.setSize(new Dimension(300, 88)); // Generated
+ }
+ return this.renterSearchCarPanel;
+ }
+
+ /**
+ * This method initializes jPanel_placeHolder
+ *
+ * @return javax.swing.JPanel
+ */
+ protected JPanel getJPanel_placeHolder() {
+ if (this.jPanel_placeHolder == null) {
+ this.jPanel_placeHolder = new JPanel();
+ this.jPanel_placeHolder.setLayout(new GridBagLayout()); // Generated
+ this.jPanel_placeHolder.setPreferredSize(new Dimension(300, 88)); // Generated
+ }
+ if (this.jComboBox_Type.getSelectedItem().equals("Car")) {
+ this.jPanel_placeHolder = getRenterSearchCarPanel();
+ this.renterSearchRoomPanel = null;
+ } else if (this.jComboBox_Type.getSelectedItem().equals("Room")) {
+ this.jPanel_placeHolder = getRenterSearchRoomPanel();
+ this.renterSearchCarPanel = null;
+ }
+ this.jPanel_placeHolder.revalidate();
+ this.jPanel_placeHolder.repaint();
+ return this.jPanel_placeHolder;
+ }
+
+ /**
+ * This method initializes renterSearchRoomPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private RenterSearchRoomPanel getRenterSearchRoomPanel() {
+ if (this.renterSearchRoomPanel == null) {
+ this.renterSearchRoomPanel = new RenterSearchRoomPanel();
+ this.renterSearchRoomPanel.setPreferredSize(new Dimension(300, 88)); // Generated
+ this.renterSearchRoomPanel.setSize(new Dimension(300, 88)); // Generated
+ }
+ return this.renterSearchRoomPanel;
+ }
+
+ /**
+ * This method initializes jButton_Search
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton_Search() {
+ if (this.jButton_Search == null) {
+ this.jButton_Search = new JButton();
+ this.jButton_Search.setText("Search for offers");
+ this.jButton_Search.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ if (e.getID() == ActionEvent.ACTION_PERFORMED) {
+ System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
+ if (RenterSearchPanel.this.getJComboBox_Type().getSelectedItem().equals("Car")) {
+ System.out.println("Search for Car Offers");
+ try {
+ RenterSearchPanel.this.fireSearchFinished(
+ Handler.searchForCarOffers(
+ new CarRequirements(
+ "Test",
+ new PositiveInteger(((SearchDetailInterface)RenterSearchPanel.this.getJPanel_placeHolder()).getCount())
+ ),
+ ((SearchDetailInterface)RenterSearchPanel.this.getJPanel_placeHolder()).getDateSpec(),
+ ((SearchDetailInterface)RenterSearchPanel.this.getJPanel_placeHolder()).getLocSpec()
+ )
+ );
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (RemoteException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ } else if (RenterSearchPanel.this.getJComboBox_Type().getSelectedItem().equals("Room")) {
+ System.out.println("Search for Room Offers");
+ try {
+ RenterSearchPanel.this.fireSearchFinished(
+ Handler.searchForRoomOffers(
+ new RoomRequirements(
+ "Test",
+ new PositiveInteger(((SearchDetailInterface)RenterSearchPanel.this.getJPanel_placeHolder()).getCount())
+ ),
+ ((SearchDetailInterface)RenterSearchPanel.this.getJPanel_placeHolder()).getDateSpec(),
+ ((SearchDetailInterface)RenterSearchPanel.this.getJPanel_placeHolder()).getLocSpec()
+ )
+ );
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (RemoteException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ }
+ }
+ });
+ }
+ return this.jButton_Search;
+ }
+ /**
+ * This method initializes jButton_Search
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton_Clear() {
+ if (this.jButton_Clear == null) {
+ this.jButton_Clear = new JButton();
+ this.jButton_Clear.setText("Clear list");
+ this.jButton_Clear.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ if (e.getID() == ActionEvent.ACTION_PERFORMED) {
+ System.out.println("Clearing Search Results.");
+ RenterSearchPanel.this.fireClearSearch();
+ }
+ }
+ });
+ }
+ return this.jButton_Clear;
+ }
+ public void addListener(SearchListener listener) {
+ this.listeners.add(listener);
+ }
+
+ public void removeListener(SearchListener listener) {
+ this.listeners.remove(listener);
+ }
+
+ public void fireSearchFinished(TableOfferEntry[] toe) {
+ SearchEvent e = new SearchEvent(this, toe);
+ for(int i = 0; i<this.listeners.size(); i++) {
+ SearchListener listener = (SearchListener)this.listeners.get(i);
+ listener.searchFinished(e);
+ }
+ }
+ public void fireClearSearch() {
+ for(int i = 0; i<this.listeners.size(); i++) {
+ SearchListener listener = (SearchListener)this.listeners.get(i);
+ listener.searchClear();
+ }
+ }
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchResultPanel.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchResultPanel.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchResultPanel.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchResultPanel.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.awt.GridBagLayout;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+
+import java.awt.GridBagConstraints;
+import java.awt.Dimension;
+import java.awt.BorderLayout;
+import java.util.ArrayList;
+
+import javax.swing.JButton;
+
+public class RenterSearchResultPanel extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ private JScrollPane jScrollPane = null;
+ private JTable jTable_Result = null;
+ private JPanel jPanel = null; // @jve:decl-index=0:visual-constraint="329,20"
+ private JButton jButton_Book = null;
+
+ private ArrayList listeners = new ArrayList();
+
+ /**
+ * This is the default constructor
+ */
+ public RenterSearchResultPanel() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints.gridy = 0; // Generated
+ gridBagConstraints.weightx = 1.0; // Generated
+ gridBagConstraints.weighty = 1.0; // Generated
+ gridBagConstraints.gridx = 0; // Generated
+ this.setSize(300, 200);
+ this.setLayout(new GridBagLayout());
+ this.add(getJPanel(), gridBagConstraints); // Generated
+ }
+
+ /**
+ * This method initializes jScrollPane
+ *
+ * @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (this.jScrollPane == null) {
+ this.jScrollPane = new JScrollPane();
+ this.jScrollPane.setViewportView(getJTable_Result()); // Generated
+ }
+ return this.jScrollPane;
+ }
+
+ /**
+ * This method initializes jTable_Result
+ *
+ * @return javax.swing.JTable
+ */
+ private JTable getJTable_Result() {
+ if (this.jTable_Result == null) {
+ this.jTable_Result = new JTable();
+ this.jTable_Result.setModel(new SearchResultTableModel());
+ this.jTable_Result.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+// this.jTable_Result.getTableHeader().setReorderingAllowed(false);
+ }
+ return this.jTable_Result;
+ }
+
+ /**
+ * This method initializes jPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJPanel() {
+ if (this.jPanel == null) {
+ this.jPanel = new JPanel();
+ this.jPanel.setLayout(new BorderLayout()); // Generated
+ this.jPanel.setSize(new Dimension(264, 205)); // Generated
+ this.jPanel.add(getJButton_Book(), BorderLayout.SOUTH); // Generated
+ this.jPanel.add(getJScrollPane(), BorderLayout.CENTER);
+ }
+ return this.jPanel;
+ }
+
+ /**
+ * This method initializes jButton_Book
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton_Book() {
+ if (this.jButton_Book == null) {
+ this.jButton_Book = new JButton();
+ this.jButton_Book.setText("Add selected offer to basket");
+ this.jButton_Book.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ System.out.println("actionPerformed(): " + e.getActionCommand());
+ fireAddToBasketFinished();
+ }
+ });
+ }
+ return this.jButton_Book;
+ }
+
+ public void addTableOfferEntries(TableOfferEntry[] offers) {
+ SearchResultTableModel srtm = (SearchResultTableModel)getJTable_Result().getModel();
+ for (int i = 0; i<offers.length; i++) {
+ TableOfferEntry toe = offers[i];
+ srtm.addTableOfferEntry(toe);
+ }
+ }
+ public void clearTableOffers(){
+ SearchResultTableModel srtm = (SearchResultTableModel)getJTable_Result().getModel();
+ srtm.clearResults();
+ }
+
+ public void addAddToBasketListener(AddToBasketListener listener) {
+ this.listeners.add(listener);
+ }
+
+ public void removeAddToBasketListener(AddToBasketListener listener) {
+ this.listeners.remove(listener);
+ }
+
+ public void fireAddToBasketFinished() {
+ TableOfferEntry[] toe = ((SearchResultTableModel)this.jTable_Result.getModel()).getRows(this.jTable_Result.getSelectedRows());
+ AddToBasketEvent atbe = new AddToBasketEvent(this, toe);
+ for(int i = 0; i<this.listeners.size(); i++) {
+ AddToBasketListener listener = (AddToBasketListener)this.listeners.get(i);
+ listener.addToBasketFinished(atbe);
+ }
+ }
+
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchRoomPanel.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchRoomPanel.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchRoomPanel.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RenterSearchRoomPanel.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,273 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.awt.GridBagLayout;
+
+import javax.swing.JFormattedTextField;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import java.awt.GridBagConstraints;
+import javax.swing.JTextField;
+import javax.swing.JComboBox;
+
+import org.apache.kandula.demo.ba.holiday.DateSpec;
+import org.apache.kandula.demo.ba.holiday.LocSpec;
+
+import java.awt.Dimension;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class RenterSearchRoomPanel extends JPanel implements SearchDetailInterface {
+
+ private static final long serialVersionUID = 1L;
+ private JLabel jLabel_Who = null;
+ private JLabel jLabel_When = null;
+ private JLabel jLabel_Where = null;
+ private JLabel jLabel_bedCount = null;
+ private JTextField jTextField_Who = null;
+ private JFormattedTextField jTextField_When = null;
+ private JTextField jTextField_Where = null;
+ private JComboBox jComboBox_BedCount = null;
+ private JFormattedTextField jTextField_WhenTo = null;
+
+ private final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); // @jve:decl-index=0:
+ /**
+ * This is the default constructor
+ */
+ public RenterSearchRoomPanel() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
+ gridBagConstraints41.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints41.gridy = 1; // Generated
+ gridBagConstraints41.weightx = 1.0; // Generated
+ gridBagConstraints41.gridx = 2; // Generated
+ GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
+ gridBagConstraints7.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints7.gridy = 3; // Generated
+ gridBagConstraints7.weightx = 1.0; // Generated
+ gridBagConstraints7.gridwidth = 2; // Generated
+ gridBagConstraints7.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
+ gridBagConstraints6.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints6.gridy = 2; // Generated
+ gridBagConstraints6.weightx = 1.0; // Generated
+ gridBagConstraints6.gridwidth = 2;
+ gridBagConstraints6.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+ gridBagConstraints5.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints5.gridy = 1; // Generated
+ gridBagConstraints5.weightx = 1.0; // Generated
+ gridBagConstraints5.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
+ gridBagConstraints4.fill = GridBagConstraints.BOTH; // Generated
+ gridBagConstraints4.gridy = 0; // Generated
+ gridBagConstraints4.weightx = 1.0; // Generated
+ gridBagConstraints4.gridwidth = 2; // Generated
+ gridBagConstraints4.gridx = 1; // Generated
+ GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+ gridBagConstraints3.anchor = GridBagConstraints.EAST;
+ gridBagConstraints3.gridx = 0; // Generated
+ gridBagConstraints3.gridy = 3; // Generated
+ GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+ gridBagConstraints2.anchor = GridBagConstraints.EAST;
+ gridBagConstraints2.gridx = 0; // Generated
+ gridBagConstraints2.gridy = 2; // Generated
+ GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+ gridBagConstraints1.anchor = GridBagConstraints.EAST;
+ gridBagConstraints1.gridx = 0; // Generated
+ gridBagConstraints1.gridy = 1; // Generated
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.anchor = GridBagConstraints.EAST;
+ gridBagConstraints.gridx = 0; // Generated
+ gridBagConstraints.gridy = 0; // Generated
+ this.setSize(300, 88);
+ this.setLayout(new GridBagLayout());
+ this.setPreferredSize(new Dimension(300, 88)); // Generated
+ this.add(getJLabel_Who(), gridBagConstraints); // Generated
+ this.add(getJLabel_When(), gridBagConstraints1); // Generated
+ this.add(getJLabel_Where(), gridBagConstraints2); // Generated
+ this.add(getJLabel_bedCount(), gridBagConstraints3); // Generated
+ this.add(getJTextField_Who(), gridBagConstraints4); // Generated
+ this.add(getJTextField_When(), gridBagConstraints5); // Generated
+ this.add(getJTextField_Where(), gridBagConstraints6);
+ this.add(getJComboBox_BedCount(), gridBagConstraints7); // Generated
+ this.add(getJTextField_WhenTo(), gridBagConstraints41); // Generated
+ }
+
+ /**
+ * @return Returns the jLabel_Who.
+ */
+ public JLabel getJLabel_Who() {
+ if (this.jLabel_Who == null) {
+ this.jLabel_Who = new JLabel();
+ this.jLabel_Who.setText("who:");
+ }
+ return this.jLabel_Who;
+ }
+
+ /**
+ * This method initializes jTextField_Who
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextField_Who() {
+ if (this.jTextField_Who == null) {
+ this.jTextField_Who = new JTextField();
+ }
+ return this.jTextField_Who;
+ }
+
+ /**
+ * @return Returns the jLabel_When.
+ */
+ public JLabel getJLabel_When() {
+ if (this.jLabel_When == null) {
+ this.jLabel_When = new JLabel();
+ this.jLabel_When.setText("when:");
+ }
+ return this.jLabel_When;
+ }
+
+ /**
+ * This method initializes jTextField_When
+ *
+ * @return javax.swing.JTextField
+ */
+ private JFormattedTextField getJTextField_When() {
+ if (this.jTextField_When == null) {
+ this.jTextField_When = new JFormattedTextField();
+ this.jTextField_When.setValue(new Date());
+ }
+ return this.jTextField_When;
+ }
+
+ /**
+ * @return Returns the jLabel_Where.
+ */
+ public JLabel getJLabel_Where() {
+ if (this.jLabel_Where == null) {
+ this.jLabel_Where = new JLabel();
+ this.jLabel_Where.setText("where:"); // Generated
+ }
+ return this.jLabel_Where;
+ }
+
+ /**
+ * This method initializes jTextField_Where
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getJTextField_Where() {
+ if (this.jTextField_Where == null) {
+ this.jTextField_Where = new JTextField();
+ }
+ return this.jTextField_Where;
+ }
+
+ /**
+ * @return Returns the jLabel_bedCount.
+ */
+ public JLabel getJLabel_bedCount() {
+ if (this.jLabel_bedCount == null) {
+ this.jLabel_bedCount = new JLabel();
+ this.jLabel_bedCount.setText("min bedcount:");
+ }
+ return this.jLabel_bedCount;
+ }
+
+ /**
+ * This method initializes jComboBox_BedCount
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBox_BedCount() {
+ if (this.jComboBox_BedCount == null) {
+ this.jComboBox_BedCount = new JComboBox();
+ this.jComboBox_BedCount.addItem(new String("1"));
+ this.jComboBox_BedCount.addItem(new String("2"));
+ this.jComboBox_BedCount.addItem(new String("3"));
+ this.jComboBox_BedCount.addItem(new String("4"));
+ this.jComboBox_BedCount.addItem(new String("5"));
+ this.jComboBox_BedCount.addItem(new String("6"));
+ this.jComboBox_BedCount.addItem(new String("7"));
+ this.jComboBox_BedCount.addItem(new String("8"));
+ }
+ return this.jComboBox_BedCount;
+ }
+
+
+ /**
+ * This method initializes jTextField_WhenTo
+ *
+ * @return javax.swing.JTextField
+ */
+ private JFormattedTextField getJTextField_WhenTo() {
+ if (this.jTextField_WhenTo == null) {
+ this.jTextField_WhenTo = new JFormattedTextField();
+ this.jTextField_WhenTo.setValue(new Date());
+ }
+ return this.jTextField_WhenTo;
+ }
+
+ public String getWho() {
+ return this.getJTextField_Who().getText();
+ }
+
+ public String getWhenFrom() {
+ return sdf.format((Date)this.getJTextField_When().getValue());
+ }
+
+ public String getWhenTo() {
+ return sdf.format((Date)this.getJTextField_When().getValue());
+ }
+
+ public String getWhereFrom() {
+ return this.getJTextField_Where().getText();
+ }
+
+ public String getWhereTo() {
+ return this.getJTextField_Where().getText();
+ }
+
+ public String getCount() {
+ return (String)this.getJComboBox_BedCount().getSelectedItem();
+ }
+
+ public DateSpec getDateSpec() {
+ return new DateSpec((Date)getJTextField_When().getValue(), (Date)getJTextField_WhenTo().getValue());
+ }
+
+ public LocSpec getLocSpec() {
+ return new LocSpec(getWhereFrom());
+ }
+} // @jve:decl-index=0:visual-constraint="10,10"
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RoomTableOfferEntry.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RoomTableOfferEntry.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RoomTableOfferEntry.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/RoomTableOfferEntry.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+
+import org.apache.kandula.demo.ba.holiday.room.DateSpec;
+
+public class RoomTableOfferEntry extends TableOfferEntry {
+
+ public RoomTableOfferEntry(
+ final String pBookingReference,
+ final String pSpecification,
+ final String where,
+ final DateSpec dateSpec,
+ final BigDecimal pPrice,
+ final String[] pPayments,
+ final Calendar pExpires
+
+ ) {
+ super(
+ pBookingReference, pSpecification, where,
+ new org.apache.kandula.demo.ba.holiday.DateSpec(dateSpec),
+ pPrice,
+ pPayments,
+ pExpires
+ );
+ }
+
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchDetailInterface.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchDetailInterface.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchDetailInterface.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchDetailInterface.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import org.apache.kandula.demo.ba.holiday.DateSpec;
+import org.apache.kandula.demo.ba.holiday.LocSpec;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public interface SearchDetailInterface {
+ String getWho();
+ String getWhenFrom();
+ String getWhenTo();
+ String getWhereFrom();
+ String getWhereTo();
+ String getCount();
+ DateSpec getDateSpec();
+ LocSpec getLocSpec();
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchEvent.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchEvent.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchEvent.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchEvent.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.util.EventObject;
+
+public class SearchEvent extends EventObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2587687656272802783L;
+ private final TableOfferEntry[] toe;
+ public SearchEvent(Object source, TableOfferEntry[] entry) {
+ super(source);
+ this.toe = entry;
+ }
+
+ public TableOfferEntry[] getToe() {
+ return this.toe;
+ }
+
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchListener.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchListener.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchListener.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchListener.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.util.EventListener;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public interface SearchListener extends EventListener {
+
+ void searchFinished(SearchEvent e);
+ void searchClear();
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchResultTableModel.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchResultTableModel.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchResultTableModel.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/SearchResultTableModel.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import javax.swing.table.AbstractTableModel;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class SearchResultTableModel extends AbstractTableModel {
+
+ /**
+ * The number format for the price.
+ */
+ public static NumberFormat NF_PRICE = NumberFormat.getCurrencyInstance();
+
+ /**
+ * The date format.
+ */
+ public static final DateFormat DF_YYYYMMDD_HHMISS = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1217359885695319126L;
+
+ /**
+ *
+ */
+ private static final int COLUMNINDEX_EXPIRES = 8;
+
+ /**
+ *
+ */
+ private final Vector content = new Vector();
+
+ /**
+ *
+ */
+ private final Vector columnNames = new Vector();
+
+ /**
+ *
+ */
+ private final Timer timer = new Timer();
+
+ /**
+ *
+ */
+ public SearchResultTableModel() {
+ this.columnNames.add("Booking reference");
+ this.columnNames.add("When From");
+ this.columnNames.add("When To");
+ this.columnNames.add("Where From");
+ this.columnNames.add("Where To");
+ this.columnNames.add("Description");
+ this.columnNames.add("Price");
+ this.columnNames.add("Payment methods");
+ this.columnNames.add("Expires");
+
+ this.timer.schedule(new TimerTask(){
+ public void run() {
+ final Vector contentV = SearchResultTableModel.this.content;
+
+ if(contentV == null || contentV.size()==0)
+ return ;
+
+ for(int i=0; i<contentV.size(); i++)
+ SearchResultTableModel.this.fireTableCellUpdated(i, COLUMNINDEX_EXPIRES);
+ }
+ }, 0, 1000);
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.AbstractTableModel#getColumnName(int)
+ */
+ public String getColumnName(int column) {
+ return (String)this.columnNames.get(column);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ public int getColumnCount() {
+ return this.columnNames.size();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ public int getRowCount() {
+ return this.content.size();
+ }
+
+ private final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ TableOfferEntry toe = (TableOfferEntry)this.content.get(rowIndex);
+ switch (columnIndex) {
+ case 0:
+ return toe.getBookingReference();
+ case 1:
+ return sdf.format(toe.getWhen_from());
+ case 2:
+ return sdf.format(toe.getWhen_to());
+ case 3:
+ return toe.getWhere_from();
+ case 4:
+ return toe.getWhere_to();
+ case 5:
+ return toe.getSpecification();
+ case 6:
+ return NF_PRICE.format( toe.getPrice() );
+ case 7:
+ return Arrays.asList(toe.getPayments());
+ case COLUMNINDEX_EXPIRES:
+ final Calendar expires = toe.getExpires();
+ if (expires == null)
+ return "";
+
+ final long expiresT = Calendar.getInstance().getTimeInMillis() - expires.getTimeInMillis();
+
+ if (expiresT < 0)
+ return ""+(-expiresT/1000)+" sec";
+ return "expired";
+ default:
+ break;
+ }
+ return null;
+ }
+
+ public void addTableOfferEntry(TableOfferEntry toe){
+ this.content.add(toe);
+ this.fireTableDataChanged();
+ }
+
+ public TableOfferEntry getRow(int rowIndex) {
+ TableOfferEntry tOE = (TableOfferEntry) this.content.get(rowIndex);
+ return tOE;
+ }
+
+ public TableOfferEntry[] getRows(int[] rowIndices) {
+ TableOfferEntry[] toe = new TableOfferEntry[rowIndices.length];
+ for (int i = 0; i<rowIndices.length; i++) {
+ toe[i] = (TableOfferEntry)this.content.get(rowIndices[i]);
+ }
+ return toe;
+ }
+
+ public void clearResults() {
+ this.content.clear();
+ this.fireTableDataChanged();
+ }
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/TableOfferEntry.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/TableOfferEntry.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/TableOfferEntry.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/client/gui/TableOfferEntry.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+package org.apache.kandula.demo.ba.holiday.client.gui;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.kandula.demo.ba.holiday.DateSpec;
+import org.apache.kandula.demo.ba.holiday.LocSpec;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public abstract class TableOfferEntry {
+ private final String bookingReference;
+ private final String specification;
+ private final Date when_from, when_to;
+ private final String where_from, where_to;
+ private final BigDecimal price;
+ private final String[] payments;
+ private final Calendar expires;
+
+ public TableOfferEntry(final String pBookingReference,
+ final String pSpecification, final String where,
+ final DateSpec dateSpec, final BigDecimal pPrice,
+ final String[] pPayments,final Calendar pExpires
+ ) {
+ this.bookingReference = pBookingReference;
+ this.specification = pSpecification;
+ this.when_from = dateSpec.getFrom();
+ this.when_to = dateSpec.getTo();
+ this.where_from = where;
+ this.where_to = "";
+ this.price = pPrice;
+ this.payments = pPayments;
+ this.expires = pExpires;
+ }
+
+ public TableOfferEntry(final String pBookingReference,
+ final String pSpecification, final LocSpec locSpec,
+ final DateSpec dateSpec, final BigDecimal pPrice,
+ final String[] pPayments, final Calendar pExpires
+ ) {
+ this.bookingReference = pBookingReference;
+ this.specification = pSpecification;
+ this.when_from = dateSpec.getFrom();
+ this.when_to = dateSpec.getTo();
+ this.where_from = locSpec.getFrom();
+ this.where_to = locSpec.getTo();
+ this.price = pPrice;
+ this.payments = pPayments;
+ this.expires = pExpires;
+ }
+
+ /**
+ * @return Returns the bookingReference.
+ */
+ public String getBookingReference() {
+ return this.bookingReference;
+ }
+
+ /**
+ * @return Returns the when_from.
+ */
+ public Date getWhen_from() {
+ return this.when_from;
+ }
+
+ /**
+ * @return Returns the payments.
+ */
+ public String[] getPayments() {
+ return this.payments;
+ }
+
+ /**
+ * @return Returns the specification.
+ */
+ public String getSpecification() {
+ return this.specification;
+ }
+
+ /**
+ * @return Returns the when_to.
+ */
+ public Date getWhen_to() {
+ return this.when_to;
+ }
+
+ /**
+ * @return Returns the where_from.
+ */
+ public String getWhere_from() {
+ return where_from;
+ }
+
+ /**
+ * @return Returns the where_to.
+ */
+ public String getWhere_to() {
+ return where_to;
+ }
+
+ public Calendar getExpires(){
+ return this.expires;
+ }
+
+ /**
+ * THis offer's price.
+ * @return The price.
+ */
+ public BigDecimal getPrice() {
+ return this.price;
+ }
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomParticipant.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomParticipant.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomParticipant.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomParticipant.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+
+package org.apache.kandula.demo.ba.holiday.room;
+
+import java.rmi.RemoteException;
+import java.util.Calendar;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.xml.soap.Name;
+
+import org.apache.kandula.coordinator.CoordinationContext;
+import org.apache.kandula.coordinator.TimedOutException;
+import org.apache.kandula.coordinator.ba.State;
+import org.apache.kandula.coordinator.ba.participant.BAwCCParticipant;
+import org.apache.kandula.coordinator.ba.participant.ParticipantCancelResult;
+import org.apache.kandula.coordinator.ba.participant.ParticipantCloseResult;
+import org.apache.kandula.coordinator.ba.participant.ParticipantCompensateResult;
+import org.apache.kandula.coordinator.ba.participant.ParticipantCompleteResult;
+
+/**
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class RentARoomParticipant extends BAwCCParticipant {
+
+ /**
+ * The next booking number.
+ */
+ private static long nextBookingNumer = 9999;
+
+ private final RentARoomService myService;
+
+ private final RentARoomBookingRequest myRequest;
+
+ private final RoomOfferType myOffer;
+
+ /**
+ * The booking number for this participant.
+ */
+ private final long myBookingNumber;
+
+ private final RentARoomBookingResponse myResponse;
+
+ /**
+ * A timer that Exits the participant if its compensate time times out
+ * while active.
+ */
+ private final Timer timer = new Timer();
+
+ /**
+ * @param coordinationContext
+ * @throws RemoteException
+ */
+ public RentARoomParticipant(RentARoomService pService, RentARoomBookingRequest request, RoomOfferType offer)
+ throws RemoteException {
+ super(new CoordinationContext( request.getTransactionalContext().getCoordinationContext()));
+
+ final Calendar compensateUntil = Calendar.getInstance();
+ compensateUntil.add(Calendar.SECOND, 90);
+
+ this.myService = pService;
+ this.myRequest = request;
+ this.myOffer = offer;
+
+ this.myBookingNumber = nextBookingNumer++;
+
+ if (myOffer.getOfferExpires() != null
+ && Calendar.getInstance().after(myOffer.getOfferExpires())) {
+ this.myResponse = new RentARoomBookingResponse(
+ "RoomTEST-"+getBookingNumber(),
+ "TEST booking of Room NOK",
+ Calendar.getInstance(),
+ "Offer expired"
+ );
+ this.tellExit();
+ } else {
+ this.myResponse = new RentARoomBookingResponse(
+ "RoomTEST-"+getBookingNumber(),
+ "TEST booking of Room OK",
+ compensateUntil,
+ "Active"
+ );
+
+ final TimerTask exitIfNotCompleted = new TimerTask(){
+ public void run() {
+ final RentARoomParticipant me = RentARoomParticipant.this;
+ System.out.println("Room "+me.myBookingNumber+": CompensateUntil reached while ACTIVE, exiting...");
+ if (State.STATE_ACTIVE.equals( me.getState() )){
+ me.tellExit();
+ }
+ }
+ };
+ this.timer.schedule(exitIfNotCompleted, compensateUntil.getTime());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.coordinator.ba.participant.BAwCCParticipant#onComplete()
+ */
+ protected ParticipantCompleteResult onComplete() {
+ if (this.myOffer.getOfferExpires() != null
+ && Calendar.getInstance().after(this.myOffer.getOfferExpires())) {
+ System.out.println("*** rentaroom booking "+getBookingNumber()+" tells exit because offer expired");
+
+ this.tellExit();
+ return ParticipantCompleteResult.HANDLED_BY_APPLICATION;
+ } else {
+ System.out.println("*** rentaroom booking "+getBookingNumber()+" completed");
+
+ return ParticipantCompleteResult.COMPLETED;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.coordinator.ba.participant.AbstractParticipant#onCancel()
+ */
+ protected ParticipantCancelResult onCancel() {
+ System.out.println("*** rentaroom booking "+getBookingNumber()+" canceled");
+
+ return ParticipantCancelResult.CANCELED;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.coordinator.ba.participant.AbstractParticipant#onClose()
+ */
+ protected ParticipantCloseResult onClose() {
+ System.out.println("*** rentaroom booking "+getBookingNumber()+" closed");
+
+ return ParticipantCloseResult.CLOSED;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.coordinator.ba.participant.AbstractParticipant#onCompensate()
+ */
+ protected ParticipantCompensateResult onCompensate() {
+ // Check if the booking may be compensated
+ if (this.myResponse.getCompensateUntil()==null
+ || Calendar.getInstance().before(this.myResponse.getCompensateUntil())
+ ){
+ // YES!
+ System.out.println("*** rentaroom booking "+this.myBookingNumber+" compensated");
+
+ return ParticipantCompensateResult.COMPENSATED;
+ }
+ // NO!
+ System.out.println("*** rentaroom booking "+this.myBookingNumber+" NOT compensated, too late! Faulting...");
+
+ // Sorry, its too late -- manual intervention required.
+ return ParticipantCompensateResult.FAULTED;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.coordinator.ba.participant.AbstractParticipant#onFinish()
+ */
+ protected void onFinish() {
+ System.out.println("*** rentaroom booking "+getBookingNumber()+" finished, disposing");
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.coordinator.Callback#onFault(javax.xml.soap.Name)
+ */
+ public void onFault(Name code) {
+ System.out.println("*** rentaroom booking "+getBookingNumber()+" Fault: "+code);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.coordinator.Callback#timeout()
+ */
+ public void timeout() throws TimedOutException {
+ System.out.println("*** rentaroom booking "+this.myBookingNumber+" Timeout!");
+ }
+
+ /**
+ * Return the booking response object so the calling web service
+ * may return it to the customer. At this point, the constructor will
+ * already have registered the participant with the coordination context
+ * and reported Completed.
+ * @return The booking response
+ */
+ public RentARoomBookingResponse getBookingResponse() {
+
+ // Access the field so it is read at least one time...
+ if (this.myRequest == null)
+ throw new NullPointerException();
+
+ return this.myResponse;
+ }
+
+ /**
+ * The current booking number.
+ * @return ..
+ */
+ public long getBookingNumber(){
+ return this.myBookingNumber;
+ }
+}
Added: webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomService.java
URL: http://svn.apache.org/viewvc/webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomService.java?view=auto&rev=556065
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomService.java (added)
+++ webservices/kandula/branches/Kandula_1/src/samples/holiday/src/org/apache/kandula/demo/ba/holiday/room/RentARoomService.java Fri Jul 13 09:48:21 2007
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ * @author Hannes Erven, Georg Hicker
+ */
+package org.apache.kandula.demo.ba.holiday.room;
+
+import java.math.BigDecimal;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * Demonstration Web Service for the Kandula WS-BusinessActivity Implementation.
+ *
+ * This Web Service "plays" a hotel business. For any given request, a random
+ * response is returned to the caller and stored in the offer registry.
+ *
+ * When the customer wants to book one or more of those offers, they send a
+ * CoordinationContext with the order and the web service happily registers itself
+ * as a participant in the given context. It is necessary for the customer to issue
+ * one doBooking request per option to book, e.g. if the customer still is unsure which
+ * of two departure dates to decide for, they simple book both room offers but with different
+ * CoordinationContexts and hence two participants (one for each start date) in the transation.
+ * This enables the customer to conventiently decide which offer to close, and which to compensate.
+ *
+ * The reservations' states are recorded in the order book.
+ *
+ *
+ * @author Hannes Erven, Georg Hicker (C) 2006
+ *
+ */
+public class RentARoomService implements RentARoomPortType {
+
+ /**
+ * The next booking reference number when giving out offers.
+ */
+ private static int nextOfferReference = 9999;
+
+ /**
+ * An Offer Reference --> CarOfferType map for all offers
+ */
+ private static Map offers = new HashMap();
+
+ private static final String[] roomClasses = {"cubbyhole", "room", "suite", "penthouse"};
+
+ private static final double[] priceFactor = {0.5, 0.75, 1, 1.5};
+
+ /**
+ * A Booking Reference --> RentARoomParticipant map for all bookings
+ */
+ private static Map bookings = new HashMap();
+
+ /**
+ * Some payment methods from which the service randomly chooses some
+ */
+ public static final String[] paymentMethods = {
+ "Cash",
+ "Bank transfer",
+ "PayPal",
+ "VISA",
+ "MasterCard",
+ "DinersClub"
+ };
+
+ /**
+ * Fetch the price list for the given room requirements and date. The returned data
+ * is randomly generated.
+ * @param params The room requirements and date
+ * @return Rental Room Offers for WSBA demonstration.
+ * @throws RemoteException
+ *
+ */
+ public RentARoomOfferResponse getOffers(final RentARoomOfferRequest params) throws RemoteException {
+ try{
+ final ArrayList ret = new ArrayList();
+ for (int classInd=0; classInd<roomClasses.length; classInd++) {
+ final RoomOfferType roomOffer = new RoomOfferType();
+
+ final String curBookingRef = "Room "+(nextOfferReference++);
+
+ final Calendar expires = Calendar.getInstance();
+ expires.add(Calendar.SECOND, (int) (100*priceFactor[classInd]));
+
+ roomOffer.setDateSpec(params.getDateSpec());
+ roomOffer.setLocSpec(params.getLocSpec());
+ roomOffer.setOfferExpires(expires);
+ roomOffer.setPayment(getRandomPaymentMethods());
+ roomOffer.setPrice(
+ new BigDecimal(
+ (new Random().nextInt(749)+100)*priceFactor[classInd]
+ )
+ );
+ roomOffer.setRoomBookingReference(curBookingRef);
+ roomOffer.setRoomSpec(roomClasses[classInd]);
+
+ // Add the offer to the return
+ ret.add(roomOffer);
+ // Record the offer
+ offers.put(curBookingRef, roomOffer);
+ System.out.println("Offer ref "+curBookingRef+" --> "+roomOffer);
+ }
+
+ final RentARoomOfferResponse offerResp = new RentARoomOfferResponse();
+ offerResp.setMetadata("Metadata currently not used!");
+ offerResp.setRoomOffer((RoomOfferType[]) ret.toArray(new RoomOfferType[0]));
+
+ return offerResp;
+ } catch(Exception e) {
+ e.printStackTrace();
+ throw new RemoteException("Error while proccessing your request: " + e);
+ }
+ }
+
+ private String[] getRandomPaymentMethods() {
+ final ArrayList ret = new ArrayList();
+
+ for (int i = 0; i<paymentMethods.length; i++) {
+ if (Math.random() > 0.5) {
+ ret.add(paymentMethods[i]);
+ }
+ }
+
+ if (ret.size() == 0) {
+ ret.add(paymentMethods[new Random().nextInt(paymentMethods.length)]);
+ }
+
+ return (String[]) ret.toArray(new String[0]);
+ }
+
+ /**
+ * Actually book one or more offers from getOffers(). The web serivce enrols in the given
+ * WS-BA transaction context as participant, reports completed and waits for closing/compensation.
+ * The booking response includes a xsd:dateTime up until which compensation may be issued.
+ * If the customer decides to compensate at a later time, the participant will report Faulted.
+ * @param params The booking request.
+ * @return The booking response.
+ * @throws RemoteException
+ */
+ public RentARoomBookingResponse doBooking(final RentARoomBookingRequest params) throws RemoteException {
+ try{
+ final String req_OfferReference = params.getRoomBookingReference();
+
+ if (offers.containsKey(req_OfferReference)) {
+ RoomOfferType offer = (RoomOfferType)offers.get(req_OfferReference);
+ final RentARoomParticipant part = new RentARoomParticipant(this, params, offer);
+
+ final RentARoomBookingResponse ret = part.getBookingResponse();
+
+ bookings.put(new Long(part.getBookingNumber()), part);
+
+ return ret;
+
+ } else {
+ throw new IllegalArgumentException("Sorry, no offer with offer code "+req_OfferReference+" found!");
+ }
+ }catch(final Exception e){
+ e.printStackTrace();
+ throw new RemoteException("Error while processing your request: ", e);
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org