001: package vicazh.hyperpool.stream.net.http.html;
002:
003: import javax.swing.*;
004: import org.jfree.report.event.*;
005: import java.awt.*;
006: import java.awt.event.*;
007: import java.beans.*;
008: import java.util.logging.*;
009: import vicazh.hyperpool.Start;
010: import vicazh.hyperpool.stream.*;
011:
012: /**
013: * The graphic antivirus service
014: *
015: * @author Victor Zhigunov
016: * @version 0.4.0
017: */
018: public class IAntivirusService extends IReportService implements
019: AntivirusServiceMBean, ActionListener, PropertyChangeListener {
020: private JDialog dialog;
021:
022: private JOptionPane optionPane;
023:
024: private JTextField textDir;
025:
026: private JFormattedTextField textDate;
027:
028: private JTextField textDelimiter;
029:
030: private JTextField textServer;
031:
032: private JFormattedTextField textPort;
033:
034: private JFormattedTextField textBuffer;
035:
036: private DefaultComboBoxModel themeModel;
037:
038: /**
039: * @param name
040: * service name
041: * @param buttonClear
042: * clear button
043: * @param dialogClear
044: * clear dialog
045: * @param buttonStart
046: * start date range button
047: * @param buttonEnd
048: * end date range button
049: * @param box
050: * time period value combo box
051: * @param dialogDate
052: * date select dialog
053: * @param b1
054: * period radio button
055: * @param b2
056: * range radio button
057: * @param buttonCreate
058: * create button
059: * @param buttonPrint
060: * print button
061: * @param buttonExport
062: * export button
063: * @param names
064: * columns names
065: * @param container
066: * report container
067: * @param model
068: * type model
069: * @param boxzoom
070: * zoom combo box
071: * @param boxpage
072: * page combo box
073: * @param listener
074: * repagination listener
075: * @param component
076: * repagination component
077: * @param chooser
078: * file chooser
079: * @param parent
080: * parent component
081: * @param dialogReplace
082: * replace dialog
083: * @param reportModel
084: * report model
085: * @param dialog
086: * options dialog
087: * @param textDir
088: * directory value field
089: * @param textDate
090: * date value field
091: * @param textDelimiter
092: * delimiter value field
093: * @param textServer
094: * ClamAV server value field
095: * @param textPort
096: * ClamAV port value field
097: * @param textBuffer
098: * buffer size value field
099: * @param themeModel
100: * theme model
101: */
102: public IAntivirusService(String name, JButton buttonClear,
103: JDialog dialogClear, JButton buttonStart,
104: JButton buttonEnd, JComboBox box, JDialog dialogDate,
105: AbstractButton b1, AbstractButton b2, JButton buttonCreate,
106: JButton buttonPrint, JButton buttonExport, Object[] names,
107: Container container, DefaultComboBoxModel model,
108: JComboBox boxzoom, JComboBox boxpage,
109: RepaginationListener listener, Component component,
110: JFileChooser chooser, Component parent,
111: JDialog dialogReplace, IReportModel reportModel,
112: JDialog dialog, JTextField textDir,
113: JFormattedTextField textDate, JTextField textDelimiter,
114: JTextField textServer, JFormattedTextField textPort,
115: JFormattedTextField textBuffer,
116: DefaultComboBoxModel themeModel) {
117: super (AntivirusServiceMBean.class, name, buttonClear,
118: dialogClear, buttonStart, buttonEnd, box, dialogDate,
119: b1, b2, buttonCreate, buttonPrint, buttonExport, names,
120: container, model, boxzoom, boxpage, listener,
121: component, chooser, parent, dialogReplace, reportModel);
122: this .dialog = dialog;
123: optionPane = (JOptionPane) dialog.getContentPane();
124: optionPane.addPropertyChangeListener(this );
125: this .textDir = textDir;
126: this .textDate = textDate;
127: this .textDelimiter = textDelimiter;
128: this .textServer = textServer;
129: this .textPort = textPort;
130: this .textBuffer = textBuffer;
131: this .themeModel = themeModel;
132: updateUI();
133: }
134:
135: public void actionPerformed(ActionEvent e) {
136: dialog.setLocationRelativeTo(dialog.getOwner());
137: dialog.setVisible(true);
138: Object value = optionPane.getValue();
139: if (value == JOptionPane.UNINITIALIZED_VALUE)
140: return;
141: optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
142: if (((Integer) value).intValue() != JOptionPane.OK_OPTION)
143: return;
144: AntivirusService s = new AntivirusService();
145: s.setDir(textDir.getText());
146: s.setDate((Integer) textDate.getValue());
147: s.setDelimiter(textDelimiter.getText());
148: s.setHost(textServer.getText());
149: s.setPort((Integer) textPort.getValue());
150: s.setBuffer((Integer) textBuffer.getValue());
151: IMessageTheme t = (IMessageTheme) themeModel.getSelectedItem();
152: s.setTheme(t.theme);
153: s.setUrl(t.transformer);
154: try {
155: setAttribute(FileServiceMBean.OPTIONS, s);
156: } catch (Exception ex) {
157: Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
158: }
159: }
160:
161: public void updateUI() {
162: SwingUtilities.updateComponentTreeUI(dialog);
163: super .updateUI();
164: }
165:
166: protected void otherNotification(String type, Object value) {
167: if (type.equals(FileServiceMBean.OPTIONS)) {
168: textDir.setText(((FileService) value).getDir());
169: textDate.setValue(((ReportService) value).getDate());
170: textDelimiter.setText(((ReportService) value)
171: .getDelimiter());
172: textServer.setText(((AntivirusService) value).getHost());
173: textPort.setValue(((AntivirusService) value).getPort());
174: textBuffer.setValue(((AntivirusService) value).getBuffer());
175: for (int i = 0; i < themeModel.getSize(); i++) {
176: Object o = themeModel.getElementAt(i);
177: if (((IMessageTheme) o).theme
178: .equals(((AntivirusService) value).getTheme())) {
179: themeModel.setSelectedItem(o);
180: break;
181: }
182: }
183: }
184: super.otherNotification(type, value);
185: }
186: }
|