Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions e90cb4 ... vs 4bc36b ... 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;
29 + import common.HouseInterface;
28 30 import common.OfferInterface;
29 31
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,22 +57,40 @@
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 -
72 - jComboBox1 = new JComboBox<RuralHouse>(v);
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 + }
93 + jComboBox1 = new JComboBox<RuralHouse>(Hlist);
73 94
74 95 comboBox_o = new JComboBox<Offer>(
75 96 ((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers());
  @@ -123,10 +144,16 @@
123 144
124 145 @Override
125 146 public void itemStateChanged(ItemEvent arg0) {
126 - Vector<Offer> vo = ((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers();
147 +
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 + }
127 155 comboBox_o.removeAllItems();
128 - if (!((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers()
129 - .isEmpty()) {
156 + if (!vo.isEmpty()) {
130 157 jCalendar1.setEnabled(true);
131 158 jCalendar2.setEnabled(true);
132 159 jButton1.setEnabled(true);