01: package vicazh.hyperpool.stream;
02:
03: import javax.swing.*;
04: import javax.swing.event.*;
05: import java.awt.event.*;
06: import java.util.logging.*;
07: import vicazh.hyperpool.*;
08: import vicazh.hyperpool.Start;
09:
10: /**
11: * The graphic dial service
12: *
13: * @author Victor Zhigunov
14: * @version 0.4.0
15: */
16: public class IDialService extends IService implements DialServiceMBean,
17: ActionListener, DocumentListener {
18:
19: private JTextField textCommand;
20:
21: private JButton buttonOK;
22:
23: /**
24: * @param name
25: * service name
26: * @param textCommand
27: * command text field
28: * @param buttonOK
29: * OK button
30: */
31: public IDialService(String name, JTextField textCommand,
32: JButton buttonOK) {
33: super (DialServiceMBean.class, name);
34: textCommand.getDocument().addDocumentListener(this );
35: this .textCommand = textCommand;
36: buttonOK.setEnabled(false);
37: buttonOK.addActionListener(this );
38: this .buttonOK = buttonOK;
39: }
40:
41: public void actionPerformed(ActionEvent e) {
42: buttonOK.setEnabled(false);
43: try {
44: setAttribute(DialServiceMBean.COMMAND, textCommand
45: .getText());
46: } catch (Exception ex) {
47: Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
48: }
49: }
50:
51: public void insertUpdate(DocumentEvent e) {
52: update();
53: }
54:
55: public void removeUpdate(DocumentEvent e) {
56: update();
57: }
58:
59: public void changedUpdate(DocumentEvent e) {
60: update();
61: }
62:
63: private void update() {
64: buttonOK.setEnabled(true);
65: }
66:
67: protected void otherNotification(String type, Object value) {
68: textCommand.setText((String) value);
69: }
70: }
|