001: package vicazh.hyperpool.stream.net.http;
002:
003: import javax.swing.*;
004: import org.jfree.report.event.*;
005: import vicazh.hyperpool.Start;
006: import vicazh.hyperpool.stream.*;
007: import java.awt.*;
008: import java.awt.event.*;
009: import java.util.logging.*;
010:
011: /**
012: * The graphic log service
013: *
014: * @author Victor Zhigunov
015: * @version 0.4.0
016: */
017: public class ILogService extends IReportService implements
018: LogServiceMBean, ActionListener {
019: private JDialog dialog;
020:
021: private JOptionPane optionPane;
022:
023: private JTextField textDir;
024:
025: private JFormattedTextField textDate;
026:
027: private JTextField textDelimiter;
028:
029: /**
030: * @param name
031: * service name
032: * @param buttonClear
033: * clear button
034: * @param dialogClear
035: * clear dialog
036: * @param buttonStart
037: * start date range button
038: * @param buttonEnd
039: * end date range button
040: * @param box
041: * time period value combo box
042: * @param dialogDate
043: * date select dialog
044: * @param b1
045: * period radio button
046: * @param b2
047: * range radio button
048: * @param buttonCreate
049: * create button
050: * @param buttonPrint
051: * print button
052: * @param buttonExport
053: * export button
054: * @param names
055: * columns names
056: * @param container
057: * report container
058: * @param model
059: * type model
060: * @param boxzoom
061: * zoom combo box
062: * @param boxpage
063: * page combo box
064: * @param listener
065: * repagination listener
066: * @param component
067: * repagination component
068: * @param chooser
069: * file chooser
070: * @param parent
071: * parent component
072: * @param dialogReplace
073: * replace dialog
074: * @param reportModel
075: * report model
076: * @param dialog
077: * options dialog
078: * @param textDir
079: * directory value field
080: * @param textDate
081: * date value field
082: * @param textDelimiter
083: * delimiter value field
084: */
085: public ILogService(String name, JButton buttonClear,
086: JDialog dialogClear, JButton buttonStart,
087: JButton buttonEnd, JComboBox box, JDialog dialogDate,
088: AbstractButton b1, AbstractButton b2, JButton buttonCreate,
089: JButton buttonPrint, JButton buttonExport, Object[] names,
090: Container container, DefaultComboBoxModel model,
091: JComboBox boxzoom, JComboBox boxpage,
092: RepaginationListener listener, Component component,
093: JFileChooser chooser, Component parent,
094: JDialog dialogReplace, IReportModel reportModel,
095: JDialog dialog, JTextField textDir,
096: JFormattedTextField textDate, JTextField textDelimiter) {
097: super (LogServiceMBean.class, name, buttonClear, dialogClear,
098: buttonStart, buttonEnd, box, dialogDate, b1, b2,
099: buttonCreate, buttonPrint, buttonExport, names,
100: container, model, boxzoom, boxpage, listener,
101: component, chooser, parent, dialogReplace, reportModel);
102: this .dialog = dialog;
103: optionPane = (JOptionPane) dialog.getContentPane();
104: optionPane.addPropertyChangeListener(this );
105: this .textDir = textDir;
106: this .textDate = textDate;
107: this .textDelimiter = textDelimiter;
108: updateUI();
109: }
110:
111: public void actionPerformed(ActionEvent e) {
112: dialog.setLocationRelativeTo(dialog.getOwner());
113: dialog.setVisible(true);
114: Object value = optionPane.getValue();
115: if (value == JOptionPane.UNINITIALIZED_VALUE)
116: return;
117: optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
118: if (((Integer) value).intValue() != JOptionPane.OK_OPTION)
119: return;
120: LogService s = new LogService();
121: s.setDir(textDir.getText());
122: s.setDate((Integer) textDate.getValue());
123: s.setDelimiter(textDelimiter.getText());
124: try {
125: setAttribute(FileServiceMBean.OPTIONS, s);
126: } catch (Exception ex) {
127: Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
128: }
129: }
130:
131: public void updateUI() {
132: SwingUtilities.updateComponentTreeUI(dialog);
133: super .updateUI();
134: }
135:
136: protected void otherNotification(String type, Object value) {
137: if (type.equals(FileServiceMBean.OPTIONS)) {
138: textDir.setText(((FileService) value).getDir());
139: textDate.setValue(((ReportService) value).getDate());
140: textDelimiter.setText(((ReportService) value)
141: .getDelimiter());
142: }
143: super.otherNotification(type, value);
144: }
145: }
|