Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions 578bec ... vs ad3773 ... for ruralHouses client/src/gui/ModifyOfferGUI.java

Diff revisions: vs.
  @@ -12,6 +12,7 @@
12 12 import java.beans.PropertyChangeEvent;
13 13 import java.beans.PropertyChangeListener;
14 14 import java.rmi.Naming;
15 + import java.rmi.RemoteException;
15 16 import java.sql.Date;
16 17 import java.text.DateFormat;
17 18 import java.util.Calendar;
  @@ -25,10 +26,12 @@
25 26 import javax.swing.JTextField;
26 27
27 28 import com.toedter.calendar.JCalendar;
28 - import common.OfferInterface;
29 29
30 + import common.HouseInterface;
31 + import common.OfferInterface;
30 32 import configuration.___IntNames;
31 33 import domain.Offer;
34 + import domain.Owner;
32 35 import domain.RuralHouse;
33 36 import exceptions.BadDates;
34 37
  @@ -54,23 +57,41 @@
54 57 private JLabel jLabel5 = new JLabel();
55 58 private final JLabel jLabel1_o = new JLabel();
56 59 private JComboBox<Offer> comboBox_o;
60 + private Vector<RuralHouse> Hlist = null;
61 + private OfferInterface om = null;
62 + private HouseInterface hm = null;
57 63
58 - public ModifyOfferGUI(Vector<RuralHouse> v) {
64 +
65 + public ModifyOfferGUI(Owner o) {
59 66 try {
60 - jbInit(v);
67 + jbInit(o);
61 68 } catch (Exception e) {
62 69 e.printStackTrace();
63 70 }
64 71 }
65 72
66 - private void jbInit(Vector<RuralHouse> v) throws Exception {
73 + private void jbInit(Owner o) throws Exception {
67 74 this.getContentPane().setLayout(null);
68 75 this.setSize(new Dimension(513, 433));
69 76 this.setTitle("Set availability");
70 77
71 - OfferInterface om = null;
78 +
79 + try {
80 + om = (OfferInterface) Naming
81 + .lookup(___IntNames.OfferManager);
82 + hm = (HouseInterface) Naming
83 + .lookup(___IntNames.HouseManager);
84 + } catch (Exception e1) {
85 + System.out.println("Error accessing remote authentication: "
86 + + e1.toString());
87 + }
88 + try {
89 + Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
90 + } catch (RemoteException e1) {
91 + e1.printStackTrace();
92 + }
72 93
73 - jComboBox1 = new JComboBox<RuralHouse>(v);
94 + jComboBox1 = new JComboBox<RuralHouse>(Hlist);
74 95
75 96 comboBox_o = new JComboBox<Offer>(
76 97 ((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers());
  @@ -124,10 +145,15 @@
124 145
125 146 @Override
126 147 public void itemStateChanged(ItemEvent arg0) {
127 - Vector<Offer> vo = ((RuralHouse) jComboBox1.getSelectedItem()).offers;
148 + Vector<Offer> vo= null;
149 + try {
150 + vo = om.getRuralHouseOffers((RuralHouse) jComboBox1.getSelectedItem());
151 + } catch (RemoteException e) {
152 + // TODO Auto-generated catch block
153 + e.printStackTrace();
154 + }
128 155 comboBox_o.removeAllItems();
129 - if (!((RuralHouse) jComboBox1.getSelectedItem()).offers
130 - .isEmpty()) {
156 + if (!vo.isEmpty()) {
131 157 jCalendar1.setEnabled(true);
132 158 jCalendar2.setEnabled(true);
133 159 jButton1.setEnabled(true);