View Javadoc

1   package org.lsst.ccs.plugin.jas3.console;
2   
3   import java.util.regex.Pattern;
4   
5   /**
6    * A graphical panel for controlling a RegularExpressionFilter.
7    * @author tonyj
8    */
9   class RegularExpressionMessageFilterPanel extends javax.swing.JPanel {
10      private final RegularExpressionMessageFilter filter;
11  
12      /**
13       * Creates new form RegularExpressionMessageFilterPanel
14       */
15      RegularExpressionMessageFilterPanel(RegularExpressionMessageFilter filter) {
16          this.filter = filter;
17          initComponents();
18      }
19  
20      void apply() {
21          filter.setVeto(vetoTextField.getText().isEmpty() ? null : Pattern.compile(vetoTextField.getText()));
22          filter.setAccept(acceptTextField.getText().isEmpty() ? null : Pattern.compile(acceptTextField.getText()));
23      }
24      
25      /**
26       * This method is called from within the constructor to initialize the form.
27       * WARNING: Do NOT modify this code. The content of this method is always
28       * regenerated by the Form Editor.
29       */
30      @SuppressWarnings("unchecked")
31      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
32      private void initComponents() {
33  
34          javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
35          javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
36          vetoTextField = new javax.swing.JTextField();
37          javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
38          acceptTextField = new javax.swing.JTextField();
39  
40          jLabel1.setText("<html>Some text explaining how to use this filter");
41  
42          jLabel2.setText("Veto:");
43  
44          vetoTextField.setText(filter.getVeto() == null ? "" : filter.getVeto().toString());
45  
46          jLabel3.setText("Accept:");
47  
48          acceptTextField.setText(filter.getAccept() == null ? "" : filter.getAccept().toString());
49  
50          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
51          this.setLayout(layout);
52          layout.setHorizontalGroup(
53              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
54              .addGroup(layout.createSequentialGroup()
55                  .addContainerGap()
56                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
57                      .addGroup(layout.createSequentialGroup()
58                          .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
59                          .addGap(0, 63, Short.MAX_VALUE))
60                      .addGroup(layout.createSequentialGroup()
61                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
62                              .addComponent(jLabel3)
63                              .addComponent(jLabel2))
64                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
65                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
66                              .addComponent(vetoTextField)
67                              .addComponent(acceptTextField))))
68                  .addContainerGap())
69          );
70          layout.setVerticalGroup(
71              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
72              .addGroup(layout.createSequentialGroup()
73                  .addContainerGap()
74                  .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
75                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
76                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
77                      .addComponent(jLabel2)
78                      .addComponent(vetoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
79                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
80                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
81                      .addComponent(jLabel3)
82                      .addComponent(acceptTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
83                  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
84          );
85      }// </editor-fold>//GEN-END:initComponents
86  
87      // Variables declaration - do not modify//GEN-BEGIN:variables
88      private javax.swing.JTextField acceptTextField;
89      private javax.swing.JTextField vetoTextField;
90      // End of variables declaration//GEN-END:variables
91  
92  
93  }