1 /*
2 * Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchroton,
3 * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
4 *
5 * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS.
6 * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
7 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND
8 * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
9 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
11 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE
12 * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR
13 * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
14 * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
15 * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
16 * OR MODIFICATIONS.
17 * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION,
18 * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS
19 * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY
20 * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM
21 */
22
23 package de.desy.acop.chart.customizer;
24
25 import java.awt.GridBagLayout;
26 import java.beans.Customizer;
27 import java.beans.PropertyChangeSupport;
28
29 import javax.swing.JButton;
30 import javax.swing.JComboBox;
31 import javax.swing.JFrame;
32 import javax.swing.JLabel;
33 import javax.swing.JPanel;
34 import javax.swing.JTabbedPane;
35 import javax.swing.JTextField;
36
37 import de.desy.acop.chart.Acop;
38
39 /**
40 * @author wu To change the template for this generated type comment go to
41 * Window>Preferences>Java>Code Generation>Code and Comments
42 */
43 public class AcopCustomizer extends JTabbedPane implements Customizer
44 {
45 // private String accessRate, accessRateOld;
46 // private AccessMode accessMode;
47 // private int accessModeIndex, accessModeIndexOld;
48 // private AccessMode[] accessModeString = AccessMode.values();
49 protected Acop bean; // The bean being customized.
50 private ColorCustomizerPanel colorCustomizer;
51 private DisplayCustomizerPanel displayCustomizer;
52 private FrameCustomizerPanel frameCustomizer;
53 private GraphCustomizerPanel graphCustomizer;
54 private AxisCustomizerPanel axisCustomizer;
55 private SpecialCustomizerPanel specialCustomizer;
56 private MarkersCustomizerPanel markersCustomizer;
57 /**
58 * This is the default constructor
59 */
60 public AcopCustomizer()
61 {
62 super();
63 // System.err.println("TEST1");
64 initialize();
65 }
66 /**
67 * This method initializes this
68 *
69 * @return void
70 */
71 private void initialize()
72 {
73 listeners = new PropertyChangeSupport(this);
74 // System.out.println("TEST1");
75 // this.setLayout(new CardLayout() );
76 setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
77
78 JPanel p = new JPanel();
79 p.setLayout(new GridBagLayout());
80
81 // p.add(getDevice(), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
82 // GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
83 // p.add(getDisplayButton(), new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
84 // GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
85 // p.add(getLabel(), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
86 // GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
87 // p.add(getChoiceMode(), new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
88 // GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
89 // p.add(getLabel1(), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
90 // GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
91 // p.add(getTextFieldRate(), new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
92 // GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
93 // addTab("Device", p);
94
95 displayCustomizer = new DisplayCustomizerPanel();
96 addTab("Display", displayCustomizer);
97
98 frameCustomizer = new FrameCustomizerPanel();
99 addTab("Frame", frameCustomizer);
100
101 graphCustomizer = new GraphCustomizerPanel();
102 addTab("Graph", graphCustomizer);
103
104 axisCustomizer = new AxisCustomizerPanel();
105 addTab("Axis", axisCustomizer);
106
107 specialCustomizer = new SpecialCustomizerPanel();
108 addTab("Special", specialCustomizer);
109
110 markersCustomizer = new MarkersCustomizerPanel();
111 addTab("Markers", markersCustomizer);
112 /*
113 p = new JPanel();
114 p.setLayout(new GridBagLayout());
115 p.add(new JButton("Test"), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
116 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
117 addTab("Marker", p);
118 */
119 colorCustomizer = new ColorCustomizerPanel();
120 addTab("Colors", colorCustomizer);
121
122 this.setSize(478, 297);
123 }
124 public void setObject(Object o)
125 {
126 bean = (Acop) o; // Save the object we're customizing.
127 // Put a label at the top of the panel.
128 // this.setLayout(new BorderLayout());
129 // accessRate = "555";
130 // accessRate = new String(bean.getAcopTransport().getAccessRate());
131 // accessRateOld = new String(accessRate);
132 // textFieldRate.setText(accessRate);
133 // accessMode = AccessMode.WRITE;
134 // accessMode = bean.getAcopTransport().getAccessMode();
135
136 // choiceMode.setSelectedItem(accessMode);
137 displayCustomizer.setAcopBean(bean);
138 frameCustomizer.setAcopBean(bean);
139 graphCustomizer.setAcopBean(bean);
140 axisCustomizer.setAcopBean(bean);
141 specialCustomizer.setAcopBean(bean);
142 markersCustomizer.setAcopBean(bean);
143 colorCustomizer.setAcopBean(bean);
144 }
145 /*
146 * public void addPropertyChangeListener(PropertyChangeListener l) { // defer
147 * to the support object listeners.addPropertyChangeListener(l); } public void
148 * removePropertyChangeListener(PropertyChangeListener l) { // defer to the
149 * support object listeners.removePropertyChangeListener(l); }
150 */
151 // This code uses the PropertyChangeSupport class to maintain a list of
152 // listeners interested in the edits we make to the bean.
153 protected PropertyChangeSupport listeners;
154 // private JButton device = null;
155 private JLabel label = null;
156 private JButton DisplayButton = null;
157 private JComboBox choiceMode = null;
158 private JLabel label1 = null;
159 private JTextField textFieldRate = null;
160 /**
161 * This method initializes device
162 *
163 * @return java.awt.Button
164 */
165 // private JButton getDevice()
166 // {
167 // if (device == null)
168 // {
169 // device = new JButton();
170 // // device.setBounds(20, 27, 55, 23);
171 // device.setText("Device");
172 // device.setName("Device");
173 // }
174 // return device;
175 // }
176 /**
177 * This method initializes label
178 *
179 * @return java.awt.Label
180 */
181 private JLabel getLabel()
182 {
183 if (label == null)
184 {
185 label = new JLabel();
186 // label.setBounds(23, 86, 38, 23);
187 label.setText("Mode:");
188 label.setName("Mode");
189 }
190 return label;
191 }
192 /**
193 * This method initializes DisplayButton
194 *
195 * @return java.awt.Button
196 */
197 private JButton getDisplayButton()
198 {
199 if (DisplayButton == null)
200 {
201 DisplayButton = new JButton();
202 // DisplayButton.setBounds(82, 25, 54, 23);
203 DisplayButton.setText("Display");
204 DisplayButton.setName("Display");
205 }
206 return DisplayButton;
207 }
208 /**
209 * This method initializes choiceMode
210 *
211 * @return java.awt.Choice
212 */
213 // private JComboBox getChoiceMode()
214 // {
215 // if (choiceMode == null)
216 // {
217 // choiceMode = new JComboBox(AccessMode.values());
218 // // choiceMode.setBounds(76, 87, 78, 38);
219 // choiceMode.addItemListener(new java.awt.event.ItemListener()
220 // {
221 // public void itemStateChanged(java.awt.event.ItemEvent e)
222 // {
223 // if (accessMode != choiceMode.getSelectedItem())
224 // {
225 // accessMode = (AccessMode) choiceMode.getSelectedItem();
226 // // bean.getAcopTransport().setAccessMode(accessMode);
227 // System.out.println("setAccessMode"); // TODO Auto-generated Event
228 // // stub itemStateChanged()
229 // firePropertyChange(null, null, null);
230 // }
231 // System.out.println("itemStateChanged()"); // TODO Auto-generated Event
232 // // stub itemStateChanged()
233 // }
234 // });
235 // // for (int i=0; i<accessModeString.length; i++) choiceMode.setName(
236 // // accessModeString[i] );
237 // }
238 // return choiceMode;
239 // }
240 /**
241 * This method initializes label1
242 *
243 * @return java.awt.Label
244 */
245 private JLabel getLabel1()
246 {
247 if (label1 == null)
248 {
249 label1 = new JLabel();
250 // label1.setBounds(22, 60, 34, 22);
251 label1.setText("Rate:");
252 label1.setName("Rate");
253 }
254 return label1;
255 }
256 /**
257 * This method initializes textFieldRate
258 *
259 * @return java.awt.TextField
260 */
261 // private JTextField getTextFieldRate()
262 // {
263 // if (textFieldRate == null)
264 // {
265 // textFieldRate = new JTextField();
266 // // textFieldRate.setBounds(77, 61, 70, 19);
267 // textFieldRate.setName("RateText");
268 // System.out.println(" textFieldRate.setName (RateText) "); // TODO
269 // // Auto-generated
270 // // Event
271 // // stub
272 // // textValueChanged()
273 // textFieldRate.addPropertyChangeListener(new PropertyChangeListener()
274 // {
275 // public void propertyChange(PropertyChangeEvent evt)
276 // {
277 // accessRate = textFieldRate.getText();
278 // System.out.println(" textValueChanged(): " + accessRate); // TODO
279 // // Auto-generated
280 // // Event
281 // // stub
282 // // textValueChanged()
283 // if (accessRateOld != accessRate && bean != null)
284 // {
285 // // bean.getAcopTransport().setAccessRate(accessRate);
286 // accessRateOld = accessRate;
287 // System.out.println("try setAccessRate"); // TODO Auto-generated
288 // // Event stub
289 // // itemStateChanged()
290 // firePropertyChange(null, null, null);
291 // }
292 // }
293 // });
294 // }
295 // return textFieldRate;
296 // }
297 public static void main(String[] args)
298 {
299 try
300 {
301 JFrame f = new JFrame();
302 AcopCustomizer c = new AcopCustomizer();
303 f.setContentPane(c);
304 Acop a = new Acop();
305 c.setObject(a);
306 f.setVisible(true);
307 }
308 catch (Exception e)
309 {
310 e.printStackTrace();
311 }
312 }
313 } // @jve:decl-index=0:visual-constraint="7,1"