try {
if (hm.registerNewHouse(newRh)) {
- owner.getRuralHouses().add(newRh);
- houseBox.removeItem(rh);
feedback.setText("House properly modified");
} else
feedback.setText("Imposible to modify the house");
} catch (RemoteException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
import javax.swing.JTextField;
import com.toedter.calendar.JCalendar;
-
import common.HouseInterface;
import common.OfferInterface;
+
import configuration.___IntNames;
import domain.Offer;
import domain.Owner;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
+import common.HouseInterface;
+
+import configuration.___IntNames;
import domain.Owner;
public class OffersRelatedOwnerGUI extends JFrame {
JButton btnCreateOffers = new JButton("Create Offers");
btnCreateOffers.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
- Frame a = new AddOffersGUI(owner.getRuralHouses());
+ HouseInterface houseM=null;
+ try {
+ houseM = (HouseInterface) Naming
+ .lookup(___IntNames.HouseManager);
+ } catch (Exception e1) {
+ System.out.println("Error accessing remote authentication: "
+ + e1.toString());
+ }
+ Frame a = null;
+ try {
+ a = new AddOffersGUI(houseM.getHouses(owner, null, null, 0, 0, 0, 0, 0));
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
a.setVisible(true);
}
});
*/
private static final long serialVersionUID = 1L;
-
-
-
public AdminManager() throws RemoteException {
}
return new Vector<Account>(Administrator.getInstance()
.getNewOwnerRequest());
}
-
- public Vector<Owner> getAllOwners()throws RemoteException {
+
+ public Vector<Owner> getAllOwners() throws RemoteException {
try {
return new Vector<Owner>(DB4oManager.getInstance().getOwners());
} catch (Exception e) {
}
return null;
}
- public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException {
+
+ public void removeHouseAdditionRequests(RuralHouse house)
+ throws RemoteException {
Administrator.getInstance().getAddRequest().remove(house);
}
- public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException {
+ public void removeHouseDeletionRequests(RuralHouse house)
+ throws RemoteException {
Administrator.getInstance().getRemoveRequest().remove(house);
}
-
+
public void removeOwnerAdditionRequests(int index) throws RemoteException {
Administrator.getInstance().getNewOwnerRequest().remove(index);
}
-
+
public boolean addAdditionRequest(RuralHouse rh) throws RemoteException {
- if (this.getAdditionRequests().contains(rh)) {
+ if (this.getAdditionRequests().contains(rh)
+ || !suitsRegulations(rh.getFeatures().getnKitchens(), rh
+ .getFeatures().getnBaths(),rh
+ .getFeatures().getnLivings())) {
return false;
}
return Administrator.getInstance().getAddRequest().add(rh);
return Administrator.getInstance().getRemoveRequest().add(rh);
}
-
- public boolean addAccountRequest(String usr,
- String pss, Owner ow) throws RemoteException {
-
- Account acc = new Account (usr, pss, ow);
+
+ public boolean addAccountRequest(String usr, String pss, Owner ow)
+ throws RemoteException {
+
+ Account acc = new Account(usr, pss, ow);
if (this.getOwnerAdditionRequests().contains(acc)) {
return false;
}
@Override
public void saveInstance() throws RemoteException {
Administrator.saveInstance();
-
- }
-
+ }
+ private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) {
+ if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+ return false;
+ else
+ return true;
+ }
-// public boolean removeAccount(Account acc) {
-// if (this.getDeletionRequests().contains(acc))
-// return false;
-// return Administrator.getInstance().getNewOwnerRequest().add(acc);
-// }
+ // public boolean removeAccount(Account acc) {
+ // if (this.getDeletionRequests().contains(acc))
+ // return false;
+ // return Administrator.getInstance().getNewOwnerRequest().add(acc);
+ // }
}
public boolean registerNewHouse(RuralHouse rh) {
boolean stored = false;
- if (!suitsRegulations(rh.getFeatures().getnKitchens(), rh.getFeatures()
+ if (!suitsRegulations(rh.getFeatures().getnRooms(), rh.getFeatures()
.getnBaths(), rh.getFeatures().getnKitchens()))
return false;
stored = this.dbMngr.storeRuralHouses(rh);
null);
try {
ObjectSet<RuralHouse> result = db.queryByExample(house);
+ Owner own = new Owner(rh.getOwner().getName(),rh.getOwner().getBankAccount(),rh.getOwner().getMailAccount());
+ Owner ow = (Owner) db.queryByExample(own).get(0);
+ rh.setOwner(ow);
if (result.isEmpty()) {
- Owner ow = (Owner) db.queryByExample(rh.getOwner()).get(0);
- rh.setOwner(ow);
ow.addRuralHouse(rh);
db.store(rh);
db.commit();
stored = true;
} else {
+ ow.getRuralHouses().remove(result.get(0));
+ result.get(0).setOwner(null);
+ ow.addRuralHouse(rh);
+ db.store(result.get(0));
db.delete(result.get(0));
db.store(rh);
db.commit();
try {
Offer of = (Offer) db.queryByExample(
- new Offer(o.getOfferNumber(), new RuralHouse(o
+ new Offer(0, new RuralHouse(o
.getRuralHouse().getHouseName(), null, null, null,
- null), null, null, 0)).get(0);
+ null), o.getFirstDay(), o.getLastDay(), 0)).get(0);
Booking proto = new Booking(0, of, null, null);
ObjectSet<Booking> result = db.queryByExample(proto);
return new Vector<Booking>(result);
import java.io.Serializable;
import java.util.Date;
-public class Booking implements Serializable {
+public class Booking implements Serializable {
/**
*
private Date bookingDate;
private Client client;
private Offer offer;
-
-
-
- public Booking(int bN , Offer offer,Client client) {
-
+
+ public Booking(int bN, Offer offer, Client client) {
+
this.bookingNumber = bN;
this.offer = offer;
- this.client=client;
- //Booking date is assigned to actual date
- this.bookingDate= new java.util.Date(System.currentTimeMillis());
+ this.client = client;
+ // Booking date is assigned to actual date
+ this.bookingDate = new java.util.Date(System.currentTimeMillis());
}
-
- public Booking(int bN , Offer offer,Client client, Date bookDate) {
+ public Booking(int bN, Offer offer, Client client, Date bookDate) {
this.bookingNumber = bN;
this.offer = offer;
- this.client=client;
- this.bookingDate= bookDate; }
-
+ this.client = client;
+ this.bookingDate = bookDate;
+ }
public int getBookNumber() {
return this.bookingNumber;
return this.offer;
}
-
public void setBookDate(Date bookDate) {
this.bookingDate = bookDate;
}
public Date getBookDate() {
return this.bookingDate;
}
-
+
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
-
+
}
\ No newline at end of file
+++ /dev/null
-package gui;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.rmi.Naming;
-import java.sql.Date;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTextField;
-
-import com.toedter.calendar.JCalendar;
-import common.OfferInterface;
-
-import configuration.___IntNames;
-import domain.RuralHouse;
-import exceptions.BadDates;
-import exceptions.OverlappingOfferExists;
-
-
-
-public class AddOffersGUI extends JFrame {
-private static final long serialVersionUID = 1L;
-
-
- private JComboBox<RuralHouse> jComboBox1;
- private JLabel jLabel1 = new JLabel();
- private JLabel jLabel2 = new JLabel();
- private JTextField jTextField1 = new JTextField();
- private JLabel jLabel3 = new JLabel();
- private JTextField jTextField2 = new JTextField();
- private JLabel jLabel4 = new JLabel();
- private JTextField jTextField3 = new JTextField();
- private JButton jButton1 = new JButton();
-
- // Code for JCalendar
- private JCalendar jCalendar1 = new JCalendar();
- private JCalendar jCalendar2 = new JCalendar();
- private Calendar calendarInicio = null;
- private Calendar calendarFin = null;
- private JButton jButton2 = new JButton();
- private JLabel jLabel5 = new JLabel();
- private final JLabel lblNewLabel = new JLabel("");
-
-
- public AddOffersGUI(Vector<RuralHouse> v)
- {
- try
- {
- jbInit(v);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
-
- private void jbInit(Vector<RuralHouse> v) throws Exception
- {
- this.getContentPane().setLayout(null);
- this.setSize(new Dimension(513, 433));
- this.setTitle("Set availability");
-
-
- jComboBox1 = new JComboBox<RuralHouse>(v);
- jComboBox1.setBounds(new Rectangle(115, 30, 115, 20));
- jLabel1.setText("List of houses:");
- jLabel1.setBounds(new Rectangle(25, 30, 95, 20));
- jLabel2.setText("First day :");
- jLabel2.setBounds(new Rectangle(25, 75, 85, 25));
- jTextField1.setBounds(new Rectangle(25, 265, 220, 25));
- jTextField1.setEditable(false);
- jLabel3.setText("Last day :");
- jLabel3.setBounds(new Rectangle(260, 75, 75, 25));
- jTextField2.setBounds(new Rectangle(260, 265, 220, 25));
- jTextField2.setEditable(false);
- jLabel4.setText("Price:");
- jLabel4.setBounds(new Rectangle(260, 30, 75, 20));
- jTextField3.setBounds(new Rectangle(350, 30, 115, 20));
- jTextField3.setText("0");
- jButton1.setText("Accept");
- jButton1.setBounds(new Rectangle(100, 360, 130, 30));
- jTextField3.addFocusListener(new FocusListener()
- {
- public void focusGained(FocusEvent e)
- {
- }
-
- public void focusLost(FocusEvent e)
- {
- jTextField3_focusLost();
- }
- });
- jButton1.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- jButton1_actionPerformed(e);
- }
- });
- jButton2.setText("Cancel");
- jButton2.setBounds(new Rectangle(270, 360, 130, 30));
- jButton2.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- jButton2_actionPerformed(e);
- }
- });
- jLabel5.setBounds(new Rectangle(100, 320, 300, 20));
- jLabel5.setForeground(Color.red);
- jLabel5.setSize(new Dimension(305, 20));
- jCalendar1.setBounds(new Rectangle(25, 100, 220, 165));
- jCalendar2.setBounds(new Rectangle(260, 100, 220, 165));
-
- // Code for JCalendar
- this.jCalendar1.addPropertyChangeListener(new PropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent propertychangeevent)
- {
- if (propertychangeevent.getPropertyName().equals("locale"))
- {
- jCalendar1.setLocale((Locale) propertychangeevent.getNewValue());
- DateFormat dateformat = DateFormat.getDateInstance(1, jCalendar1.getLocale());
- jTextField1.setText(dateformat.format(calendarInicio.getTime()));
- }
- else if (propertychangeevent.getPropertyName().equals("calendar"))
- {
- calendarInicio = (Calendar) propertychangeevent.getNewValue();
- DateFormat dateformat1 = DateFormat.getDateInstance(1, jCalendar1.getLocale());
- jTextField1.setText(dateformat1.format(calendarInicio.getTime()));
- jCalendar1.setCalendar(calendarInicio);
- }
- }
- });
-
- this.jCalendar2.addPropertyChangeListener(new PropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent propertychangeevent)
- {
- if (propertychangeevent.getPropertyName().equals("locale"))
- {
- jCalendar2.setLocale((Locale) propertychangeevent.getNewValue());
- DateFormat dateformat = DateFormat.getDateInstance(1, jCalendar2.getLocale());
- jTextField2.setText(dateformat.format(calendarFin.getTime()));
- }
- else if (propertychangeevent.getPropertyName().equals("calendar"))
- {
- calendarFin = (Calendar) propertychangeevent.getNewValue();
- DateFormat dateformat1 = DateFormat.getDateInstance(1, jCalendar2.getLocale());
- jTextField2.setText(dateformat1.format(calendarFin.getTime()));
- jCalendar2.setCalendar(calendarFin);
- }
- }
- });
-
-
- this.getContentPane().add(jCalendar2, null);
- this.getContentPane().add(jCalendar1, null);
- this.getContentPane().add(jLabel5, null);
- this.getContentPane().add(jButton2, null);
- this.getContentPane().add(jButton1, null);
- this.getContentPane().add(jTextField3, null);
- this.getContentPane().add(jLabel4, null);
- this.getContentPane().add(jTextField2, null);
- this.getContentPane().add(jLabel3, null);
- this.getContentPane().add(jTextField1, null);
- this.getContentPane().add(jLabel2, null);
- this.getContentPane().add(jLabel1, null);
- this.getContentPane().add(jComboBox1, null);
- lblNewLabel.setBounds(115, 301, 298, 38);
-
- getContentPane().add(lblNewLabel);
- }
-
- private void jButton1_actionPerformed(ActionEvent e)
- {
- RuralHouse ruralHouse=((RuralHouse)jComboBox1.getSelectedItem());
-
- // The next instruction creates a java.sql.Date object from the date selected in the JCalendar object
- Date firstDay=new Date(jCalendar1.getCalendar().getTime().getTime());
- // The next instruction removes the hour, minute, second and ms from the date
- // This has to be made because the date will be stored in db4o as a java.util.Date object
- // that would store those data, and that would give problems when comparing dates later
- firstDay=Date.valueOf(firstDay.toString());
-
-
- Date lastDay=new Date(jCalendar2.getCalendar().getTime().getTime());
- //Remove the hour:minute:second:ms from the date
- lastDay=Date.valueOf(lastDay.toString());
-
-
- try {
-
- //It could be to trigger an exception if the introduced string is not a number
- float price= Float.parseFloat(jTextField3.getText());
-
- //Obtain the business logic from a StartWindow class (local or remote)
- OfferInterface offerM = null;
- try {
- offerM = (OfferInterface) Naming
- .lookup(___IntNames.OfferManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- offerM.createOffer(ruralHouse, firstDay, lastDay, price);
-
- jLabel5.setText("Offer created");
-
- } catch (java.lang.NumberFormatException e1) {
- jLabel5.setText(jTextField3.getText()+ " is not a valid price");
- } catch (OverlappingOfferExists e1) {
- jLabel5.setText("There exists an overlapping offer");
- }
- catch (BadDates e1) {
- jLabel5.setText("Last day is before first day in the offer");
- } catch (NullPointerException e1){
- jLabel5.setText("Bad dates or there exists an overlapping offer");
- } catch (Exception e1) {
-
- e1.printStackTrace();
- }
- }
- private void jButton2_actionPerformed(ActionEvent e)
- {
- this.setVisible(false);
- }
-
- private void jTextField3_focusLost()
- {
- try
- {
- new Integer (jTextField3.getText());
- jLabel5.setText("");
- }
- catch (NumberFormatException ex)
- {
- jLabel5.setText("Error: Introduce a number");
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package gui;
-
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-public class AdminMenuGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
-
-
-
- /**
- * Create the frame.
- */
- public AdminMenuGUI() {
-
-
- this.setTitle("Administrator Menu");
- this.getContentPane().setLayout(null);
- setBounds(100, 100, 450, 500);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- //TODO BOTH BUTTONS ARE TO MODIFY
- JButton btnAdd = new JButton("Add requests");
- btnAdd.setBounds(120, 67, 164, 81);
- btnAdd.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new listOfAdditionRequestsGUI();
- a.setVisible(true);
- }
- });
-
- JButton btnDel = new JButton("Delete Requests");
- btnDel.setBounds(120, 159, 164, 73);
- btnDel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new listOfRemovalRequestsGUI();
- a.setVisible(true);
- }
- });
-
- JButton btnOwneraddition = new JButton("OwnerAddition");
- btnOwneraddition.setBounds(120, 243, 164, 73);
- btnOwneraddition.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new listOfOwnerAddittionRequests();
- a.setVisible(true);
- }
- });
- contentPane.setLayout(null);
- contentPane.add(btnOwneraddition);
- contentPane.add(btnDel);
- contentPane.add(btnAdd);
-
- JButton btnOwnerDeletion = new JButton("Owner Deletion");
- btnOwnerDeletion.setBounds(120, 331, 164, 73);
- btnOwnerDeletion.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new DeleteOwnerGUI();
- a.setVisible(true);
- }
- });
- contentPane.add(btnOwnerDeletion);
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTextField;
-
-import domain.Booking;
-
-public class BookRuralHouseConfirmationWindow extends JFrame {
- private static final long serialVersionUID = 1L;
-
- private JLabel jLabel1 = new JLabel();
- private JTextField jTextField1 = new JTextField();
- private JLabel jLabel2 = new JLabel();
- private JTextField jTextField2 = new JTextField();
- private JLabel jLabel3 = new JLabel();
- private JButton jButton1 = new JButton();
- private JLabel jLabel4 = new JLabel();
- private JLabel jLabel5 = new JLabel();
- private JTextField jTextField3 = new JTextField();
- private JTextField jTextField4 = new JTextField();
-
- public BookRuralHouseConfirmationWindow(Booking book)
- {
- try
- {
- jbInit(book);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
- private void jbInit(Booking book) throws Exception
- {
-
-
- this.getContentPane().setLayout(null);
- this.setSize(new Dimension(416, 316));
- this.setTitle("See Booking Details");
- this.setResizable(false);
- jLabel1.setText("Owner Bank account number:");
- jLabel1.setBounds(new Rectangle(20, 20, 200, 25));
- jTextField1.setBounds(new Rectangle(225, 20, 165, 25));
- jTextField1.setEditable(false);
-
- jTextField1.setText(book.getOffer().getRuralHouse().getOwner().getBankAccount());
-
- jLabel2.setText("Booking number:");
- jLabel2.setBounds(new Rectangle(20, 60, 130, 25));
- jTextField2.setBounds(new Rectangle(225, 60, 165, 25));
- jTextField2.setEditable(false);
-
- jTextField2.setText(Integer.toString(book.getBookNumber()));
-
- jLabel3.setText("You must deposit 20% of the total ammount of a book in the next three days.");
- jLabel3.setBounds(new Rectangle(20, 105, 370, 25));
- jButton1.setText("Close");
- jButton1.setBounds(new Rectangle(135, 235, 130, 30));
- jButton1.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- jButton1_actionPerformed(e);
- }
- });
- jLabel4.setText("Total:");
- jLabel4.setBounds(new Rectangle(70, 140, 85, 25));
- jLabel5.setText("Deposit ammount:");
- jLabel5.setBounds(new Rectangle(70, 175, 100, 25));
- jTextField3.setBounds(new Rectangle(180, 140, 115, 25));
- jTextField3.setEditable(false);
-
- jTextField3.setText(Float.toString(book.getOffer().getPrice()) + " \80");
- jTextField4.setBounds(new Rectangle(180, 175, 115, 25));
- jTextField4.setEditable(false);
- jTextField4.setText(Float.toString(book.getOffer().getPrice()*(float)0.2) + " \80");
-
- this.getContentPane().add(jTextField4, null);
- this.getContentPane().add(jTextField3, null);
- this.getContentPane().add(jLabel5, null);
- this.getContentPane().add(jLabel4, null);
- this.getContentPane().add(jButton1, null);
- this.getContentPane().add(jLabel3, null);
- this.getContentPane().add(jTextField2, null);
- this.getContentPane().add(jLabel2, null);
- this.getContentPane().add(jTextField1, null);
- this.getContentPane().add(jLabel1, null);
- }
-
- private void jButton1_actionPerformed(ActionEvent e)
- {
- this.setVisible(false);
- }
-}
\ No newline at end of file
+++ /dev/null
-package gui;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.border.EmptyBorder;
-
-import common.HouseInterface;
-import common.OfferInterface;
-
-import configuration.___IntNames;
-import domain.Offer;
-import domain.Owner;
-import domain.RuralHouse;
-
-public class DeleteOfferGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JLabel feedback;
- private JComboBox<RuralHouse> comboBox;
- private JComboBox<Offer> comboBox_1;
- private JButton btnDelete;
- private Vector<RuralHouse> Hlist = null;
- private HouseInterface hm = null;
-
- /**
- * Create the frame.
- */
- public DeleteOfferGUI(Owner o) {
- try {
- hm = (HouseInterface) Naming
- .lookup(___IntNames.HouseManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- try {
- Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
- } catch (RemoteException e1) {
- e1.printStackTrace();
- }
- setBounds(100, 100, 450, 300);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- comboBox = new JComboBox<RuralHouse>(this.Hlist);
- comboBox.setBounds(101, 38, 314, 20);
-
- comboBox_1 = new JComboBox<Offer>();
- comboBox_1.setBounds(101, 76, 314, 20);
- Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers();
- comboBox_1.removeAllItems();
- for (Offer of : vo) {
- comboBox_1.addItem(of);
- ;
- }
-
- JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
- rdbtnIAmSure.setBounds(101, 134, 108, 23);
-
- btnDelete = new JButton("DELETE");
- btnDelete.setBounds(92, 226, 117, 23);
- btnDelete.setEnabled(false);
-
- comboBox.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent arg0) {
- Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers();
- comboBox_1.removeAllItems();
- for (Offer of : vo) {
- comboBox_1.addItem(of);
- ;
- }
-
- }
-
- });
-
- rdbtnIAmSure.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- int state = e.getStateChange();
- if (state == ItemEvent.SELECTED) {
- if (comboBox_1.getSelectedItem() != null)
- btnDelete.setEnabled(true);
- } else if (state == ItemEvent.DESELECTED) {
- btnDelete.setEnabled(false);
- }
- }
- });
-
- JLabel lblHouse = new JLabel("House:");
- lblHouse.setBounds(25, 41, 68, 14);
-
- JLabel lblOffer = new JLabel("Offer:");
- lblOffer.setBounds(25, 79, 68, 14);
- contentPane.setLayout(null);
- contentPane.add(btnDelete);
- contentPane.add(rdbtnIAmSure);
- contentPane.add(lblHouse);
- contentPane.add(lblOffer);
- contentPane.add(comboBox);
- contentPane.add(comboBox_1);
-
- feedback = new JLabel("");
- feedback.setBounds(140, 178, 202, 23);
- contentPane.add(feedback);
-
- btnDelete.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- actionListenerButton(arg0);
-
- }
-
- });
- }
-
- private void actionListenerButton(ActionEvent e) {
-
- Offer toDel = (Offer) comboBox_1.getSelectedItem();
- OfferInterface oM = null;
- try {
- oM = (OfferInterface) Naming
- .lookup(___IntNames.OfferManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- try {
- oM.deleteOffer((RuralHouse) comboBox.getSelectedItem(), toDel);
- comboBox_1.removeItem(toDel);
- btnDelete.setEnabled(false);
- feedback.setText("Offer correctly deleted");
- } catch (Exception e1) {
- feedback.setText("Imposible to delete the offer");
- e1.printStackTrace();
- }
-
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableModel;
-
-import common.AccountInterface;
-import common.AdminInterface;
-
-import configuration.___IntNames;
-import domain.Owner;
-
-public class DeleteOwnerGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JTable table;
-
- private DefaultTableModel tableModel;
- private AdminInterface AdM = null;
- private Vector<Owner> owners = new Vector<Owner>();
-
- /**
- * Create the frame.
- */
- public DeleteOwnerGUI() {
- setTitle("Current owners:");
- try {
- init();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void init() throws Exception {
- setBounds(100, 100, 600, 500);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- try {
- AdM = (AdminInterface) Naming
- .lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out
- .println("Error accessing remote authentication: "
- + e1.toString());
- }
- this.owners = AdM.getAllOwners();
- JLabel lblNewLabel = new JLabel();
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
- lblNewLabel.setBounds(23, 41, 536, 33);
- contentPane.add(lblNewLabel);
- if (this.owners.isEmpty())
- lblNewLabel
- .setText("There are not owners in the system");
- else
- lblNewLabel.setText("List of owners:");
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
- scrollPane.setBounds(23, 113, 536, 271);
- contentPane.add(scrollPane);
- final JLabel feedback = new JLabel("");
- feedback.setBounds(134, 447, 307, 14);
- contentPane.add(feedback);
- JButton btnNewButton = new JButton("Delete from the system");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
- AccountInterface acm = null;
-
- try {
- acm = (AccountInterface) Naming
- .lookup(___IntNames.AccountManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- try {
- if(acm.removeAccount(table.getSelectedRow()))
- {
- feedback.setText("Deleted from the system");
- }
- } catch (RemoteException e1) {
- e1.printStackTrace();
- }
-
- ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
- }
- }
- });
- btnNewButton.setBounds(88, 396, 428, 40);
- contentPane.add(btnNewButton);
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
-
- scrollPane.setViewportView(table);
- tableModel = new DefaultTableModel(null, new String[] {
- "Name", "E-mail", "Bank Account" });
-
- table.setModel(tableModel);
-
-
- Enumeration<Owner> rhs = this.owners.elements();
- while (rhs.hasMoreElements()) {
- Owner own = rhs.nextElement();
- Vector<Object> row = new Vector<Object>();
- row.add(own.getName());
- row.add(own.getMailAccount());
- row.add(own.getBankAccount());
- tableModel.addRow(row);
- }
-
-
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.rmi.Naming;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-
-import common.BookingInterface;
-
-import configuration.___IntNames;
-import domain.Booking;
-import domain.Client;
-import domain.Offer;
-import domain.RuralHouse;
-
-public class HouseFeaturesGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JLabel lblDistrict;
- private JTextField District_f;
- private JLabel lblDescription;
- private JTextField description_f;
- private JLabel lblKitchen;
- private JTextField kitchens_f;
- private JLabel lblRooms;
- private JTextField rooms_f;
- private JLabel lblLivings;
- private JTextField lRooms_f;
- private JLabel lblParkings;
- private JTextField parkings_f;
- private JLabel lblBaths;
- private JTextField baths_f;
- private JTable table;
- private DefaultTableModel tableModel;
- private RuralHouse rh;
- private Vector<Offer> offers= new Vector<Offer>();
- private JTextField telIn;
- private int row;
- private JLabel labelPhone;
- private JLabel lblName;
- private JTextField nameField;
- private JLabel lblEmail;
- private JTextField mailField;
-
- /**
- * Create the frame.
- */
-
- public HouseFeaturesGUI(RuralHouse RH, final Date FirstDay,
- final Date LastDay) {
- this.rh = RH;
- this.getContentPane().setLayout(null);
- setBounds(100, 100, 500, 700);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- lblDistrict = new JLabel("District:");
- lblDistrict.setBounds(23, 67, 70, 14);
- lblDistrict.setHorizontalAlignment(SwingConstants.RIGHT);
-
- District_f = new JTextField();
- District_f.setEditable(false);
- District_f.setBounds(103, 64, 86, 20);
- District_f.setColumns(10);
-
- lblDescription = new JLabel("Description:");
- lblDescription.setBounds(215, 67, 90, 14);
- lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
-
- description_f = new JTextField();
- description_f.setEditable(false);
- description_f.setBounds(238, 99, 178, 129);
- description_f.setColumns(10);
-
- lblKitchen = new JLabel("Kitchens:");
- lblKitchen.setBounds(23, 211, 70, 14);
- lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT);
-
- kitchens_f = new JTextField();
- kitchens_f.setEditable(false);
- kitchens_f.setBounds(103, 202, 86, 20);
- kitchens_f.setColumns(10);
-
- lblRooms = new JLabel("Rooms:");
- lblRooms.setBounds(23, 102, 70, 14);
- lblRooms.setHorizontalAlignment(SwingConstants.RIGHT);
-
- rooms_f = new JTextField();
- rooms_f.setEditable(false);
- rooms_f.setBounds(103, 99, 86, 20);
- rooms_f.setColumns(10);
-
- lblLivings = new JLabel("Living rooms:");
- lblLivings.setBounds(30, 236, 63, 14);
- lblLivings.setHorizontalAlignment(SwingConstants.RIGHT);
-
- lRooms_f = new JTextField();
- lRooms_f.setEditable(false);
- lRooms_f.setBounds(103, 233, 86, 20);
- lRooms_f.setColumns(10);
-
- lblParkings = new JLabel("Parkings:");
- lblParkings.setBounds(23, 174, 70, 14);
- lblParkings.setHorizontalAlignment(SwingConstants.RIGHT);
-
- parkings_f = new JTextField();
- parkings_f.setEditable(false);
- parkings_f.setBounds(103, 171, 86, 20);
- parkings_f.setColumns(10);
-
- lblBaths = new JLabel("Baths:");
- lblBaths.setBounds(23, 143, 70, 14);
- lblBaths.setHorizontalAlignment(SwingConstants.RIGHT);
-
- baths_f = new JTextField();
- baths_f.setEditable(false);
- baths_f.setBounds(103, 140, 86, 20);
- baths_f.setColumns(10);
- contentPane.setLayout(null);
- contentPane.add(lblParkings);
- contentPane.add(parkings_f);
- contentPane.add(lblRooms);
- contentPane.add(rooms_f);
- contentPane.add(lblBaths);
- contentPane.add(baths_f);
- contentPane.add(lblDistrict);
- contentPane.add(District_f);
- contentPane.add(lblLivings);
- contentPane.add(lRooms_f);
- contentPane.add(lblKitchen);
- contentPane.add(kitchens_f);
- contentPane.add(description_f);
- contentPane.add(lblDescription);
- parkings_f.setText(Integer.toString(rh.getFeatures().getnParkings()));
- rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
- baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
- District_f.setText(rh.getDistrict());
- kitchens_f.setText(Integer.toString(rh.getFeatures().getnKitchens()));
- description_f.setText(rh.getDescription());
- lRooms_f.setText(Integer.toString(rh.getFeatures().getnLivings()));
- JLabel lblAvailbleOffers = new JLabel("Availble Offers:");
- lblAvailbleOffers.setBounds(30, 286, 86, 14);
- contentPane.add(lblAvailbleOffers);
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(40, 311, 376, 183);
- contentPane.add(scrollPane);
-
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
- tableModel = new DefaultTableModel(null, new String[] { "Offer #",
- "FirstDay", "LastDay", "Price" });
- table.setModel(tableModel);
- scrollPane.setViewportView(table);
-
- JButton btnBookSelected = new JButton("Book SelectedOffer");
- btnBookSelected.setBounds(238, 614, 178, 23);
- contentPane.add(btnBookSelected);
-
- btnBookSelected.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
-
- jButton_ActionPerformed(arg0);
- }
-
- });
-
- JLabel lblNewLabel = new JLabel(
- "Green: Suit your dates. Red: Do not suit your dates");
- lblNewLabel.setEnabled(false);
- lblNewLabel.setBounds(170, 282, 261, 23);
- contentPane.add(lblNewLabel);
-
- JLabel lblNewLabel_1 = new JLabel("Telephone num:");
- lblNewLabel_1.setBounds(10, 618, 83, 14);
- contentPane.add(lblNewLabel_1);
-
- telIn = new JTextField();
- telIn.setBounds(103, 615, 129, 20);
- contentPane.add(telIn);
- telIn.setColumns(10);
-
- labelPhone = new JLabel("");
- labelPhone.setBounds(238, 252, 178, 14);
- contentPane.add(labelPhone);
-
- lblName = new JLabel("Name:");
- lblName.setBounds(10, 516, 46, 14);
- contentPane.add(lblName);
-
- nameField = new JTextField();
- nameField.setBounds(103, 513, 178, 20);
- contentPane.add(nameField);
- nameField.setColumns(10);
-
- lblEmail = new JLabel("E-mail:");
- lblEmail.setBounds(10, 565, 46, 14);
- contentPane.add(lblEmail);
-
- mailField = new JTextField();
- mailField.setBounds(103, 562, 178, 20);
- contentPane.add(mailField);
- mailField.setColumns(10);
-
- table.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent arg0) {
- row = table.getSelectedRow();
- }
- });
-
- Enumeration<Offer> rhs = rh.getAllOffers().elements();
- while (rhs.hasMoreElements()) {
- Offer of = rhs.nextElement();
- if (of.getBookings() == null
- || !of.isBooked()) {
- offers.add(of);
- Vector<Object> row = new Vector<Object>();
- row.add(of.getOfferNumber());
- row.add(of.getFirstDay());
- row.add(of.getLastDay());
- row.add(of.getPrice());
- tableModel.addRow(row);
- }
- }
- table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
- int row, int col) {
-
- super.getTableCellRendererComponent(table, value, isSelected,
- hasFocus, row, col);
-
- Date firstDay = (Date) table.getModel().getValueAt(row, 1);
- Date lastDay = (Date) table.getModel().getValueAt(row, 2);
- if (FirstDay != null && LastDay != null) {
- if (LastDay.before(lastDay) || FirstDay.after(firstDay)) {
- setBackground(Color.RED);
- setForeground(Color.BLACK);
- } else {
- setBackground(Color.GREEN);
- setForeground(Color.BLACK);
- }
- }
- return this;
- }
- });
- }
-
- private void jButton_ActionPerformed(ActionEvent arg0) {
-
- BookingInterface bookingM = null;
- try {
- bookingM = (BookingInterface) Naming
- .lookup(___IntNames.BookingManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")
- && mailField
- .getText()
- .matches(
- "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")
- && !nameField.getText().isEmpty()) {
- labelPhone.setText("");
- Vector<Booking> book = null;
- try {
- if (table.getRowCount() != 0) {
- Client cl = new Client(nameField.getText(),
- mailField.getText(), telIn.getText());
- book = bookingM.createBooking(rh, offers.get(row)
- .getFirstDay(), offers.get(row).getLastDay(),cl);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (book != null) {
- BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
- book.lastElement());
- confirmWindow.setVisible(true);
- }
- } else {
- labelPhone.setText("Bad formatted data.");
-
- }
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-import domain.Owner;
-
-public class HousesRelatedOwnerGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private Owner owner;
- /**
- * Create the frame.
- */
- public HousesRelatedOwnerGUI(Owner o) {
- this.getContentPane().setLayout(null);
- owner = o;
- setBounds(100, 100, 450, 562);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- JButton btnCreateHouses = new JButton("Create Request");
- btnCreateHouses.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- Frame a = new RequestNewHouseGUI(owner);
- a.setVisible(true);
- }
- });
-
- JButton btnModifyHouses = new JButton("Modify Houses");
- btnModifyHouses.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
-
- Frame a = new ModifyHouseGUI(owner);
- a.setVisible(true);
-
- }
- });
-
- JButton btnDeleteHouses = new JButton("Delete Request");
- btnDeleteHouses.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new RequestDeleteHouseGUI(owner);
- a.setVisible(true);
- }
- });
- GroupLayout gl_contentPane = new GroupLayout(contentPane);
- gl_contentPane.setHorizontalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(110)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addComponent(btnDeleteHouses, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE)
- .addComponent(btnModifyHouses, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE)
- .addComponent(btnCreateHouses, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE))
- .addGap(121))
- );
- gl_contentPane.setVerticalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(88)
- .addComponent(btnCreateHouses, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
- .addGap(40)
- .addComponent(btnModifyHouses, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
- .addGap(39)
- .addComponent(btnDeleteHouses, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(394, Short.MAX_VALUE))
- );
- contentPane.setLayout(gl_contentPane);
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.Frame;
-import java.awt.KeyEventDispatcher;
-import java.awt.KeyboardFocusManager;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JPasswordField;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-
-import common.LoginInterface;
-
-import configuration.___IntNames;
-import domain.Account;
-
-public class LoginGUI extends JFrame {
-
- private static final long serialVersionUID= 1L;
- private JPanel jContentPane = null;
- private JTextField usernameField;
- private JPasswordField passwordField;
- private LoginInterface loginManager = null;
- private JLabel loginFeedback;
- private JButton btnRegister;
- protected boolean isFocused = false;
- public LoginGUI() {
- super();
- initialize();
- }
-
- private void initialize() {
- try {
- loginManager = (LoginInterface) Naming
- .lookup(___IntNames.LoginManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- this.setSize(449, 293);
- this.setContentPane(getJContentPane());
- this.setTitle("Login");
- addWindowListener(new WindowAdapter() {
-
-
- @Override
- public void windowGainedFocus(WindowEvent e) {
- isFocused = true;
- }
-
- @Override
- public void windowLostFocus(WindowEvent e) {
- isFocused = false;
- }
- });
-
- KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent e) {
- if (isFocused && e.getKeyCode() == KeyEvent.VK_ENTER )
- jButton_ActionPerformed();
-
- return false;
- }});
- }
-
-
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- jContentPane = new JPanel();
- jContentPane.setLayout(null);
-
- JLabel usernameTag = new JLabel("Username:");
- usernameTag.setBounds(56, 67, 104, 20);
- jContentPane.add(usernameTag);
-
- JLabel passwordTag = new JLabel("Password:");
- passwordTag.setBounds(56, 132, 104, 15);
- jContentPane.add(passwordTag);
-
- usernameField = new JTextField();
- usernameField.setBounds(202, 65, 133, 25);
- jContentPane.add(usernameField);
- usernameField.setColumns(10);
-
- passwordField = new JPasswordField();
- passwordField.setBounds(202, 122, 133, 25);
- jContentPane.add(passwordField);
-
- JButton loginButton = new JButton("Login");
- loginButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
-
- jButton_ActionPerformed();
- }
- });
- loginButton.setBounds(95, 179, 117, 25);
- jContentPane.add(loginButton);
-
- loginFeedback = new JLabel("");
- loginFeedback.setForeground(Color.RED);
- loginFeedback.setHorizontalAlignment(SwingConstants.CENTER);
- loginFeedback.setBounds(83, 216, 269, 25);
- jContentPane.add(loginFeedback);
-
- btnRegister = new JButton("Register");
- btnRegister.setBounds(222, 180, 113, 23);
- btnRegister.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
-
- jButton_ActionPerformed2(arg0);
- }
- });
- jContentPane.add(btnRegister);
- }
- return jContentPane;
- }
- private void jButton_ActionPerformed2(ActionEvent e){
-
-
- this.setVisible(false);
- Frame a = new OwnerRegistrationGUI();
- a.setVisible(true);
-
-
- }
-
-
-
- private void jButton_ActionPerformed(){
-
- Account acc = null;
- try {
- acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (acc == null) loginFeedback.setText("Incorrect username or password");
- else if( acc.getAdmin()) {
- this.setVisible(false);
- Frame a = new AdminMenuGUI();
- a.setVisible(true);
- } else {
- if(acc.getOwner()==null){
- loginFeedback.setText("Incorrect username or password");
- }else{
- this.setVisible(false);
- Frame a = new OwnerMenuGUI(acc.getOwner());
- a.setVisible(true);
- }
- }
-
- }
-} // @jve:decl-index=0:visual-constraint="222,33"
-
+++ /dev/null
-package gui;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.util.Vector;
-
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-import javax.swing.border.EmptyBorder;
-
-import common.HouseInterface;
-
-import configuration.___IntNames;
-import domain.Districs;
-import domain.HouseFeatures;
-import domain.Owner;
-import domain.RuralHouse;
-
-public class ModifyHouseGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private Owner owner;
- private JLabel lblDistrict;
- private JLabel feedback;
- private JLabel lblDescription;
- private JTextField description_f;
- private JLabel lblKitchen;
- private JTextField kitchens_f;
- private JLabel lblRooms;
- private JTextField rooms_f;
- private JLabel lblLivings;
- private JTextField lRooms_f;
- private JLabel lblParkings;
- private JTextField parkings_f;
- private JLabel lblBaths;
- private String[] distric;
- private JTextField baths_f;
- private JButton btnConfirm;
- private JComboBox<RuralHouse> houseBox;
- private JComboBox<String> comboBox;
- private RuralHouse rh;
-
- /**
- * Create the frame.
- */
- public ModifyHouseGUI(final Owner o) {
- this.distric=Districs.longNames();
- comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
-
- this.distric));
- this.getContentPane().setLayout(null);
- owner = o;
- setBounds(100, 100, 500, 583);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- JLabel lblCode = new JLabel("House Name:");
- lblCode.setBounds(15, 88, 64, 14);
- lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
-
- lblDistrict = new JLabel("District:");
- lblDistrict.setBounds(39, 119, 70, 14);
- lblDistrict.setHorizontalAlignment(SwingConstants.RIGHT);
-
- lblDescription = new JLabel("Description:");
- lblDescription.setBounds(231, 88, 90, 14);
- lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
-
- description_f = new JTextField();
- description_f.setBounds(241, 113, 178, 129);
- description_f.setColumns(10);
-
- lblKitchen = new JLabel("Kitchens:");
- lblKitchen.setBounds(230, 316, 70, 14);
- lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT);
-
- kitchens_f = new JTextField();
- kitchens_f.setBounds(318, 313, 86, 20);
- kitchens_f.setColumns(10);
-
- lblRooms = new JLabel("Rooms:");
- lblRooms.setBounds(39, 316, 70, 14);
- lblRooms.setHorizontalAlignment(SwingConstants.RIGHT);
-
- rooms_f = new JTextField();
- rooms_f.setBounds(127, 313, 86, 20);
- rooms_f.setColumns(10);
-
- lblLivings = new JLabel("Living rooms:");
- lblLivings.setBounds(237, 354, 63, 14);
- lblLivings.setHorizontalAlignment(SwingConstants.RIGHT);
-
- lRooms_f = new JTextField();
- lRooms_f.setBounds(318, 351, 86, 20);
- lRooms_f.setColumns(10);
-
- lblParkings = new JLabel("Parkings:");
- lblParkings.setBounds(39, 404, 70, 14);
- lblParkings.setHorizontalAlignment(SwingConstants.RIGHT);
-
- parkings_f = new JTextField();
- parkings_f.setBounds(127, 401, 86, 20);
- parkings_f.setColumns(10);
-
- lblBaths = new JLabel("Baths:");
- lblBaths.setBounds(39, 354, 70, 14);
- lblBaths.setHorizontalAlignment(SwingConstants.RIGHT);
-
- baths_f = new JTextField();
- baths_f.setBounds(127, 351, 86, 20);
- baths_f.setColumns(10);
-
- btnConfirm = new JButton("Confirm");
- btnConfirm.setBounds(145, 462, 69, 23);
- btnConfirm.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
-
- RuralHouse newRh = new RuralHouse(rh.getHouseName(), owner,
- description_f.getText(), (String)comboBox.getSelectedItem(),
- new HouseFeatures(new Integer(rooms_f.getText()),
- new Integer(kitchens_f.getText()), new Integer(
- baths_f.getText()), new Integer(
- lRooms_f.getText()), new Integer(
- parkings_f.getText())));
- HouseInterface hm= null;
- try {
- hm = (HouseInterface) Naming
- .lookup(___IntNames.HouseManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- try {
- if (hm.registerNewHouse(newRh)) {
- owner.getRuralHouses().add(newRh);
- houseBox.removeItem(rh);
- feedback.setText("House properly modified");
- } else
- feedback.setText("Imposible to modify the house");
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- });
- HouseInterface hm= null;
- try {
- hm = (HouseInterface) Naming
- .lookup(___IntNames.HouseManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- Vector<RuralHouse> list = null;
- try {
- list = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
- } catch (RemoteException e1) {
- e1.printStackTrace();
- }
-
- houseBox = new JComboBox<RuralHouse>(list);
- if (!o.getRuralHouses().isEmpty()) {
- rh = (RuralHouse) houseBox.getSelectedItem();
- comboBox.setSelectedItem(rh.getDistrict());
- description_f.setText(rh.getDescription());
- kitchens_f.setText(Integer
- .toString(rh.getFeatures().getnKitchens()));
- rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
- lRooms_f.setText(Integer.toString(rh.getFeatures().getnLivings()));
- parkings_f.setText(Integer
- .toString(rh.getFeatures().getnParkings()));
- baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
- houseBox.setBounds(89, 85, 124, 20);
- }else{
- feedback.setText("Not available houses");
- btnConfirm.setEnabled(false);
- }
- houseBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- rh = (RuralHouse) houseBox.getSelectedItem();
- comboBox.setSelectedItem(rh.getDistrict());
- description_f.setText(rh.getDescription());
- kitchens_f.setText(Integer.toString(rh.getFeatures()
- .getnKitchens()));
- rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
- lRooms_f.setText(Integer.toString(rh.getFeatures()
- .getnLivings()));
- parkings_f.setText(Integer.toString(rh.getFeatures()
- .getnParkings()));
- baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
-
- }
- });
- contentPane.setLayout(null);
- contentPane.add(lblParkings);
- contentPane.add(parkings_f);
- contentPane.add(lblRooms);
- contentPane.add(rooms_f);
- contentPane.add(lblCode);
- contentPane.add(houseBox);
- contentPane.add(lblBaths);
- contentPane.add(baths_f);
- contentPane.add(lblDistrict);
- contentPane.add(lblLivings);
- contentPane.add(lRooms_f);
- contentPane.add(lblKitchen);
- contentPane.add(kitchens_f);
- contentPane.add(description_f);
- contentPane.add(lblDescription);
- contentPane.add(btnConfirm);
-
- feedback = new JLabel("");
- feedback.setBounds(189, 510, 195, 23);
- contentPane.add(feedback);
-
- comboBox.setBounds(127, 116, 86, 20);
- contentPane.add(comboBox);
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.sql.Date;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTextField;
-
-import com.toedter.calendar.JCalendar;
-import common.HouseInterface;
-import common.OfferInterface;
-
-import configuration.___IntNames;
-import domain.Offer;
-import domain.Owner;
-import domain.RuralHouse;
-import exceptions.BadDates;
-
-public class ModifyOfferGUI extends JFrame {
-
- private static final long serialVersionUID = 1L;
-
- private JComboBox<RuralHouse> jComboBox1;
- private JLabel jLabel1 = new JLabel();
- private JLabel jLabel2 = new JLabel();
- private JTextField jTextField1 = new JTextField();
- private JLabel jLabel3 = new JLabel();
- private JTextField jTextField2 = new JTextField();
- private JLabel jLabel4 = new JLabel();
- private JTextField jTextField3 = new JTextField();
- private JButton jButton1 = new JButton();
- // Code for JCalendar
- private JCalendar jCalendar1 = new JCalendar();
- private JCalendar jCalendar2 = new JCalendar();
- private Calendar calendarInicio = null;
- private Calendar calendarFin = null;
- private JButton jButton2 = new JButton();
- private JLabel jLabel5 = new JLabel();
- private final JLabel jLabel1_o = new JLabel();
- private JComboBox<Offer> comboBox_o;
- private Vector<RuralHouse> Hlist = null;
- private OfferInterface om = null;
- private HouseInterface hm = null;
-
-
- public ModifyOfferGUI(Owner o) {
- try {
- jbInit(o);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void jbInit(Owner o) throws Exception {
- this.getContentPane().setLayout(null);
- this.setSize(new Dimension(513, 433));
- this.setTitle("Set availability");
-
-
- try {
- om = (OfferInterface) Naming
- .lookup(___IntNames.OfferManager);
- hm = (HouseInterface) Naming
- .lookup(___IntNames.HouseManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- try {
- Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
- } catch (RemoteException e1) {
- e1.printStackTrace();
- }
-
-
- jComboBox1 = new JComboBox<RuralHouse>(Hlist);
-
- comboBox_o = new JComboBox<Offer>(
- ((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers());
- DateFormat dateformat1 = DateFormat.getDateInstance(1,
- jCalendar1.getLocale());
- if (!((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers()
- .isEmpty()) {
- jTextField1.setText(dateformat1.format(((Offer) comboBox_o
- .getSelectedItem()).getFirstDay()));
- jTextField2.setText(dateformat1.format(((Offer) comboBox_o
- .getSelectedItem()).getLastDay()));
- jLabel4.setText(Float.toString(((Offer) comboBox_o
- .getSelectedItem()).getPrice()));
- jTextField3.setText(Float.toString(((Offer) comboBox_o
- .getSelectedItem()).getPrice()));
- } else {
- jLabel5.setText("There are no offers for the selected rural house");
- jCalendar1.setEnabled(false);
- jCalendar2.setEnabled(false);
- jButton1.setEnabled(false);
- comboBox_o.setEnabled(false);
- jTextField3.setEnabled(false);
- }
- jComboBox1.setBounds(new Rectangle(115, 12, 115, 20));
- jLabel1.setText("List of houses:");
- jLabel1.setBounds(new Rectangle(25, 12, 95, 20));
- jLabel2.setText("First day :");
- jLabel2.setBounds(new Rectangle(25, 75, 85, 25));
- jTextField1.setBounds(new Rectangle(25, 265, 220, 25));
- jTextField1.setEditable(false);
- jLabel3.setText("Last day :");
- jLabel3.setBounds(new Rectangle(260, 75, 75, 25));
- jTextField2.setBounds(new Rectangle(260, 265, 220, 25));
- jTextField2.setEditable(false);
- jLabel4.setText("Price:");
- jLabel4.setBounds(new Rectangle(260, 30, 75, 20));
- jTextField3.setBounds(new Rectangle(350, 30, 115, 20));
- jTextField3.setText("0");
- jButton1.setText("Accept");
- jButton1.setBounds(new Rectangle(100, 360, 130, 30));
- jTextField3.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- }
-
- public void focusLost(FocusEvent e) {
- jTextField3_focusLost();
- }
- });
-
- jComboBox1.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent arg0) {
-
- Vector<Offer> vo= null;
- try {
- vo = om.getRuralHouseOffers((RuralHouse) jComboBox1.getSelectedItem());
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- comboBox_o.removeAllItems();
- if (!vo.isEmpty()) {
- jCalendar1.setEnabled(true);
- jCalendar2.setEnabled(true);
- jButton1.setEnabled(true);
- comboBox_o.setEnabled(true);
- jTextField3.setEnabled(true);
- jLabel5.setText("");
- for (Offer of : vo) {
- comboBox_o.addItem(of);
- }
- } else {
- jLabel5.setText("There are no offers for the selected rural house");
- jCalendar1.setEnabled(false);
- jCalendar2.setEnabled(false);
- jButton1.setEnabled(false);
- comboBox_o.setEnabled(false);
- jTextField3.setEnabled(false);
-
- }
- }
-
- });
-
- comboBox_o.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent arg0) {
- if (arg0.getStateChange() == ItemEvent.SELECTED) {
- Offer of = (Offer) comboBox_o.getSelectedItem();
- DateFormat dateformat1 = DateFormat.getDateInstance(1,
- jCalendar1.getLocale());
- jTextField1.setText(dateformat1.format(of.getFirstDay()));
- jTextField2.setText(dateformat1.format(of.getLastDay()));
- }
- }
-
- });
-
- jButton1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- jButton1_actionPerformed(e);
- }
- });
- jButton2.setText("Cancel");
- jButton2.setBounds(new Rectangle(270, 360, 130, 30));
- jButton2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- jButton2_actionPerformed(e);
- }
- });
- jLabel5.setBounds(new Rectangle(100, 320, 300, 20));
- jLabel5.setForeground(Color.red);
- jLabel5.setSize(new Dimension(305, 20));
- jCalendar1.setBounds(new Rectangle(25, 100, 220, 165));
- jCalendar2.setBounds(new Rectangle(260, 100, 220, 165));
-
- // Code for JCalendar
- this.jCalendar1.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent propertychangeevent) {
- if (propertychangeevent.getPropertyName().equals("locale")) {
- jCalendar1.setLocale((Locale) propertychangeevent
- .getNewValue());
- DateFormat dateformat = DateFormat.getDateInstance(1,
- jCalendar1.getLocale());
- jTextField1.setText(dateformat.format(calendarInicio
- .getTime()));
- } else if (propertychangeevent.getPropertyName().equals(
- "calendar")) {
- calendarInicio = (Calendar) propertychangeevent
- .getNewValue();
- DateFormat dateformat1 = DateFormat.getDateInstance(1,
- jCalendar1.getLocale());
- jTextField1.setText(dateformat1.format(calendarInicio
- .getTime()));
- jCalendar1.setCalendar(calendarInicio);
- }
- }
- });
-
- this.jCalendar2.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent propertychangeevent) {
- if (propertychangeevent.getPropertyName().equals("locale")) {
- jCalendar2.setLocale((Locale) propertychangeevent
- .getNewValue());
- DateFormat dateformat = DateFormat.getDateInstance(1,
- jCalendar2.getLocale());
- jTextField2.setText(dateformat.format(calendarFin.getTime()));
- } else if (propertychangeevent.getPropertyName().equals(
- "calendar")) {
- calendarFin = (Calendar) propertychangeevent.getNewValue();
- DateFormat dateformat1 = DateFormat.getDateInstance(1,
- jCalendar2.getLocale());
- jTextField2.setText(dateformat1.format(calendarFin
- .getTime()));
- jCalendar2.setCalendar(calendarFin);
- }
- }
- });
-
- this.getContentPane().add(jCalendar2, null);
- this.getContentPane().add(jCalendar1, null);
- this.getContentPane().add(jLabel5, null);
- this.getContentPane().add(jButton2, null);
- this.getContentPane().add(jButton1, null);
- this.getContentPane().add(jTextField3, null);
- this.getContentPane().add(jLabel4, null);
- this.getContentPane().add(jTextField2, null);
- this.getContentPane().add(jLabel3, null);
- this.getContentPane().add(jTextField1, null);
- this.getContentPane().add(jLabel2, null);
- this.getContentPane().add(jLabel1, null);
- this.getContentPane().add(jComboBox1, null);
- jLabel1_o.setText("List of offers:");
- jLabel1_o.setBounds(new Rectangle(25, 30, 95, 20));
- jLabel1_o.setBounds(25, 44, 95, 20);
-
- getContentPane().add(jLabel1_o);
- comboBox_o.setBounds(new Rectangle(115, 30, 115, 20));
- comboBox_o.setBounds(115, 44, 115, 20);
-
- getContentPane().add(comboBox_o);
- }
-
- private void jButton1_actionPerformed(ActionEvent e) {
- RuralHouse ruralHouse = ((RuralHouse) jComboBox1.getSelectedItem());
- Date firstDay = new Date(jCalendar1.getCalendar().getTime().getTime());
- // Remove the hour:minute:second:ms from the date
- firstDay = Date.valueOf(firstDay.toString());
- Date lastDay = new Date(jCalendar2.getCalendar().getTime().getTime());
- // Remove the hour:minute:second:ms from the date
- lastDay = Date.valueOf(lastDay.toString());
-
-
- try {
-
- // It could be to trigger an exception if the introduced string is
- // not a number
- float price = Float.parseFloat(jTextField3.getText());
-
- // Obtain the business logic from a StartWindow class (local or
- // remote)
- OfferInterface offerM = null;
- try {
- offerM = (OfferInterface) Naming
- .lookup(___IntNames.OfferManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- offerM.deleteOffer(ruralHouse, (Offer) comboBox_o.getSelectedItem());
- offerM.createOffer(ruralHouse, firstDay, lastDay, price);
-
- jLabel5.setText("Offer modified");
-
- } catch (java.lang.NumberFormatException e1) {
- jLabel5.setText(jTextField3.getText() + " is not a valid price");
- } catch (BadDates e1) {
- jLabel5.setText("Last day is before first day in the offer");
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
-
- private void jButton2_actionPerformed(ActionEvent e) {
- this.setVisible(false);
- }
-
- private void jTextField3_focusLost() {
- try {
- new Integer(jTextField3.getText());
- jLabel5.setText("");
- } catch (NumberFormatException ex) {
- jLabel5.setText("Error: Please introduce a number");
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package gui;
-
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-
-import domain.Owner;
-
-public class OffersRelatedOwnerGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private Owner owner;
- /**
- * Create the frame.
- */
- public OffersRelatedOwnerGUI(Owner o) {
- this.getContentPane().setLayout(null);
- owner = o;
- setBounds(100, 100, 450, 562);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- JButton btnCreateOffers = new JButton("Create Offers");
- btnCreateOffers.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- Frame a = new AddOffersGUI(owner.getRuralHouses());
- a.setVisible(true);
- }
- });
-
- JButton btnModifyOffers = new JButton("Modify Offers");
- btnModifyOffers.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
-
- Frame a = new ModifyOfferGUI(owner);
- a.setVisible(true);
-
- }
- });
-
- JButton btnDeleteOffers = new JButton("Delete Offers");
- btnDeleteOffers.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new DeleteOfferGUI(owner);
- a.setVisible(true);
- }
- });
- GroupLayout gl_contentPane = new GroupLayout(contentPane);
- gl_contentPane.setHorizontalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(110)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addComponent(btnDeleteOffers, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE)
- .addComponent(btnModifyOffers, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE)
- .addComponent(btnCreateOffers, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE))
- .addGap(121))
- );
- gl_contentPane.setVerticalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(88)
- .addComponent(btnCreateOffers, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
- .addGap(40)
- .addComponent(btnModifyOffers, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
- .addGap(39)
- .addComponent(btnDeleteOffers, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(394, Short.MAX_VALUE))
- );
- contentPane.setLayout(gl_contentPane);
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.border.EmptyBorder;
-
-import domain.Owner;
-
-public class OwnerMenuGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private Owner owner;
-
-
- /**
- * Create the frame.
- */
- public OwnerMenuGUI(Owner o) {
- this.setTitle("Owner Menu");
- this.getContentPane().setLayout(null);
- owner = o;
- setBounds(100, 100, 450, 473);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- JButton btnHouses = new JButton("Houses");
- btnHouses.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new HousesRelatedOwnerGUI(owner);
- a.setVisible(true);
- }
- });
-
- JButton btnOffers = new JButton("Offers");
- btnOffers.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new OffersRelatedOwnerGUI(owner);
- a.setVisible(true);
- }
- });
-
- JButton btnBookings = new JButton("Bookings");
- btnBookings.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Frame a = new listOfOffers(owner);
- a.setVisible(true);
- }
- });
- GroupLayout gl_contentPane = new GroupLayout(contentPane);
- gl_contentPane.setHorizontalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(115)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
- .addComponent(btnBookings, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(btnOffers, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
- .addComponent(btnHouses, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))
- .addContainerGap(145, Short.MAX_VALUE))
- );
- gl_contentPane.setVerticalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(62)
- .addComponent(btnHouses, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
- .addGap(58)
- .addComponent(btnOffers, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
- .addComponent(btnBookings, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
- );
- contentPane.setLayout(gl_contentPane);
- }
-
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.border.EmptyBorder;
-
-import common.AdminInterface;
-
-import configuration.___IntNames;
-import domain.Owner;
-
-public class OwnerRegistrationGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel panel;
- private JTextField nameField;
- private JTextField userNameField;
- private AdminInterface am = null;
- private JTextField passField;
- private JTextField bank1Field;
- private JTextField bank2Field;
- private JTextField bank3Field;
- private JTextField bank4Field;
- private JTextField emailField;
- private JLabel lblWhenAcceptedYou;
- private JLabel feedback;
-
- /**
- * Create the frame.
- */
- public OwnerRegistrationGUI() {
-
- try {
- am = (AdminInterface) Naming.lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- setTitle("Owner registration");
- setBounds(100, 100, 500, 400);
- panel = new JPanel();
- panel.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(panel);
- panel.setLayout(null);
-
- JLabel nameLb = new JLabel("Name:");
- nameLb.setBounds(37, 45, 46, 14);
- panel.add(nameLb);
-
- nameField = new JTextField();
- nameField.setBounds(147, 42, 86, 20);
- panel.add(nameField);
- nameField.setColumns(10);
-
- JLabel lblUsername = new JLabel("Username:");
- lblUsername.setBounds(37, 212, 69, 14);
- panel.add(lblUsername);
-
- userNameField = new JTextField();
- userNameField.setBounds(147, 209, 86, 20);
- panel.add(userNameField);
- userNameField.setColumns(10);
-
- JLabel lblPassword = new JLabel("Password:");
- lblPassword.setBounds(37, 258, 69, 14);
- panel.add(lblPassword);
-
- passField = new JTextField();
- passField.setBounds(147, 255, 86, 20);
- panel.add(passField);
- passField.setColumns(10);
-
- JLabel lblBankAccount = new JLabel("Bank account:");
- lblBankAccount.setBounds(37, 94, 69, 14);
- panel.add(lblBankAccount);
-
- bank1Field = new JTextField();
- bank1Field.setBounds(147, 91, 61, 20);
- panel.add(bank1Field);
-
- bank2Field = new JTextField();
- bank2Field.setBounds(218, 91, 61, 20);
- panel.add(bank2Field);
-
- bank3Field = new JTextField();
- bank3Field.setBounds(289, 91, 32, 20);
- panel.add(bank3Field);
-
- bank4Field = new JTextField();
- bank4Field.setBounds(331, 91, 117, 20);
- panel.add(bank4Field);
-
- JButton btnSendRegistrationRequest = new JButton(
- "Send registration request");
- btnSendRegistrationRequest.setBounds(127, 316, 194, 23);
- btnSendRegistrationRequest.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
-
- jButton_ActionPerformed(arg0);
- }
- });
-
- panel.add(btnSendRegistrationRequest);
-
- JLabel lblEmail = new JLabel("E-mail:");
- lblEmail.setBounds(37, 155, 46, 14);
- panel.add(lblEmail);
-
- emailField = new JTextField();
- emailField.setBounds(147, 152, 148, 20);
- panel.add(emailField);
- emailField.setColumns(10);
-
- lblWhenAcceptedYou = new JLabel(
- "When accepted you will receive an e-mail");
- lblWhenAcceptedYou.setForeground(Color.GREEN);
- lblWhenAcceptedYou.setBounds(127, 291, 214, 14);
- panel.add(lblWhenAcceptedYou);
-
- feedback = new JLabel("");
- feedback.setForeground(Color.RED);
- feedback.setEnabled(false);
- feedback.setBounds(127, 344, 214, 20);
- panel.add(feedback);
- }
-
- private void jButton_ActionPerformed(ActionEvent e) {
-
- if (!emailField
- .getText()
- .matches(
- "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")
- || !this.nameField.getText().isEmpty()||this.bank1Field.getText().length()!=4 || this.bank2Field.getText().length()!=4
- ||this.bank3Field.getText().length()!=2 || this.bank4Field.getText().length()!=10) {
- Owner own = new Owner(this.nameField.getText(),
- this.bank1Field.getText() + " " + this.bank2Field.getText()
- + " " + this.bank3Field.getText() + " "
- + this.bank4Field.getText(),
- this.emailField.getText());
-
- try {
- if (this.am.addAccountRequest(this.userNameField.getText(),
- this.passField.getText(), own)) {
- this.am.saveInstance();
- this.feedback.setText("Request sended");
- } else {
- this.feedback.setText("Can't send the request");
- }
- } catch (RemoteException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- } else {
- this.feedback.setText("Bad formatted data");
- }
-
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.sql.Date;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.Vector;
-
-import javax.swing.ButtonGroup;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButton;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-
-import com.toedter.calendar.JCalendar;
-import common.HouseInterface;
-
-import configuration.___IntNames;
-import domain.Districs;
-import domain.RuralHouse;
-
-public class QueryAvailabilityGUI2 extends JFrame {
- private static final long serialVersionUID = 1L;
-
- private JComboBox<String> jComboBox1;
- private JLabel jLabel2 = new JLabel();
- private JTextField jTextField1 = new JTextField();
- private JLabel jLabel3 = new JLabel();
- private JTextField jTextField2 = new JTextField();
- private JLabel jLabel4 = new JLabel();
- private JTextField jTextField3 = new JTextField();
- private JButton jButton1 = new JButton();
-
- // Code for JCalendar
- private JCalendar jCalendar1 = new JCalendar();
- private JCalendar jCalendar2 = new JCalendar();
- private Calendar calendarInicio = null;
- private Calendar calendarFin = null;
- private JButton jButton2 = new JButton();
- private JLabel jLabel5 = new JLabel();
- private final JLabel lblNewLabel = new JLabel("");
- private final JRadioButton ruralHouseName = new JRadioButton(
- "Use RuralHouse name");
- private final JRadioButton district = new JRadioButton("Use District Name");
- private final ButtonGroup buttonGroup = new ButtonGroup();
- private final JMenuBar menuBar = new JMenuBar();
- private final JMenu mnMoreOptions = new JMenu("Search Options");
- private final JMenuItem PopUpM = new JMenuItem("More Filters");
- private final JPopupMenu popupMenu = new JPopupMenu();
- private final JLabel lblNewLabel_1 = new JLabel("Number of bedrooms:");
- private JTextField nBedrooms;
- private JTextField nKitchens;
- private final JLabel lblExtraFeatures = new JLabel("EXTRA FEATURES");
- private final JLabel lblNumberOfBaths = new JLabel("Number of baths:");
- private final JTextField nBaths = new JTextField();
- private final JLabel lblParkings = new JLabel("Parking slots:");
- private final JTextField nParkings = new JTextField();
- private HouseInterface houseMan = null;
- private final JLabel lblNumberOfLivings = new JLabel("Number of Livings:");
- private final JTextField nLivings = new JTextField();
- private final JLabel feedback = new JLabel("");
-
- public QueryAvailabilityGUI2() {
-
- try {
- houseMan = (HouseInterface) Naming
- .lookup(___IntNames.HouseManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- nLivings.setText("0");
- nLivings.setColumns(10);
- nParkings.setText("0");
- nParkings.setColumns(10);
- nBaths.setText("0");
- nBaths.setColumns(10);
- try {
- jbInit();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void jbInit() throws Exception {
- this.getContentPane().setLayout(null);
- this.setSize(new Dimension(550, 500));
- this.setTitle("Query Availability");
-
- jComboBox1 = new JComboBox<String>(new DefaultComboBoxModel<String>(
- Districs.longNames()));
- jComboBox1.setEnabled(false);
- jComboBox1.setBounds(new Rectangle(115, 30, 115, 20));
- jLabel2.setText("First day :");
- jLabel2.setBounds(new Rectangle(20, 134, 85, 25));
- jTextField1.setBounds(new Rectangle(20, 350, 220, 25));
- jTextField1.setEditable(false);
- jLabel3.setText("Last day :");
- jLabel3.setBounds(new Rectangle(281, 134, 75, 25));
- jTextField2.setBounds(new Rectangle(281, 350, 220, 20));
- jTextField2.setEditable(false);
- jLabel4.setText("Rural House name:");
- jLabel4.setBounds(new Rectangle(275, 30, 128, 20));
- jTextField3.setBounds(new Rectangle(413, 30, 115, 20));
- jButton1.setText("Search");
- jButton1.setBounds(new Rectangle(60, 377, 165, 30));
- jButton1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- jButton1_actionPerformed(e);
- }
- });
- jButton2.setText("Cancel");
- jButton2.setBounds(new Rectangle(305, 377, 162, 30));
- jButton2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- jButton2_actionPerformed(e);
- }
- });
- jLabel5.setBounds(new Rectangle(207, 600, 305, 20));
- jLabel5.setForeground(Color.red);
- jLabel5.setSize(new Dimension(305, 20));
- jCalendar1.setBounds(new Rectangle(20, 184, 220, 165));
- jCalendar2.setBounds(new Rectangle(281, 184, 220, 165));
-
- // Code for JCalendar
- this.jCalendar1.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent propertychangeevent) {
- if (propertychangeevent.getPropertyName().equals("locale")) {
- jCalendar1.setLocale((Locale) propertychangeevent
- .getNewValue());
- DateFormat dateformat = DateFormat.getDateInstance(1,
- jCalendar1.getLocale());
- jTextField1.setText(dateformat.format(calendarInicio
- .getTime()));
- } else if (propertychangeevent.getPropertyName().equals(
- "calendar")) {
- calendarInicio = (Calendar) propertychangeevent
- .getNewValue();
- DateFormat dateformat1 = DateFormat.getDateInstance(1,
- jCalendar1.getLocale());
- jTextField1.setText(dateformat1.format(calendarInicio
- .getTime()));
- jCalendar1.setCalendar(calendarInicio);
- }
- }
- });
-
- this.jCalendar2.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent propertychangeevent) {
- if (propertychangeevent.getPropertyName().equals("locale")) {
- jCalendar2.setLocale((Locale) propertychangeevent
- .getNewValue());
- DateFormat dateformat = DateFormat.getDateInstance(1,
- jCalendar2.getLocale());
- jTextField2.setText(dateformat.format(calendarFin.getTime()));
- } else if (propertychangeevent.getPropertyName().equals(
- "calendar")) {
- calendarFin = (Calendar) propertychangeevent.getNewValue();
- DateFormat dateformat1 = DateFormat.getDateInstance(1,
- jCalendar2.getLocale());
- jTextField2.setText(dateformat1.format(calendarFin
- .getTime()));
- jCalendar2.setCalendar(calendarFin);
- }
- }
- });
- popupMenu.setBounds(75, 125, 58, 16);
-
- addPopup(getContentPane(), popupMenu);
- lblExtraFeatures.setHorizontalAlignment(SwingConstants.CENTER);
-
- popupMenu.add(lblExtraFeatures);
-
- popupMenu.add(lblNewLabel_1);
-
- nBedrooms = new JTextField();
- nBedrooms.setText("0");
- popupMenu.add(nBedrooms);
- nBedrooms.setColumns(10);
-
- JLabel lblNumberOfKitchens = new JLabel("Number of kitchens:");
- popupMenu.add(lblNumberOfKitchens);
-
- nKitchens = new JTextField();
- nKitchens.setText("0");
- popupMenu.add(nKitchens);
- nKitchens.setColumns(10);
-
- popupMenu.add(lblNumberOfBaths);
-
- popupMenu.add(nBaths);
-
- popupMenu.add(lblParkings);
-
- popupMenu.add(nParkings);
-
- popupMenu.add(lblNumberOfLivings);
-
- popupMenu.add(nLivings);
-
- this.getContentPane().add(jCalendar2, null);
- this.getContentPane().add(jCalendar1, null);
- this.getContentPane().add(jLabel5, null);
- this.getContentPane().add(jButton2, null);
- this.getContentPane().add(jButton1, null);
- this.getContentPane().add(jTextField3, null);
- this.getContentPane().add(jLabel4, null);
- this.getContentPane().add(jTextField2, null);
- this.getContentPane().add(jLabel3, null);
- this.getContentPane().add(jTextField1, null);
- this.getContentPane().add(jLabel2, null);
- this.getContentPane().add(jComboBox1, null);
- lblNewLabel.setBounds(115, 301, 298, 38);
-
- getContentPane().add(lblNewLabel);
- ;
- district.setBounds(20, 69, 128, 20);
- getContentPane().add(district);
- buttonGroup.add(ruralHouseName);
- buttonGroup.add(district);
- ruralHouseName.setSelected(true);
- ruralHouseName.setBounds(276, 60, 177, 38);
- district.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- int state = e.getStateChange();
- if (state == ItemEvent.SELECTED) {
- jComboBox1.setEnabled(true);
- jCalendar1.setEnabled(false);
- jCalendar2.setEnabled(false);
- } else if (state == ItemEvent.DESELECTED) {
- jComboBox1.setEnabled(false);
-
- }
- }
- });
-
- ruralHouseName.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- int state = e.getStateChange();
- if (state == ItemEvent.SELECTED) {
- jTextField3.setEnabled(true);
- jCalendar1.setEnabled(true);
- jCalendar2.setEnabled(true);
- } else if (state == ItemEvent.DESELECTED) {
- jTextField3.setEnabled(false);
- }
- }
- });
- getContentPane().add(ruralHouseName);
-
- JLabel lblNewLabel_2 = new JLabel("District name:");
- lblNewLabel_2.setBounds(20, 30, 85, 17);
- getContentPane().add(lblNewLabel_2);
- feedback.setHorizontalAlignment(SwingConstants.CENTER);
- feedback.setForeground(Color.RED);
- feedback.setBounds(134, 413, 269, 17);
-
- getContentPane().add(feedback);
-
- setJMenuBar(menuBar);
-
- menuBar.add(mnMoreOptions);
- PopUpM.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- popupMenu.show(QueryAvailabilityGUI2.this, popupMenu.getX(),
- popupMenu.getY());
- }
- });
-
- mnMoreOptions.add(PopUpM);
- }
-
- private void jButton1_actionPerformed(ActionEvent e) {
- if (this.district.isSelected()) {
- Vector<RuralHouse> houses = null;
- try {
- houses = houseMan.getHouses(null, null, jComboBox1
- .getSelectedItem().toString(), Integer.parseInt(nBedrooms
- .getText()), Integer.parseInt(nKitchens.getText()), Integer
- .parseInt(nBaths.getText()), Integer.parseInt(nParkings
- .getText()), Integer.parseInt(nLivings.getText()));
- } catch (NumberFormatException | RemoteException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- listOfHousesGUI list = new listOfHousesGUI(houses);
- list.setVisible(true);
- } else if (this.ruralHouseName.isSelected()) {
- try {
- RuralHouse rh = houseMan.getHouses(null, jTextField3.getText(), null,
- 0, 0, 0, 0, 0).get(0);
- // The next instruction creates a java.sql.Date object from the
- // date selected in the JCalendar object
- Date firstDay = new Date(jCalendar1.getCalendar().getTime()
- .getTime());
- // The next instruction removes the hour, minute, second and ms
- // from the date
- // This has to be made because the date will be stored in db4o
- // as a java.util.Date object
- // that would store those data, and that would give problems
- // when comparing dates later
- firstDay = Date.valueOf(firstDay.toString());
-
- Date lastDay = new Date(jCalendar2.getCalendar().getTime()
- .getTime());
- // Remove the hour:minute:second:ms from the date
- lastDay = Date.valueOf(lastDay.toString());
- if(firstDay!=null&&lastDay!=null&&firstDay.before(lastDay)){
- HouseFeaturesGUI hou = new HouseFeaturesGUI(rh, firstDay,
- lastDay);
- hou.setVisible(true);
- }else{
- feedback.setText("Wrong Dates");
- }
-
- } catch (Exception e1) {
- feedback.setText("Not matching houses");
- }
- }
- }
-
- private void jButton2_actionPerformed(ActionEvent e) {
- this.setVisible(false);
- }
-
- private static void addPopup(Component component, final JPopupMenu popup) {
- component.addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- if (e.isPopupTrigger()) {
- showMenu(e);
- }
- }
-
- public void mouseReleased(MouseEvent e) {
- if (e.isPopupTrigger()) {
- showMenu(e);
- }
- }
-
- private void showMenu(MouseEvent e) {
- popup.show(e.getComponent(), e.getX(), e.getY());
- }
- });
- }
-}
\ No newline at end of file
+++ /dev/null
-package gui;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.border.EmptyBorder;
-
-import common.AdminInterface;
-
-import configuration.___IntNames;
-import domain.Owner;
-import domain.RuralHouse;
-
-public class RequestDeleteHouseGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private Owner owner;
- private JComboBox<RuralHouse> comboBox;
- private JButton btnDelete;
- private AdminInterface am = null;
- JLabel feedback = new JLabel("");
-
- /**
- * Create the frame.
- */
- public RequestDeleteHouseGUI(Owner o) {
- try {
- am = (AdminInterface) Naming
- .lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- this.owner = o;
- setBounds(100, 100, 450, 300);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- comboBox = new JComboBox<RuralHouse>(this.owner.getRuralHouses());
- comboBox.setBounds(75, 55, 332, 20);
-
-
- JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
- rdbtnIAmSure.setBounds(90, 154, 90, 23);
-
- btnDelete = new JButton("REQUEST");
- btnDelete.setBounds(90, 213, 90, 23);
- btnDelete.setEnabled(false);
-
- rdbtnIAmSure.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- int state = e.getStateChange();
- if (state == ItemEvent.SELECTED){
- btnDelete.setEnabled(true);
- }
- else if (state == ItemEvent.DESELECTED){
- btnDelete.setEnabled(false);
- }
- }
- });
- contentPane.setLayout(null);
- contentPane.add(comboBox);
- contentPane.add(rdbtnIAmSure);
- contentPane.add(btnDelete);
- feedback.setBounds(90, 184, 274, 18);
- contentPane.add(feedback);
-
- btnDelete.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- actionListenerButton(arg0);
-
- }
-
-
- });
- }
-
- private void actionListenerButton(ActionEvent e){
- RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
-
- try {
- if(am.addDeletionRequest(toDel)){
- am.saveInstance();
- feedback.setText("Delete request sended");
-
- }else{
- feedback.setText("Request cannot be sended(Already sended)");
- }
- } catch (RemoteException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.SwingConstants;
-import javax.swing.border.EmptyBorder;
-
-import common.AdminInterface;
-
-import configuration.___IntNames;
-import domain.Districs;
-import domain.HouseFeatures;
-import domain.Owner;
-import domain.RuralHouse;
-
-public class RequestNewHouseGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private Owner owner;
- private JLabel lblCode ;
- private JLabel feedback = new JLabel("");
- private JTextField Code_f;
- private JLabel lblTown;
- private JLabel lblDescription;
- private JTextField description_f;
- private JLabel lblKitchen;
- private JTextField kitchens_f;
- private JLabel lblRooms;
- private JTextField rooms_f;
- private JLabel lblLivings;
- private JTextField lRooms_f;
- private JLabel lblParkings;
- private JTextField parkings_f;
- private JLabel lblBaths;
- private JTextField baths_f;
- private JButton btnRegister;
- private AdminInterface am = null;
- private JComboBox<String> comboBox;
-
-
- /**
- * Create the frame.
- */
- public RequestNewHouseGUI(Owner o) {
- comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
- Districs.longNames()));
- try {
- am = (AdminInterface) Naming
- .lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- this.setTitle("New House");
- setBackground(Color.WHITE);
- this.getContentPane().setLayout(null);
- owner = o;
- setBounds(100, 100, 500, 583);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
-
- lblCode = new JLabel("House Name:");
- lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
-
- Code_f = new JTextField();
- Code_f.setColumns(10);
-
- lblTown = new JLabel("District:");
- lblTown.setHorizontalAlignment(SwingConstants.RIGHT);
-
- lblDescription = new JLabel("Description(optional):");
- lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
-
- description_f = new JTextField();
- description_f.setToolTipText("");
- description_f.setHorizontalAlignment(SwingConstants.LEFT);
- description_f.setColumns(10);
-
- lblKitchen = new JLabel("Kitchens:");
- lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT);
-
- kitchens_f = new JTextField();
- kitchens_f.setColumns(10);
-
- lblRooms = new JLabel("Rooms:");
- lblRooms.setHorizontalAlignment(SwingConstants.RIGHT);
-
- rooms_f = new JTextField();
- rooms_f.setColumns(10);
-
- lblLivings = new JLabel("Living rooms:");
- lblLivings.setHorizontalAlignment(SwingConstants.RIGHT);
-
- lRooms_f = new JTextField();
- lRooms_f.setColumns(10);
-
- lblParkings = new JLabel("Parkings:");
- lblParkings.setHorizontalAlignment(SwingConstants.RIGHT);
-
- parkings_f = new JTextField();
- parkings_f.setColumns(10);
-
- lblBaths = new JLabel("Baths:");
- lblBaths.setHorizontalAlignment(SwingConstants.RIGHT);
-
- baths_f = new JTextField();
- baths_f.setColumns(10);
-
- btnRegister = new JButton("Request registration");
- btnRegister.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- RuralHouse rh = null;
- try {
- //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
- rh = new RuralHouse(Code_f.getText(),
- owner, description_f.getText(),
- (String) comboBox.getSelectedItem(), new HouseFeatures(Integer.parseInt(rooms_f.getText()),
- Integer.parseInt(kitchens_f.getText()),
- Integer.parseInt(baths_f.getText()),
- Integer.parseInt(lRooms_f.getText()),
- Integer.parseInt(parkings_f.getText())) );
-
- }
- catch(NumberFormatException e){
- e.printStackTrace();
- }
-
- try {
- if(am.addAdditionRequest(rh)){
- am.saveInstance();
- feedback.setText("Request sended");
- }else{
- feedback.setText("Request cannot be sended(Already added)");
- }
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- });
-
-
-
-
- GroupLayout gl_contentPane = new GroupLayout(contentPane);
- gl_contentPane.setHorizontalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addContainerGap()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblTown, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblLivings)
- .addGap(18)
- .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblCode)
- .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(Code_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblBaths, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
- .addGap(29)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addComponent(lblDescription)
- .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE)))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblKitchen, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblRooms, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(18)
- .addComponent(lblParkings, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.UNRELATED)
- .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(140)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addComponent(feedback, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE)
- .addComponent(btnRegister))))
- .addContainerGap(97, Short.MAX_VALUE))
- );
- gl_contentPane.setVerticalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(20)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(63)
- .addComponent(lblDescription)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(60)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
- .addComponent(lblCode)
- .addComponent(Code_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(ComponentPlacement.UNRELATED)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
- .addComponent(lblTown)
- .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(18)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addComponent(lblLivings)
- .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
- .addGap(63)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(3)
- .addComponent(lblRooms))
- .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(ComponentPlacement.RELATED)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(3)
- .addComponent(lblKitchen)))
- .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(3)
- .addComponent(lblBaths))
- .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(45)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
- .addComponent(lblParkings)
- .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(41)
- .addComponent(feedback, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.UNRELATED)
- .addComponent(btnRegister)
- .addGap(54))
- );
- contentPane.setLayout(gl_contentPane);
- }
-}
+++ /dev/null
-package gui;
-
-/**
- * @author willCodeForFood
- */
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.KeyEventDispatcher;
-import java.awt.KeyboardFocusManager;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.rmi.RMISecurityManager;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.SwingConstants;
-import javax.swing.UIManager;
-
-import configuration.ConfigXML;
-
-@SuppressWarnings("deprecation")
-public class StartWindow extends JFrame {
-
- private static final long serialVersionUID = 1L;
-
- private JPanel jContentPane = null;
- private JButton boton2 = null;
- private JButton boton3 = null;
- private static configuration.ConfigXML c;
- private JLabel lblNewLabel;
-
- public static void main(String[] args) {
-
- StartWindow a = new StartWindow();
-
- System.setProperty("java.security.policy", "java.policy");
-
- a.setVisible(true);
-
- try {
-
- c = ConfigXML.getInstance();
-
- System.setProperty("java.security.policy", c.getJavaPolicyPath());
-
- System.setSecurityManager(new RMISecurityManager());
-
- 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);
- System.out.println("Error in StartWindow: " + e.toString());
- } catch (Exception e) {
- a.lblNewLabel.setText("Error: " + e.toString());
- a.lblNewLabel.setForeground(Color.RED);
- System.out.println("Error in StartWindow: " + e.toString());
- }
-
- }
-
- /**
- * This is the default constructor
- */
-
- public StartWindow() {
- super();
-
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
-
- System.exit(1);
- }
-
- });
-
- KeyboardFocusManager.getCurrentKeyboardFocusManager()
- .addKeyEventDispatcher(new KeyEventDispatcher() {
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent e) {
- switch (e.getKeyCode()) {
-
- case KeyEvent.VK_ESCAPE:
- System.exit(1);
-
- }
- return false;
- }
- });
- initialize();
- // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
-
- /**
- * This method initializes this
- *
- * @return void
- */
- private void initialize() {
- // this.setSize(271, 295);
- this.setSize(495, 290);
- this.setContentPane(getJContentPane());
- this.setTitle("Rural Houses");
- }
-
- /**
- * This method initializes jContentPane
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- jContentPane = new JPanel();
- jContentPane.setLayout(null);
- jContentPane.add(getLblNewLabel());
- jContentPane.add(getBoton2());
- jContentPane.add(getBoton3());
- }
- return jContentPane;
- }
-
- /**
- * This method initializes boton2
- *
- * @return javax.swing.JButton
- */
- private JButton getBoton2() {
- if (boton2 == null) {
- boton2 = new JButton();
- boton2.setBounds(0, 74, 479, 93);
- boton2.setText("Login");
- boton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- // C?digo cedido por la universidad
- JFrame a = new LoginGUI();
- a.setVisible(true);
- }
- });
- }
- return boton2;
- }
-
- /**
- * This method initializes boton3
- *
- * @return javax.swing.JButton
- */
- private JButton getBoton3() {
- if (boton3 == null) {
- boton3 = new JButton();
- boton3.setBounds(0, 165, 479, 87);
- boton3.setText("Query availability");
- boton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- // C?digo cedido por la universidad
- // JFrame a = new QueryAvailabilityWindow();
- JFrame a = new QueryAvailabilityGUI2();
-
- a.setVisible(true);
- }
- });
- }
- return boton3;
- }
-
- private JLabel getLblNewLabel() {
- if (lblNewLabel == null) {
- lblNewLabel = new JLabel("Select option:");
- lblNewLabel.setBounds(0, 0, 479, 63);
- lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13));
- lblNewLabel.setForeground(Color.BLACK);
- lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
- }
- return lblNewLabel;
- }
-
-} // @jve:decl-index=0:visual-constraint="0,0"
-
+++ /dev/null
-package gui;
-
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableModel;
-
-import common.AdminInterface;
-import common.HouseInterface;
-
-import configuration.___IntNames;
-import domain.RuralHouse;
-
-public class listOfAdditionRequestsGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JTable table;
- private DefaultTableModel tableModel;
- private AdminInterface am = null;
- private Vector<RuralHouse> houses;
- /**
- * Create the frame.
- */
- public listOfAdditionRequestsGUI() {
-
- try {
- am = (AdminInterface) Naming
- .lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- setTitle("Adding requests");
- try {
- this.houses= am.getAdditionRequests();
- init();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void init() throws Exception {
- setBounds(100, 100, 600, 450);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- JLabel lblNewLabel = new JLabel();
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
- lblNewLabel.setBounds(23, 41, 536, 33);
- contentPane.add(lblNewLabel);
- if (houses.isEmpty())
- lblNewLabel.setText("There are not houses to be added");
- else
- lblNewLabel.setText("List of houses to be added:");
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
- scrollPane.setBounds(23, 113, 536, 271);
- contentPane.add(scrollPane);
-
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
- scrollPane.setViewportView(table);
- tableModel = new DefaultTableModel(null, new String[] {
- "House Name", "Bedrooms", "Kitchens", "Baths", "Parkings",
- "Livings" });
-
- //Maybe there is a better way to avoid interaction.
- //table.setEnabled(false);
- table.setModel(tableModel);
-
- JButton btnNewButton = new JButton("Confirm Addition");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
- HouseInterface hm= null;
- try {
- hm = (HouseInterface) Naming
- .lookup(___IntNames.HouseManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- RuralHouse rh = houses.get(table.getSelectedRow());
- //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
- try {
- hm.registerNewHouse(rh);
- am.removeHouseAdditionRequests(rh);
- am.saveInstance();
- } catch (RemoteException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
- }
- }
- });
- btnNewButton.setBounds(88, 396, 169, 25);
- contentPane.add(btnNewButton);
-
- JButton btnDenyAddition = new JButton("Deny Addition");
- btnDenyAddition.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
- RuralHouse rh = houses.get(table.getSelectedRow());
- try {
- am.removeHouseAdditionRequests(rh);
- am.saveInstance();
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
- houses.remove(rh);
- }
- }
- });
- btnDenyAddition.setBounds(300, 396, 169, 25);
- contentPane.add(btnDenyAddition);
- Enumeration<RuralHouse> en = houses.elements();
- RuralHouse rh;
-
- while (en.hasMoreElements()) {
- rh = en.nextElement();
- Vector<Object> row = new Vector<Object>();
- row.add(rh.getHouseName());
- row.add(rh.getFeatures().getnRooms());
- row.add(rh.getFeatures().getnKitchens());
- row.add(rh.getFeatures().getnBaths());
- row.add(rh.getFeatures().getnParkings());
- row.add(rh.getFeatures().getnLivings());
- tableModel.addRow(row);
- }
-
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-
-import common.BookingInterface;
-
-import configuration.___IntNames;
-import domain.Booking;
-import domain.Offer;
-
-public class listOfBookingRequestsGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JTable table;
- private Offer off;
- private BookingInterface bookM = null;
- private DefaultTableModel tableModel;
- private Vector<Booking> bookings = new Vector<Booking>();
-
- /**
- * Create the frame.
- */
- public listOfBookingRequestsGUI(Offer of) {
- setTitle("Adding requests");
- this.off = of;
-
- try {
-
- init();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void init() throws Exception {
- setBounds(100, 100, 600, 500);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- this.bookings = this.off.getBookings();
- JLabel lblNewLabel = new JLabel();
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
- lblNewLabel.setBounds(23, 41, 536, 33);
- contentPane.add(lblNewLabel);
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
- scrollPane.setBounds(23, 113, 536, 271);
- contentPane.add(scrollPane);
-
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
- scrollPane.setViewportView(table);
- tableModel = new DefaultTableModel(null,
- new String[] { "Booking Number", "Booking Date", "Name",
- "E-mail", "Telephone" });
-
- table.setModel(tableModel);
-
- JButton btnNewButton = new JButton("Confirm Booking");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- bookM = (BookingInterface) Naming
- .lookup(___IntNames.BookingManager);
- } catch (Exception e1) {
- System.out
- .println("Error accessing remote authentication: "
- + e1.toString());
- }
- if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
- if (table.getRowCount() != 0
- && table.getSelectedRow() != -1) {
- Booking book = bookings.get(table.getSelectedRow());
- try {
- bookM.acceptBooking(book);
- } catch (RemoteException e1) {
- e1.printStackTrace();
- }
- contentPane.setVisible(false);
-
- }
-
- }
- }
- });
- btnNewButton.setBounds(33, 396, 169, 25);
- contentPane.add(btnNewButton);
-
- JButton btnDenyAddition = new JButton("Deny Booking");
- btnDenyAddition.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- try {
- bookM = (BookingInterface) Naming
- .lookup(___IntNames.BookingManager);
- } catch (Exception e1) {
- System.out
- .println("Error accessing remote authentication: "
- + e1.toString());
- }
- if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
- Booking book = bookings.get(table.getSelectedRow());
- try {
- bookM.denyBooking(book);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- ((DefaultTableModel) table.getModel()).removeRow(table
- .getSelectedRow());
- bookings.remove(book);
-
- }
- }
- });
- if (bookings.isEmpty())
- lblNewLabel
- .setText("There are not bookings to be confirmed or denied");
- else {
- lblNewLabel.setText("List of bookings:");
- if (this.bookings.get(0).getOffer().isBooked()) {
- btnDenyAddition.setEnabled(false);
- btnNewButton.setEnabled(false);
- }
- }
-
- btnDenyAddition.setBounds(390, 395, 169, 25);
- contentPane.add(btnDenyAddition);
-
- Enumeration<Booking> en = this.bookings.elements();
- Booking book;
- while (en.hasMoreElements()) {
- book = en.nextElement();
- Vector<Object> row = new Vector<Object>();
- row.add(book.getBookNumber());
- row.add(book.getBookDate());
- row.add(book.getClient().getName());
- row.add(book.getClient().getMailAccount());
- row.add(book.getClient().getTelephone());
- tableModel.addRow(row);
- }
- table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
- int row, int col) {
-
- super.getTableCellRendererComponent(table, value, isSelected,
- hasFocus, row, col);
-
- if (!bookings.get(row).getOffer().isBooked()) {
- setBackground(Color.RED);
- setForeground(Color.BLACK);
- } else {
- setBackground(Color.GREEN);
- setForeground(Color.BLACK);
- }
-
- return this;
- }
- });
- }
-
-}
+++ /dev/null
-package gui;
-
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableModel;
-
-import domain.RuralHouse;
-
-public class listOfHousesGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JTable table;
- private DefaultTableModel tableModel;
- private Vector<RuralHouse> houses;
- /**
- * Create the frame.
- */
- public listOfHousesGUI(Vector<RuralHouse> rhs) {
- try {
- this.houses=rhs;
- init();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void init() throws Exception {
- setBounds(100, 100, 600, 450);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- JLabel lblNewLabel = new JLabel();
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
- lblNewLabel.setBounds(23, 41, 536, 33);
- contentPane.add(lblNewLabel);
- if (houses.isEmpty())
- lblNewLabel.setText("There are not houses matching your search");
- else
- lblNewLabel.setText("List of houses that match your search:");
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
- scrollPane.setBounds(23, 113, 536, 271);
- contentPane.add(scrollPane);
-
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
- scrollPane.setViewportView(table);
- tableModel = new DefaultTableModel(null, new String[] {
- "House Name", "Bedrooms", "Kitchens", "Baths", "Parkings",
- "Livings" });
-
- //Maybe there is a better way to avoid interaction.
- //table.setEnabled(false);
- table.setModel(tableModel);
- Enumeration<RuralHouse> en = houses.elements();
- RuralHouse rh;
- table.addMouseListener( new MouseAdapter(){
- @Override
- public void mouseClicked(MouseEvent arg0) {
- int row = table.getSelectedRow();
- HouseFeaturesGUI feat = new HouseFeaturesGUI(houses.get(row),null,null);
- feat.setVisible(true);
- }
- });
- while (en.hasMoreElements()) {
- rh = en.nextElement();
- Vector<Object> row = new Vector<Object>();
- row.add(rh.getHouseName());
- row.add(rh.getFeatures().getnRooms());
- row.add(rh.getFeatures().getnKitchens());
- row.add(rh.getFeatures().getnBaths());
- row.add(rh.getFeatures().getnParkings());
- row.add(rh.getFeatures().getnLivings());
- tableModel.addRow(row);
- }
-
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-
-import domain.Offer;
-import domain.Owner;
-import domain.RuralHouse;
-
-public class listOfOffers extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JTable table;
- private Owner owner;
-
- private DefaultTableModel tableModel;
- private Vector<Offer> offers = new Vector<Offer>();
-
- /**
- * Create the frame.
- */
- public listOfOffers(Owner own) {
- setTitle("Adding requests");
- this.owner = own;
- try {
-
- init();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void init() throws Exception {
- setBounds(100, 100, 600, 450);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- this.offers = new Vector<Offer>();
- for (RuralHouse rh: this.owner.getRuralHouses()){
- this.offers.addAll(rh.getAllOffers());
- }
- JLabel lblNewLabel = new JLabel();
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
- lblNewLabel.setBounds(23, 41, 536, 33);
- contentPane.add(lblNewLabel);
- if (this.offers.isEmpty())
- lblNewLabel
- .setText("There are not bookings to be confirmed or denied");
- else
- lblNewLabel.setText("List of offers:");
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
- scrollPane.setBounds(23, 113, 536, 271);
- contentPane.add(scrollPane);
-
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
-
- scrollPane.setViewportView(table);
- tableModel = new DefaultTableModel(null, new String[] { "Offer #",
- "FirstDay", "LastDay", "Price" ,"RuralHouse"});
-
- // Maybe there is a better way to avoid interaction.
- // table.setEnabled(false);
- table.setModel(tableModel);
- table.addMouseListener( new MouseAdapter(){
- @Override
- public void mouseClicked(MouseEvent arg0) {
- int row = table.getSelectedRow();
- listOfBookingRequestsGUI feat = new listOfBookingRequestsGUI(offers.get(row));
- feat.setVisible(true);
- }
- });
- Enumeration<Offer> rhs = this.offers.elements();
- while (rhs.hasMoreElements()) {
- Offer of = rhs.nextElement();
- Vector<Object> row = new Vector<Object>();
- row.add(of.getOfferNumber());
- row.add(of.getFirstDay());
- row.add(of.getLastDay());
- row.add(of.getPrice());
- row.add(of.getRuralHouse().getHouseName());
- tableModel.addRow(row);
- }
-
- table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
- int row, int col) {
-
- super.getTableCellRendererComponent(table, value, isSelected,
- hasFocus, row, col);
-
- if (!offers.get(row).isBooked()) {
- setBackground(Color.ORANGE);
- setForeground(Color.BLACK);
- } else {
- setBackground(Color.GREEN);
- setForeground(Color.BLACK);
- }
-
- return this;
- }
- });
-
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableModel;
-
-import common.AccountInterface;
-import common.AdminInterface;
-
-import configuration.___IntNames;
-import domain.Account;
-
-public class listOfOwnerAddittionRequests extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JTable table;
- private DefaultTableModel tableModel;
- private AdminInterface am = null;
- private Vector<Account> accounts;
- /**
- * Create the frame.
- */
- public listOfOwnerAddittionRequests() {
- try {
- am = (AdminInterface) Naming
- .lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- setTitle("Adding requests");
- try {
- this.accounts= am.getOwnerAdditionRequests();
- init();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void init() throws Exception {
-
- try {
- am = (AdminInterface) Naming
- .lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- setBounds(100, 100, 600, 450);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- JLabel lblNewLabel = new JLabel();
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
- lblNewLabel.setBounds(23, 41, 536, 33);
- contentPane.add(lblNewLabel);
- if (accounts.isEmpty())
- lblNewLabel.setText("There are not owners to be added");
- else
- lblNewLabel.setText("List of owners to be added:");
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
- scrollPane.setBounds(23, 113, 536, 271);
- contentPane.add(scrollPane);
-
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
- scrollPane.setViewportView(table);
- tableModel = new DefaultTableModel(null, new String[] {
- "Name", "E-mail", "Bank Account" });
-
- table.setModel(tableModel);
-
- JButton btnNewButton = new JButton("Confirm Addition");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
- AccountInterface acm = null;
-
- try {
- acm = (AccountInterface) Naming
- .lookup(___IntNames.AccountManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
-
- try {
- acm.addAccount(table.getSelectedRow());
- am.removeOwnerAdditionRequests(table.getSelectedRow());
- am.saveInstance();
- } catch (RemoteException e1) {
- e1.printStackTrace();
- }
-
- ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
-
- }
- }
- });
- btnNewButton.setBounds(88, 396, 169, 25);
- contentPane.add(btnNewButton);
-
- JButton btnDenyAddition = new JButton("Deny Addition");
- btnDenyAddition.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
- try {
- am.removeOwnerAdditionRequests(table.getSelectedRow());
- am.saveInstance();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
-
- ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
- }
- }
- });
- btnDenyAddition.setBounds(300, 396, 169, 25);
- contentPane.add(btnDenyAddition);
- Enumeration<Account> en = accounts.elements();
- Account acc;
-
- while (en.hasMoreElements()) {
- acc = en.nextElement();
- Vector<Object> row = new Vector<Object>();
- row.add(acc.getOwner().getName());
- row.add(acc.getOwner().getMailAccount());
- row.add(acc.getOwner().getBankAccount());
- tableModel.addRow(row);
- }
-
- }
-}
+++ /dev/null
-package gui;
-
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableModel;
-
-import common.AdminInterface;
-import common.HouseInterface;
-
-import configuration.___IntNames;
-import domain.RuralHouse;
-
-public class listOfRemovalRequestsGUI extends JFrame {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JPanel contentPane;
- private JTable table;
- private DefaultTableModel tableModel;
- private AdminInterface am = null;
- private Vector<RuralHouse> houses;
-
- /**
- * Create the frame.
- */
- public listOfRemovalRequestsGUI() {
- try {
- am = (AdminInterface) Naming.lookup(___IntNames.AdminManager);
- } catch (Exception e1) {
- System.out.println("Error accessing remote authentication: "
- + e1.toString());
- }
- setTitle("Deleting requests");
- try {
- this.houses = am.getDeletionRequests();
- init();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void init() throws Exception {
- setBounds(100, 100, 600, 450);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- JLabel lblNewLabel = new JLabel();
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
- lblNewLabel.setBounds(23, 41, 536, 33);
- contentPane.add(lblNewLabel);
- if (houses.isEmpty())
- lblNewLabel.setText("There are not houses to be deleted");
- else
- lblNewLabel.setText("List of houses to be deleted:");
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
- scrollPane.setBounds(23, 113, 536, 271);
- contentPane.add(scrollPane);
-
- table = new JTable() {
- private static final long serialVersionUID = 1L;
-
- public boolean isCellEditable(int row, int column) {
- return false;
- };
- };
- scrollPane.setViewportView(table);
- tableModel = new DefaultTableModel(null, new String[] { "House Name",
- "Bedrooms", "Kitchens", "Baths", "Parkings", "Livings" });
-
- table.setModel(tableModel);
- Enumeration<RuralHouse> en = houses.elements();
- RuralHouse rh;
- JButton btnNewButton = new JButton("Confirm Deletion");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
- HouseInterface hm = null;
- try {
- hm = (HouseInterface) Naming
- .lookup(___IntNames.HouseManager);
- } catch (Exception e1) {
- System.out
- .println("Error accessing remote authentication: "
- + e1.toString());
- }
- RuralHouse rh = houses.get(table.getSelectedRow());
-
- try {
- hm.removeHouse(rh, rh.getOwner());
- am.removeHouseDeletionRequests(rh);
- am.saveInstance();
- } catch (RemoteException e1) {
- e1.printStackTrace();
- }
- ((DefaultTableModel) table.getModel()).removeRow(houses
- .indexOf(rh));
- houses.remove(rh);
-
- }
- }
- });
- btnNewButton.setBounds(90, 396, 169, 25);
- contentPane.add(btnNewButton);
-
- JButton btnNewButton_1 = new JButton("Deny Deletion");
- btnNewButton_1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
- RuralHouse rh = houses.get(table.getSelectedRow());
- ((DefaultTableModel) table.getModel()).removeRow(houses
- .indexOf(rh));
- houses.remove(rh);
- try {
- am.removeHouseDeletionRequests(rh);
- am.saveInstance();
- } catch (RemoteException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- }
- }
- });
- btnNewButton_1.setBounds(291, 396, 169, 25);
- contentPane.add(btnNewButton_1);
- while (en.hasMoreElements()) {
- rh = en.nextElement();
- Vector<Object> row = new Vector<Object>();
- row.add(rh.getHouseName());
- row.add(rh.getFeatures().getnRooms());
- row.add(rh.getFeatures().getnKitchens());
- row.add(rh.getFeatures().getnBaths());
- row.add(rh.getFeatures().getnParkings());
- row.add(rh.getFeatures().getnLivings());
- tableModel.addRow(row);
- }
-
- }
-}