|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.ericmignot.modeler.gui.palette; |
|
19 |
| |
|
20 |
| import java.awt.BorderLayout; |
|
21 |
| import java.awt.FlowLayout; |
|
22 |
| import java.awt.event.ActionEvent; |
|
23 |
| import java.awt.event.ActionListener; |
|
24 |
| import java.util.Map; |
|
25 |
| |
|
26 |
| import javax.swing.JButton; |
|
27 |
| import javax.swing.JDialog; |
|
28 |
| import javax.swing.JPanel; |
|
29 |
| |
|
30 |
| import org.ericmignot.modeler.data.BusinessObject; |
|
31 |
| |
|
32 |
| public abstract class UpdatePanel extends JPanel |
|
33 |
| { |
|
34 |
| private BusinessObject businessObject; |
|
35 |
| |
|
36 |
| public static final boolean OK = true; |
|
37 |
| public static final boolean CANCEL = false; |
|
38 |
| private boolean state; |
|
39 |
| |
|
40 |
| private JButton okButton, cancelButton; |
|
41 |
| private JPanel buttonPanel; |
|
42 |
| |
|
43 |
| private JDialog dialog; |
|
44 |
| |
|
45 |
0
| public UpdatePanel()
|
|
46 |
| { |
|
47 |
0
| this.businessObject = null;
|
|
48 |
0
| this.dialog = null;
|
|
49 |
0
| this.state = CANCEL;
|
|
50 |
0
| initComponents();
|
|
51 |
| } |
|
52 |
| |
|
53 |
0
| public BusinessObject getBusinessObject()
|
|
54 |
| { |
|
55 |
0
| return businessObject;
|
|
56 |
| } |
|
57 |
| |
|
58 |
0
| public void setBusinessObject(BusinessObject businessObject)
|
|
59 |
| { |
|
60 |
0
| this.businessObject = businessObject;
|
|
61 |
0
| this.add(this.getSpecificPanel(), BorderLayout.CENTER);
|
|
62 |
| } |
|
63 |
| |
|
64 |
0
| public void setDialog (JDialog dialog)
|
|
65 |
| { |
|
66 |
0
| this.dialog = dialog;
|
|
67 |
| } |
|
68 |
| |
|
69 |
0
| private void initComponents()
|
|
70 |
| { |
|
71 |
0
| okButton = new JButton("OK");
|
|
72 |
0
| okButton.addActionListener(new ActionListener()
|
|
73 |
| { |
|
74 |
0
| public void actionPerformed(ActionEvent e)
|
|
75 |
| { |
|
76 |
0
| UpdatePanel.this.treatOK();
|
|
77 |
| } |
|
78 |
| } |
|
79 |
| ); |
|
80 |
0
| cancelButton = new JButton ("Cancel");
|
|
81 |
0
| cancelButton.addActionListener(new ActionListener()
|
|
82 |
| { |
|
83 |
0
| public void actionPerformed(ActionEvent e)
|
|
84 |
| { |
|
85 |
0
| UpdatePanel.this.treatCancel();
|
|
86 |
| } |
|
87 |
| } |
|
88 |
| ); |
|
89 |
| |
|
90 |
0
| this.setLayout(new BorderLayout());
|
|
91 |
0
| JPanel tmp = new JPanel();
|
|
92 |
0
| this.add(tmp, BorderLayout.NORTH);
|
|
93 |
| |
|
94 |
0
| buttonPanel = new JPanel(new FlowLayout());
|
|
95 |
0
| buttonPanel.add(okButton);
|
|
96 |
0
| buttonPanel.add(cancelButton);
|
|
97 |
0
| this.add(buttonPanel, BorderLayout.SOUTH);
|
|
98 |
| } |
|
99 |
| |
|
100 |
0
| private void treatOK()
|
|
101 |
| { |
|
102 |
0
| this.state = OK;
|
|
103 |
0
| this.dialog.dispose();
|
|
104 |
| } |
|
105 |
0
| private void treatCancel()
|
|
106 |
| { |
|
107 |
0
| this.state = CANCEL;
|
|
108 |
0
| this.dialog.dispose();
|
|
109 |
| } |
|
110 |
| |
|
111 |
0
| public boolean getState()
|
|
112 |
| { |
|
113 |
0
| return this.state;
|
|
114 |
| } |
|
115 |
| |
|
116 |
0
| public JPanel getButtonPanel()
|
|
117 |
| { |
|
118 |
0
| return this.buttonPanel;
|
|
119 |
| } |
|
120 |
| |
|
121 |
| protected abstract JPanel getSpecificPanel(); |
|
122 |
| protected abstract Map getNewValues(); |
|
123 |
| |
|
124 |
| |
|
125 |
| } |