import java.rmi.RemoteException;
import java.sql.Date;
-import com.db4o.ObjectContainer;
-import com.db4o.ObjectSet;
-
import dataAccess.DB4oManager;
import domain.Offer;
import domain.RuralHouse;
private int offerNumber = 0;
dataAccess.DB4oManager dbMngr;
- private static OfferManager theOfferManager;
public OfferManager() {
try {
}
}
- public static int getNumber() {
- ObjectContainer db=DB4oManager.getContainer();
- OfferManager o=getInstance();
- o.offerNumber++;
- db.store(o);
- db.commit();
- return o.offerNumber;
- }
+
- /**
- * This method returns the instance of the OfferManager class
- *
- * @return the offer manager
- */
- public static OfferManager getInstance() {
- ObjectContainer db=DB4oManager.getContainer();
- OfferManager b = new OfferManager();
- ObjectSet<OfferManager> result = db.queryByExample(b);
- if (!result.hasNext()){
- theOfferManager = new OfferManager();
- db.store(theOfferManager);
- db.commit();
- } else theOfferManager=(OfferManager)result.next();
- return theOfferManager;
- }
/**
* This method creates an offer with a house number, first day, last day and price
boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated
if (!b) {
- ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
- return dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
+ dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
+ return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
}
return null;
}
import java.util.Date;
import java.util.Enumeration;
import java.util.Vector;
-
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
private RuralHouse rh;
private JTextField telIn;
private int row;
- private JLabel phoneNum;
+ private JLabel labelPhone;
+
+
/**
* Create the frame.
*/
JLabel lblNewLabel = new JLabel(
"Green: Suit your dates. Red: Do not suit your dates");
lblNewLabel.setEnabled(false);
- lblNewLabel.setBounds(152, 277, 261, 23);
+ lblNewLabel.setBounds(170, 282, 261, 23);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("Telephone num:");
telIn.setBounds(99, 505, 129, 20);
contentPane.add(telIn);
telIn.setColumns(10);
--
- phoneNum = new JLabel("");
- phoneNum.setBounds(215, 255, 201, 15);
- contentPane.add(phoneNum);
++
+ labelPhone = new JLabel("");
+ labelPhone.setBounds(238, 252, 178, 14);
+ contentPane.add(labelPhone);
++
table.addMouseListener( new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent arg0) {
private void jButton_ActionPerformed(ActionEvent arg0) {
BookingManager bookingM = new BookingManager();
//RegExp to see if telephone number is correct??TODO
- if (!telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")){
- phoneNum.setText("Wrong phone format");
- }else {
- phoneNum.setText("");
-
- Booking book = null;
- try {
- if (table.getRowCount()!=0)
- book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (book != null) {
- BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
- book);
- confirmWindow.setVisible(true);
- }
+ if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")) {
+ Booking book = null;
+ try {
+ if (table.getRowCount()!=0)
+ book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (book != null) {
+ BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
+ book);
+ confirmWindow.setVisible(true);
+ }
+ } else {
+ labelPhone.setText("Phone format is wrong");
++
++
}
}
}
private JTextField baths_f;
private JButton btnConfirm;
private JComboBox<RuralHouse> houseBox;
- private RuralHouse rh;
private JComboBox<String> comboBox;
+ private RuralHouse rh;
/**
* Create the frame.
*/
- public ModifyHouseGUI(Owner o) {
+ public ModifyHouseGUI(final Owner o) {
this.distric=Districs.longNames();
- comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+ comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
++
this.distric));
this.getContentPane().setLayout(null);
owner = o;
HouseManager hm = new HouseManager();
if (hm.registerNewHouse(newRh)) {
- o.getRuralHouses().remove(rh);
- o.getRuralHouses().add(newRh);
+ owner.getRuralHouses().remove(rh);
+ owner.getRuralHouses().add(newRh);
houseBox.removeItem(rh);
feedback.setText("House properly modified");
} else
import configuration.ConfigXML;
+@SuppressWarnings("deprecation")
public class StartWindow extends JFrame {
private static final long serialVersionUID = 1L;
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
c=configuration.ConfigXML.getInstance();
-
+
-
}catch (com.db4o.ext.DatabaseFileLockedException e) {
a.lblNewLabel.setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
a.lblNewLabel.setForeground(Color.RED);
a.lblNewLabel.setForeground(Color.RED);
System.out.println("Error in StartWindow: "+e.toString());
}
- //a.pack();