Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard
 
66f0c834c28b40aeac91b173d6def82e24c3b02b
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;

import domain.HouseFeatures;
import domain.Owner;
import domain.RuralHouse;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JTextPane;

import businessLogic.AdminManager;
import businessLogic.HouseManager;
import businessLogic.HouseManagerInterface;

public class RequestNewHouseGUI extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private Owner owner;
	private JLabel lblCode ;
	private JTextField Code_f;
	private JLabel lblTown;
	private JTextField Town_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 JButton btnRegister;
	private AdminManager am;


	/**
	 * Create the frame.
	 */
	public RequestNewHouseGUI(Owner o) {
		
		am  = new AdminManager();
		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 Code:");
		lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
		
		Code_f = new JTextField();
		Code_f.setColumns(10);
		
		lblTown = new JLabel("Town:");
		lblTown.setHorizontalAlignment(SwingConstants.RIGHT);
		
		Town_f = new JTextField();
		Town_f.setColumns(10);
		
		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(),
								Town_f.getText() ,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();
				}
				
				am.addAdditionRequest(rh);
			}
		});
		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()
							.addGap(140)
							.addComponent(btnRegister))
						.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(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 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)))
					.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(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblTown))
							.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, 7, 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(88)
					.addComponent(btnRegister)
					.addGap(54))
		);
		contentPane.setLayout(gl_contentPane);
	}
}

Commits for RRRRHHHH_CoderuralHouses/src/gui/RequestNewHouseGUI.java

Diff revisions: vs.
Revision Author Commited Message
66f0c8 ... Eneko Pinzolas Murua Sun 12 Apr, 2015 18:11:42 +0000

Model modified so that owners now request for a new house insetion or a house removal. Furthermore, all Administrator GUI and bussines logic create. However, Login GUI and BussinesLogic are to be modified so that they integrate Admin identification.