|
@@ -43,8 +43,7 @@ |
43 |
43 |
|
*/ |
44 |
44 |
|
public DeleteOfferGUI(Owner o) { |
45 |
45 |
|
try { |
46 |
|
- |
hm = (HouseInterface) Naming |
47 |
|
- |
.lookup(___IntNames.HouseManager); |
|
46 |
+ |
hm = (HouseInterface) Naming.lookup(___IntNames.HouseManager); |
48 |
47 |
|
} catch (Exception e1) { |
49 |
48 |
|
System.out.println("Error accessing remote authentication: " |
50 |
49 |
|
+ e1.toString()); |
|
@@ -53,7 +52,7 @@ |
53 |
52 |
|
Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0); |
54 |
53 |
|
} catch (RemoteException e1) { |
55 |
54 |
|
e1.printStackTrace(); |
56 |
|
- |
} |
|
55 |
+ |
} |
57 |
56 |
|
setBounds(100, 100, 450, 300); |
58 |
57 |
|
contentPane = new JPanel(); |
59 |
58 |
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
@@ -64,7 +63,8 @@ |
64 |
63 |
|
|
65 |
64 |
|
comboBox_1 = new JComboBox<Offer>(); |
66 |
65 |
|
comboBox_1.setBounds(101, 76, 314, 20); |
67 |
|
- |
Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers(); |
|
66 |
+ |
Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()) |
|
67 |
+ |
.getAllOffers(); |
68 |
68 |
|
comboBox_1.removeAllItems(); |
69 |
69 |
|
for (Offer of : vo) { |
70 |
70 |
|
comboBox_1.addItem(of); |
|
@@ -82,7 +82,8 @@ |
82 |
82 |
|
|
83 |
83 |
|
@Override |
84 |
84 |
|
public void itemStateChanged(ItemEvent arg0) { |
85 |
|
- |
Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers(); |
|
85 |
+ |
Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()) |
|
86 |
+ |
.getAllOffers(); |
86 |
87 |
|
comboBox_1.removeAllItems(); |
87 |
88 |
|
for (Offer of : vo) { |
88 |
89 |
|
comboBox_1.addItem(of); |
|
@@ -92,7 +93,31 @@ |
92 |
93 |
|
} |
93 |
94 |
|
|
94 |
95 |
|
}); |
|
96 |
+ |
comboBox_1.addItemListener(new ItemListener() { |
|
97 |
+ |
|
|
98 |
+ |
@Override |
|
99 |
+ |
public void itemStateChanged(ItemEvent arg0) { |
|
100 |
+ |
if (((Offer) comboBox_1.getSelectedItem()).isBooked()) { |
|
101 |
+ |
feedback.setText("This offer is already booked."); |
|
102 |
+ |
btnDelete.setEnabled(false); |
|
103 |
+ |
} |
|
104 |
+ |
|
|
105 |
+ |
} |
|
106 |
+ |
|
|
107 |
+ |
}); |
|
108 |
+ |
comboBox_1.addItemListener(new ItemListener() { |
95 |
109 |
|
|
|
110 |
+ |
@Override |
|
111 |
+ |
public void itemStateChanged(ItemEvent arg0) { |
|
112 |
+ |
if (comboBox_1.getSelectedItem() != null) { |
|
113 |
+ |
if (!((Offer) comboBox_1.getSelectedItem()).isBooked()) { |
|
114 |
+ |
feedback.setText(""); |
|
115 |
+ |
btnDelete.setEnabled(true); |
|
116 |
+ |
} |
|
117 |
+ |
} |
|
118 |
+ |
} |
|
119 |
+ |
|
|
120 |
+ |
}); |
96 |
121 |
|
rdbtnIAmSure.addItemListener(new ItemListener() { |
97 |
122 |
|
|
98 |
123 |
|
@Override |
|
@@ -119,11 +144,14 @@ |
119 |
144 |
|
contentPane.add(lblOffer); |
120 |
145 |
|
contentPane.add(comboBox); |
121 |
146 |
|
contentPane.add(comboBox_1); |
122 |
|
- |
|
|
147 |
+ |
|
123 |
148 |
|
feedback = new JLabel(""); |
124 |
149 |
|
feedback.setBounds(140, 178, 202, 23); |
125 |
150 |
|
contentPane.add(feedback); |
126 |
|
- |
|
|
151 |
+ |
if (((Offer) comboBox_1.getSelectedItem()).isBooked()) { |
|
152 |
+ |
feedback.setText("This offer is already booked."); |
|
153 |
+ |
btnDelete.setEnabled(false); |
|
154 |
+ |
} |
127 |
155 |
|
btnDelete.addActionListener(new ActionListener() { |
128 |
156 |
|
public void actionPerformed(ActionEvent arg0) { |
129 |
157 |
|
actionListenerButton(arg0); |
|
@@ -138,13 +166,12 @@ |
138 |
166 |
|
Offer toDel = (Offer) comboBox_1.getSelectedItem(); |
139 |
167 |
|
OfferInterface oM = null; |
140 |
168 |
|
try { |
141 |
|
- |
oM = (OfferInterface) Naming |
142 |
|
- |
.lookup(___IntNames.OfferManager); |
|
169 |
+ |
oM = (OfferInterface) Naming.lookup(___IntNames.OfferManager); |
143 |
170 |
|
} catch (Exception e1) { |
144 |
171 |
|
System.out.println("Error accessing remote authentication: " |
145 |
172 |
|
+ e1.toString()); |
146 |
173 |
|
} |
147 |
|
- |
|
|
174 |
+ |
|
148 |
175 |
|
try { |
149 |
176 |
|
oM.deleteOffer((RuralHouse) comboBox.getSelectedItem(), toDel); |
150 |
177 |
|
comboBox_1.removeItem(toDel); |
|
@@ -154,6 +181,6 @@ |
154 |
181 |
|
feedback.setText("Imposible to delete the offer"); |
155 |
182 |
|
e1.printStackTrace(); |
156 |
183 |
|
} |
157 |
|
- |
|
|
184 |
+ |
|
158 |
185 |
|
} |
159 |
186 |
|
} |