Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard
 
076d768e70e04655a2c343f46d0808c16a27130c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
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)) {
						feedback.setText("House properly modified");
					} else
						feedback.setText("Imposible to modify the house");
				} catch (RemoteException e) {
					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);
	}
}

Commits for RRRRHHHH_CoderuralHouses client/src/gui/ModifyHouseGUI.java

Diff revisions: vs.
Revision Author Commited Message
076d76 ... Diff Diff camjan Fri 22 May, 2015 22:22:23 +0000

The bug found in the presentation that we forgot to review has been fixed

4bc36b ... Diff Diff camjan Tue 19 May, 2015 23:23:13 +0000

Merge branch ‘master’ of https://xp-dev.com/git/RRRRHHHH_Code

Conflicts:
ruralHouses client/src/gui/HouseFeaturesGUI.java
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses/src/domain/RuralHouse.java

ad3773 ... Diff Diff pinene picture pinene Tue 19 May, 2015 18:01:40 +0000

data now is gotten using queries

4f8bcc ... epinzolas001 Mon 18 May, 2015 09:49:54 +0000

Merge conflicts solutioned