01: package vicazh.hyperpool.stream.net.http;
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 set route service
12: *
13: * @author Victor Zhigunov
14: * @version 0.4.0
15: */
16: public class ISetRouteService extends IService implements
17: SetRouteServiceMBean, ActionListener, DocumentListener {
18: private JTextField textAddress;
19:
20: private JButton buttonOK;
21:
22: /**
23: * @param name
24: * service name
25: * @param textAddress
26: * address text field
27: * @param buttonOK
28: * OK button
29: */
30: public ISetRouteService(String name, JTextField textAddress,
31: JButton buttonOK) {
32: super (SetRouteServiceMBean.class, name);
33: textAddress.getDocument().addDocumentListener(this );
34: this .textAddress = textAddress;
35: buttonOK.setEnabled(false);
36: buttonOK.addActionListener(this );
37: this .buttonOK = buttonOK;
38: }
39:
40: public void actionPerformed(ActionEvent e) {
41: buttonOK.setEnabled(false);
42: try {
43: setAttribute(SetRouteServiceMBean.PATH, textAddress
44: .getText());
45: } catch (Exception ex) {
46: Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
47: }
48: }
49:
50: public void insertUpdate(DocumentEvent e) {
51: update();
52: }
53:
54: public void removeUpdate(DocumentEvent e) {
55: update();
56: }
57:
58: public void changedUpdate(DocumentEvent e) {
59: update();
60: }
61:
62: private void update() {
63: buttonOK.setEnabled(true);
64: }
65:
66: protected void otherNotification(String type, Object value) {
67: textAddress.setText((String) value);
68: }
69: }
|