Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard
 
d30bcc8a3c13bbf5144b03a644c1345865aed708
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
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.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;

import common.OfferInterface;

import configuration.___IntNames;
import domain.Offer;
import domain.Owner;
import domain.RuralHouse;

public class DeleteOfferGUI extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private Owner owner;
	private JLabel feedback;
	private JComboBox<RuralHouse> comboBox;
	private JComboBox<Offer> comboBox_1;
	private JButton btnDelete;

	/**
	 * Create the frame.
	 */
	public DeleteOfferGUI(Owner o) {
		this.owner = o;
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		comboBox = new JComboBox<RuralHouse>(this.owner.getRuralHouses());
		comboBox.setBounds(101, 38, 314, 20);

		comboBox_1 = new JComboBox<Offer>();
		comboBox_1.setBounds(101, 76, 314, 20);
		Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).offers;
		comboBox_1.removeAllItems();
		for (Offer of : vo) {
			comboBox_1.addItem(of);
			;
		}

		JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
		rdbtnIAmSure.setBounds(101, 134, 108, 23);

		btnDelete = new JButton("DELETE");
		btnDelete.setBounds(92, 226, 117, 23);
		btnDelete.setEnabled(false);

		comboBox.addItemListener(new ItemListener() {

			@Override
			public void itemStateChanged(ItemEvent arg0) {
				Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).offers;
				comboBox_1.removeAllItems();
				for (Offer of : vo) {
					comboBox_1.addItem(of);
					;
				}

			}

		});

		rdbtnIAmSure.addItemListener(new ItemListener() {

			@Override
			public void itemStateChanged(ItemEvent e) {
				int state = e.getStateChange();
				if (state == ItemEvent.SELECTED) {
					if (comboBox_1.getSelectedItem() != null)
						btnDelete.setEnabled(true);
				} else if (state == ItemEvent.DESELECTED) {
					btnDelete.setEnabled(false);
				}
			}
		});

		JLabel lblHouse = new JLabel("House:");
		lblHouse.setBounds(25, 41, 68, 14);

		JLabel lblOffer = new JLabel("Offer:");
		lblOffer.setBounds(25, 79, 68, 14);
		contentPane.setLayout(null);
		contentPane.add(btnDelete);
		contentPane.add(rdbtnIAmSure);
		contentPane.add(lblHouse);
		contentPane.add(lblOffer);
		contentPane.add(comboBox);
		contentPane.add(comboBox_1);
		
		feedback = new JLabel("");
		feedback.setBounds(140, 178, 202, 23);
		contentPane.add(feedback);

		btnDelete.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				actionListenerButton(arg0);

			}

		});
	}

	private void actionListenerButton(ActionEvent e) {

		Offer toDel = (Offer) comboBox_1.getSelectedItem();
		OfferInterface oM = null;
		try {
			oM = (OfferInterface) Naming
					.lookup(___IntNames.OfferManager);
		} catch (Exception e1) {
			System.out.println("Error accessing remote authentication: "
					+ e1.toString());
		}
  		
		try {
			oM.deleteOffer((RuralHouse) comboBox.getSelectedItem(), toDel);
			comboBox_1.removeItem(toDel);
			btnDelete.setEnabled(false);
			feedback.setText("Offer correctly deleted");
		} catch (Exception e1) {
			feedback.setText("Imposible to delete the offer");
			e1.printStackTrace();
		}
		
	}
}

Commits for RRRRHHHH_CoderuralHouses/src/gui/DeleteOfferGUI.java

Diff revisions: vs.
Revision Author Commited Message
d30bcc ... Diff Diff pinene picture pinene Wed 20 May, 2015 16:32:33 +0000

cleaning

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

Merge conflicts solutioned

520867 ... Diff Diff pinene picture pinene Sun 19 Apr, 2015 14:09:12 +0000

tmp

5761bc ... Diff Diff camjan Wed 15 Apr, 2015 15:27:07 +0000

Bugs when deleting houses and offers fixed and GUI’s adapated for empty cases

e2ae30 ... Diff Diff Eneko Pinzolas Murua Tue 14 Apr, 2015 15:07:35 +0000

imports leaned

64482a ... Diff Diff Eneko Pinzolas Murua Sat 04 Apr, 2015 12:23:48 +0000

DeleteOffers and Modify Offers completed, both logic and GUI

95c4ff ... pinene picture pinene Tue 10 Mar, 2015 18:36:52 +0000

deleted: ruralHouses/hs_err_pid6014.log
modified: ruralHouses/src/businessLogic/OfferManager.java
modified: ruralHouses/src/dataAccess/DB4oManager.java
renamed: ruralHouses/src/gui/SetAvailability2GUI.java -> ruralHouses/src/gui/AddOffersGUI.java
modified: ruralHouses/src/gui/DeleteHouseGUI.java
new file: ruralHouses/src/gui/DeleteOfferGUI.java
deleted: ruralHouses/src/gui/SetAvailabilityGUI.java