01: package vicazh.hyperpool.stream;
02:
03: import javax.swing.*;
04: import vicazh.hyperpool.Start;
05: import java.awt.event.*;
06: import java.util.logging.*;
07:
08: /**
09: * The graphic record service
10: *
11: * @author Victor Zhigunov
12: * @version 0.4.0
13: */
14: public class IRecordService extends IFileService implements
15: RecordServiceMBean, ActionListener {
16: private JFormattedTextField textView;
17:
18: private JDialog dialog;
19:
20: private JOptionPane optionPane;
21:
22: private JTextField textDir;
23:
24: private JFormattedTextField textSize;
25:
26: /**
27: * @param name
28: * service name
29: * @param buttonClear
30: * clear button
31: * @param dialogClear
32: * clear dialog
33: * @param textView
34: * view size text field
35: * @param dialog
36: * options dialog
37: * @param textDir
38: * directory value field
39: * @param textSize
40: * set size text field
41: */
42: public IRecordService(String name, JButton buttonClear,
43: JDialog dialogClear, JFormattedTextField textView,
44: JDialog dialog, JTextField textDir,
45: JFormattedTextField textSize) {
46: super (RecordServiceMBean.class, name, buttonClear, dialogClear);
47: this .textView = textView;
48: this .dialog = dialog;
49: optionPane = (JOptionPane) dialog.getContentPane();
50: optionPane.addPropertyChangeListener(this );
51: this .textDir = textDir;
52: this .textSize = textSize;
53: updateUI();
54: }
55:
56: public void actionPerformed(ActionEvent e) {
57: dialog.setLocationRelativeTo(dialog.getOwner());
58: dialog.setVisible(true);
59: Object value = optionPane.getValue();
60: if (value == JOptionPane.UNINITIALIZED_VALUE)
61: return;
62: optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
63: if (((Integer) value).intValue() != JOptionPane.OK_OPTION)
64: return;
65: RecordService s = new RecordService();
66: s.setDir(textDir.getText());
67: s.setSize((Long) textSize.getValue());
68: try {
69: setAttribute(FileServiceMBean.OPTIONS, s);
70: } catch (Exception ex) {
71: Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
72: }
73: }
74:
75: public void updateUI() {
76: SwingUtilities.updateComponentTreeUI(dialog);
77: super .updateUI();
78: }
79:
80: protected void set(FileData data) {
81: textView.setValue(new Long(
82: (long) ((RecordData) data).receive / 1048576));
83: super .set(data);
84: }
85:
86: protected void otherNotification(String type, Object value) {
87: if (type.equals(FileServiceMBean.OPTIONS)) {
88: textDir.setText(((FileService) value).getDir());
89: textSize.setValue(((RecordService) value).getSize());
90: }
91: super.otherNotification(type, value);
92: }
93: }
|