Ignore:
Timestamp:
2003-05-27T15:57:37+12:00 (21 years ago)
Author:
kjdon
Message:

re-tabbed the code for java

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/AutofilterDialog.java

    r4293 r4366  
    4949 */
    5050public final class AutofilterDialog
    51     extends JDialog {
    52     /** The filter being edited. */
    53     private Autofilter filter;
    54     /** A reference to ourselves so our inner classes can reference us. */
    55     private AutofilterDialog self;
    56     /** The value returned from the filter dialog prompt. Used to determine if a prompt was set or unset, and what subsequent action to take. */
    57     private byte return_value = 0;
    58     /** The button used to cancel the prompt. */
    59     private JButton cancel_button = null;
    60     /** The button used to accept and commit any changes to the autofilter. */
    61     private JButton ok_button = null;
    62     /** A check box used to specify that the given filters should be applied conjunctly. */
    63     private JCheckBox and_check = null;
    64     /** The check box used to specify whether the first filter is case sensitive. */
    65     private JCheckBox first_case = null;
    66     /** The none check is used to disable the second filter. */
    67     private JCheckBox none_check = null;
    68     /** The check box used to specify that the given filters should be applied disjunctly. */
    69     private JCheckBox or_check = null;
    70     /** The check box used to specify whether the second filter is case sensitive. */
    71     private JCheckBox second_case = null;
    72     /** Used to specify the order of the resulting set: Ascending or Descending. */
    73     private JComboBox order = null;
    74     /** The method used to match the first filter: Contains, Doesn't contain etc. */
    75     private JComboBox first_method = null;
    76     /** The value to be matched for the first filter. */
    77     private JComboBox first_value = null;
    78     /** The method used to match the first filter. Options as for the first method. */
    79     private JComboBox second_method = null;
    80     /** The value to be matched for the second filter. */
    81     private JComboBox second_value = null;
    82     /** Used for the most basic filter where an Equals, Case sensitive method is automatically used. */
    83     private JComboBox value = null;
    84     /** The label which displays the name of the currently selected column (the column that will be associated with the autofilter this dialog produces). */
    85     private JLabel name;
    86     /** The autofilter prompt contains two different panes, one for basic functionality and one for advanced. This containiner component is used to allow access to each via a 'tabbed' interface. */
    87     private JTabbedPane control = null;
    88     /** A reference back to the MetaAudit dialog that spawned this prompt. Used to make sure that any open dialog window is always in front of the audit pane. */
    89     private MetaAuditFrame dialog;
    90     /** The default size for the autofilter control. */
    91     static final private Dimension SIZE = new Dimension(640, 220);
    92     /** Constructor.
    93       * @param dialog A reference to the <strong>MetaAuditFrame</strong> that spawned this dialog.
    94       * @see org.greenstone.gatherer.gui.metaaudit.Autofilter
    95       * @see org.greenstone.gatherer.gui.metaaudit.AutofilterDialog.ButtonListener
    96       * @see org.greenstone.gatherer.gui.metaaudit.AutofilterDialog.CheckListener
    97       */
    98     public AutofilterDialog(MetaAuditFrame dialog) {
    99           super(Gatherer.g_man);
    100           this.dialog = dialog;
    101           this.self = this;
    102           setModal(true);
    103           setSize(SIZE);
    104           setTitle(get("Title"));
    105           // Creation
    106           JPanel content_pane = (JPanel) getContentPane();
    107           JPanel name_pane = new JPanel();
    108           JLabel name_label = new JLabel(get("Name"));
    109           JTextField name_template = new JTextField();
    110           name = new JLabel();
    111           name.setBorder(name_template.getBorder());
    112           control = new JTabbedPane();
    113           JPanel value_pane = new JPanel();
    114           JPanel inner_value_pane = new JPanel();
    115           JLabel value_label = new JLabel(get("eqeq"));
    116           value = new JComboBox();
    117           value.setEditable(false);
    118           JPanel custom_pane = new JPanel();
    119           JPanel first_pane = new JPanel();
    120           first_method = new JComboBox();
    121           first_value = new JComboBox();
    122           first_value.setEditable(true);
    123           first_value.addItem("");
    124           first_value.setSelectedItem("");
    125           first_case = new JCheckBox(get("Case_Sensitive"));
    126           JPanel operator_pane = new JPanel();
    127           JLabel operator_label = new JLabel(get("Operator"));
    128           ButtonGroup operator_group = new ButtonGroup();
    129           and_check = new JCheckBox(get("AND"));
    130           none_check = new JCheckBox(get("None"));
    131           or_check = new JCheckBox(get("OR"));
    132           none_check.setSelected(true);
    133           operator_group.add(none_check);
    134           operator_group.add(and_check);
    135           operator_group.add(or_check);
    136           JPanel second_pane = new JPanel();
    137           second_method = new JComboBox();
    138           second_method.setEnabled(false);
    139           second_value = new JComboBox();
    140           second_value.setEditable(true);
    141           second_value.setEnabled(false);
    142           second_value.addItem("");
    143           second_value.setSelectedItem("");
    144           second_case = new JCheckBox(get("Case_Sensitive"));
    145           JPanel lower_pane = new JPanel();
    146           JPanel order_pane = new JPanel();
    147           JLabel order_label = new JLabel(get("Order"));
    148           order = new JComboBox();
    149           order.addItem(get("Ascending"));
    150           order.addItem(get("Descending"));
    151           // Assign values to method comboboxes.
    152           for(int i = 0; i < Autofilter.METHOD_LIST.length; i++) {
    153                 first_method.addItem(get(Autofilter.METHOD_LIST[i]));
    154                 second_method.addItem(get(Autofilter.METHOD_LIST[i]));
    155           }
    156           JPanel button_pane = new JPanel();
    157           cancel_button = new JButton(get("Clear"));
    158           cancel_button.setMnemonic(KeyEvent.VK_C);
    159           ok_button = new JButton(get("Set"));
    160           ok_button.setMnemonic(KeyEvent.VK_S);
    161           // Connection
    162           and_check.addActionListener(new CheckListener(true));
    163           cancel_button.addActionListener(new ButtonListener(false));
    164           none_check.addActionListener(new CheckListener(false));
    165           ok_button.addActionListener(new ButtonListener(true));
    166           or_check.addActionListener(new CheckListener(true));
    167           // Layout       
    168           name_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5));
    169 
    170           name_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
    171           name_pane.setLayout(new BorderLayout());
    172           name_pane.add(name_label, BorderLayout.WEST);
    173           name_pane.add(name, BorderLayout.CENTER);
    174 
    175           value_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5));
    176 
    177           inner_value_pane.setLayout(new BorderLayout());
    178           inner_value_pane.add(value_label, BorderLayout.WEST);
    179           inner_value_pane.add(value, BorderLayout.CENTER);
    180 
    181           value_pane.setBorder(BorderFactory.createEmptyBorder(5,10,5,10));
    182           value_pane.setLayout(new BorderLayout());
    183           value_pane.add(inner_value_pane, BorderLayout.NORTH);
    184 
    185           first_pane.setLayout(new BorderLayout());
    186           first_pane.add(first_method, BorderLayout.WEST);
    187           first_pane.add(first_value, BorderLayout.CENTER);
    188           first_pane.add(first_case, BorderLayout.EAST);
    189 
    190           operator_pane.setLayout(new GridLayout(1,4));
    191           operator_pane.add(operator_label);
    192           operator_pane.add(none_check);
    193           operator_pane.add(and_check);
    194           operator_pane.add(or_check);
    195 
    196           second_pane.setLayout(new BorderLayout());
    197           second_pane.add(second_method, BorderLayout.WEST);
    198           second_pane.add(second_value, BorderLayout.CENTER);
    199           second_pane.add(second_case, BorderLayout.EAST);
    200 
    201           order_pane.setLayout(new GridLayout(1,2));
    202           order_pane.add(order_label);
    203           order_pane.add(order);
    204 
    205           custom_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
    206           custom_pane.setLayout(new GridLayout(3,1));
    207           custom_pane.add(first_pane);
    208           custom_pane.add(operator_pane);
    209           custom_pane.add(second_pane);
     51    extends JDialog {
     52    /** The filter being edited. */
     53    private Autofilter filter;
     54    /** A reference to ourselves so our inner classes can reference us. */
     55    private AutofilterDialog self;
     56    /** The value returned from the filter dialog prompt. Used to determine if a prompt was set or unset, and what subsequent action to take. */
     57    private byte return_value = 0;
     58    /** The button used to cancel the prompt. */
     59    private JButton cancel_button = null;
     60    /** The button used to accept and commit any changes to the autofilter. */
     61    private JButton ok_button = null;
     62    /** A check box used to specify that the given filters should be applied conjunctly. */
     63    private JCheckBox and_check = null;
     64    /** The check box used to specify whether the first filter is case sensitive. */
     65    private JCheckBox first_case = null;
     66    /** The none check is used to disable the second filter. */
     67    private JCheckBox none_check = null;
     68    /** The check box used to specify that the given filters should be applied disjunctly. */
     69    private JCheckBox or_check = null;
     70    /** The check box used to specify whether the second filter is case sensitive. */
     71    private JCheckBox second_case = null;
     72    /** Used to specify the order of the resulting set: Ascending or Descending. */
     73    private JComboBox order = null;
     74    /** The method used to match the first filter: Contains, Doesn't contain etc. */
     75    private JComboBox first_method = null;
     76    /** The value to be matched for the first filter. */
     77    private JComboBox first_value = null;
     78    /** The method used to match the first filter. Options as for the first method. */
     79    private JComboBox second_method = null;
     80    /** The value to be matched for the second filter. */
     81    private JComboBox second_value = null;
     82    /** Used for the most basic filter where an Equals, Case sensitive method is automatically used. */
     83    private JComboBox value = null;
     84    /** The label which displays the name of the currently selected column (the column that will be associated with the autofilter this dialog produces). */
     85    private JLabel name;
     86    /** The autofilter prompt contains two different panes, one for basic functionality and one for advanced. This containiner component is used to allow access to each via a 'tabbed' interface. */
     87    private JTabbedPane control = null;
     88    /** A reference back to the MetaAudit dialog that spawned this prompt. Used to make sure that any open dialog window is always in front of the audit pane. */
     89    private MetaAuditFrame dialog;
     90    /** The default size for the autofilter control. */
     91    static final private Dimension SIZE = new Dimension(640, 220);
     92    /** Constructor.
     93     * @param dialog A reference to the <strong>MetaAuditFrame</strong> that spawned this dialog.
     94     * @see org.greenstone.gatherer.gui.metaaudit.Autofilter
     95     * @see org.greenstone.gatherer.gui.metaaudit.AutofilterDialog.ButtonListener
     96     * @see org.greenstone.gatherer.gui.metaaudit.AutofilterDialog.CheckListener
     97     */
     98    public AutofilterDialog(MetaAuditFrame dialog) {
     99    super(Gatherer.g_man);
     100    this.dialog = dialog;
     101    this.self = this;
     102    setModal(true);
     103    setSize(SIZE);
     104    setTitle(get("Title"));
     105    // Creation
     106    JPanel content_pane = (JPanel) getContentPane();
     107    JPanel name_pane = new JPanel();
     108    JLabel name_label = new JLabel(get("Name"));
     109    JTextField name_template = new JTextField();
     110    name = new JLabel();
     111    name.setBorder(name_template.getBorder());
     112    control = new JTabbedPane();
     113    JPanel value_pane = new JPanel();
     114    JPanel inner_value_pane = new JPanel();
     115    JLabel value_label = new JLabel(get("eqeq"));
     116    value = new JComboBox();
     117    value.setEditable(false);
     118    JPanel custom_pane = new JPanel();
     119    JPanel first_pane = new JPanel();
     120    first_method = new JComboBox();
     121    first_value = new JComboBox();
     122    first_value.setEditable(true);
     123    first_value.addItem("");
     124    first_value.setSelectedItem("");
     125    first_case = new JCheckBox(get("Case_Sensitive"));
     126    JPanel operator_pane = new JPanel();
     127    JLabel operator_label = new JLabel(get("Operator"));
     128    ButtonGroup operator_group = new ButtonGroup();
     129    and_check = new JCheckBox(get("AND"));
     130    none_check = new JCheckBox(get("None"));
     131    or_check = new JCheckBox(get("OR"));
     132    none_check.setSelected(true);
     133    operator_group.add(none_check);
     134    operator_group.add(and_check);
     135    operator_group.add(or_check);
     136    JPanel second_pane = new JPanel();
     137    second_method = new JComboBox();
     138    second_method.setEnabled(false);
     139    second_value = new JComboBox();
     140    second_value.setEditable(true);
     141    second_value.setEnabled(false);
     142    second_value.addItem("");
     143    second_value.setSelectedItem("");
     144    second_case = new JCheckBox(get("Case_Sensitive"));
     145    JPanel lower_pane = new JPanel();
     146    JPanel order_pane = new JPanel();
     147    JLabel order_label = new JLabel(get("Order"));
     148    order = new JComboBox();
     149    order.addItem(get("Ascending"));
     150    order.addItem(get("Descending"));
     151    // Assign values to method comboboxes.
     152    for(int i = 0; i < Autofilter.METHOD_LIST.length; i++) {
     153        first_method.addItem(get(Autofilter.METHOD_LIST[i]));
     154        second_method.addItem(get(Autofilter.METHOD_LIST[i]));
     155    }
     156    JPanel button_pane = new JPanel();
     157    cancel_button = new JButton(get("Clear"));
     158    cancel_button.setMnemonic(KeyEvent.VK_C);
     159    ok_button = new JButton(get("Set"));
     160    ok_button.setMnemonic(KeyEvent.VK_S);
     161    // Connection
     162    and_check.addActionListener(new CheckListener(true));
     163    cancel_button.addActionListener(new ButtonListener(false));
     164    none_check.addActionListener(new CheckListener(false));
     165    ok_button.addActionListener(new ButtonListener(true));
     166    or_check.addActionListener(new CheckListener(true));
     167    // Layout         
     168    name_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5));
     169
     170    name_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     171    name_pane.setLayout(new BorderLayout());
     172    name_pane.add(name_label, BorderLayout.WEST);
     173    name_pane.add(name, BorderLayout.CENTER);
     174
     175    value_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5));
     176
     177    inner_value_pane.setLayout(new BorderLayout());
     178    inner_value_pane.add(value_label, BorderLayout.WEST);
     179    inner_value_pane.add(value, BorderLayout.CENTER);
     180
     181    value_pane.setBorder(BorderFactory.createEmptyBorder(5,10,5,10));
     182    value_pane.setLayout(new BorderLayout());
     183    value_pane.add(inner_value_pane, BorderLayout.NORTH);
     184
     185    first_pane.setLayout(new BorderLayout());
     186    first_pane.add(first_method, BorderLayout.WEST);
     187    first_pane.add(first_value, BorderLayout.CENTER);
     188    first_pane.add(first_case, BorderLayout.EAST);
     189
     190    operator_pane.setLayout(new GridLayout(1,4));
     191    operator_pane.add(operator_label);
     192    operator_pane.add(none_check);
     193    operator_pane.add(and_check);
     194    operator_pane.add(or_check);
     195
     196    second_pane.setLayout(new BorderLayout());
     197    second_pane.add(second_method, BorderLayout.WEST);
     198    second_pane.add(second_value, BorderLayout.CENTER);
     199    second_pane.add(second_case, BorderLayout.EAST);
     200
     201    order_pane.setLayout(new GridLayout(1,2));
     202    order_pane.add(order_label);
     203    order_pane.add(order);
     204
     205    custom_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
     206    custom_pane.setLayout(new GridLayout(3,1));
     207    custom_pane.add(first_pane);
     208    custom_pane.add(operator_pane);
     209    custom_pane.add(second_pane);
    210210         
    211           control.add(get("Filter_By_Value"), value_pane);
    212           control.add(get("Custom_Filter"), custom_pane);
    213 
    214           button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
    215           button_pane.setLayout(new GridLayout(1,2));
    216           button_pane.add(ok_button);
    217           button_pane.add(cancel_button);
    218 
    219           lower_pane.setLayout(new BorderLayout());
    220           lower_pane.add(order_pane, BorderLayout.CENTER);
    221           lower_pane.add(button_pane, BorderLayout.SOUTH);
    222 
    223           content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    224           content_pane.setLayout(new BorderLayout());
    225           content_pane.add(name_pane, BorderLayout.NORTH);
    226           content_pane.add(control, BorderLayout.CENTER);
    227           content_pane.add(lower_pane, BorderLayout.SOUTH);
    228 
    229           Dimension screen_size = Gatherer.config.screen_size;
    230           setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
    231           screen_size = null;
    232     }
    233     /** Destructor. */
    234     public void destroy() {
    235           dispose();
    236           cancel_button = null;
    237           ok_button = null;
    238           and_check = null;
    239           first_case = null;
    240           none_check = null;
    241           or_check = null;
    242           second_case = null;
    243           order = null;
    244           first_method = null;
    245           first_value = null;
    246           second_method = null;
    247           second_value = null;
    248           value = null;
    249           control = null;
    250           dialog = null;
    251           self = null;
    252           name = null;
    253     }
    254     /** Display the modal dialog box, allowing the user to define the filter. When the user presses one of the buttons, dispose and return to the caller providing an indication of which button was pressed.
     211    control.add(get("Filter_By_Value"), value_pane);
     212    control.add(get("Custom_Filter"), custom_pane);
     213
     214    button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
     215    button_pane.setLayout(new GridLayout(1,2));
     216    button_pane.add(ok_button);
     217    button_pane.add(cancel_button);
     218
     219    lower_pane.setLayout(new BorderLayout());
     220    lower_pane.add(order_pane, BorderLayout.CENTER);
     221    lower_pane.add(button_pane, BorderLayout.SOUTH);
     222
     223    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     224    content_pane.setLayout(new BorderLayout());
     225    content_pane.add(name_pane, BorderLayout.NORTH);
     226    content_pane.add(control, BorderLayout.CENTER);
     227    content_pane.add(lower_pane, BorderLayout.SOUTH);
     228
     229    Dimension screen_size = Gatherer.config.screen_size;
     230    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
     231    screen_size = null;
     232    }
     233    /** Destructor. */
     234    public void destroy() {
     235    dispose();
     236    cancel_button = null;
     237    ok_button = null;
     238    and_check = null;
     239    first_case = null;
     240    none_check = null;
     241    or_check = null;
     242    second_case = null;
     243    order = null;
     244    first_method = null;
     245    first_value = null;
     246    second_method = null;
     247    second_value = null;
     248    value = null;
     249    control = null;
     250    dialog = null;
     251    self = null;
     252    name = null;
     253    }
     254    /** Display the modal dialog box, allowing the user to define the filter. When the user presses one of the buttons, dispose and return to the caller providing an indication of which button was pressed.
    255255      * @return An <i>int</i> which indicates which button was pressed to dismiss the dialog.
    256256      */
    257     public Autofilter display(Autofilter filter, ArrayList raw_values, String column_name) {
    258           this.filter = filter;
    259           name.setText(column_name);
    260           // Prune values so it only contains unique entries, then order.
    261           TreeSet values = new TreeSet(raw_values);
    262           value.setModel(new DefaultComboBoxModel(values.toArray()));
    263           String star = "*";
    264           value.insertItemAt(star, 0);
    265           value.setSelectedItem(star);
    266           first_value.setModel(new DefaultComboBoxModel(values.toArray()));
    267           second_value.setModel(new DefaultComboBoxModel(values.toArray()));
    268           // Restore previous values.
    269           if(filter != null && filter.value_one != null) {
    270                 value.setSelectedItem(filter.value_one);
    271                 first_method.setSelectedIndex(filter.method_one);
    272                 first_value.setSelectedItem(filter.value_one);
    273                 first_case.setSelected(filter.casesense_one);
    274                 if(filter.value_two == null) {
    275                      none_check.setSelected(true);
    276                 }
    277                 else {
    278                      if(filter.operation) {
    279                           and_check.setSelected(true);
    280                      }
    281                      else {
    282                           or_check.setSelected(true);
    283                      }
    284                      second_method.setSelectedIndex(filter.method_two);
    285                      second_value.setSelectedItem(filter.value_two);
    286                      second_case.setSelected(filter.casesense_two);
    287                 }
    288                 if(filter.sort) {
    289                      order.setSelectedIndex(0);
    290                 }
    291                 else {
    292                      order.setSelectedIndex(1);
    293                 }
    294           }
    295           // Display     
    296           show();
    297           dialog.toFront();
    298           return this.filter;
    299     }
    300     /** Use the given key to retrieve a phrase from the dictionary.
     257    public Autofilter display(Autofilter filter, ArrayList raw_values, String column_name) {
     258    this.filter = filter;
     259    name.setText(column_name);
     260    // Prune values so it only contains unique entries, then order.
     261    TreeSet values = new TreeSet(raw_values);
     262    value.setModel(new DefaultComboBoxModel(values.toArray()));
     263    String star = "*";
     264    value.insertItemAt(star, 0);
     265    value.setSelectedItem(star);
     266    first_value.setModel(new DefaultComboBoxModel(values.toArray()));
     267    second_value.setModel(new DefaultComboBoxModel(values.toArray()));
     268    // Restore previous values.
     269    if(filter != null && filter.value_one != null) {
     270        value.setSelectedItem(filter.value_one);
     271        first_method.setSelectedIndex(filter.method_one);
     272        first_value.setSelectedItem(filter.value_one);
     273        first_case.setSelected(filter.casesense_one);
     274        if(filter.value_two == null) {
     275        none_check.setSelected(true);
     276        }
     277        else {
     278        if(filter.operation) {
     279            and_check.setSelected(true);
     280        }
     281        else {
     282            or_check.setSelected(true);
     283        }
     284        second_method.setSelectedIndex(filter.method_two);
     285        second_value.setSelectedItem(filter.value_two);
     286        second_case.setSelected(filter.casesense_two);
     287        }
     288        if(filter.sort) {
     289        order.setSelectedIndex(0);
     290        }
     291        else {
     292        order.setSelectedIndex(1);
     293        }
     294    }
     295    // Display   
     296    show();
     297    dialog.toFront();
     298    return this.filter;
     299    }
     300    /** Use the given key to retrieve a phrase from the dictionary.
    301301      * @param key A <strong>String</strong> which uniquely maps to an entry in the Dictionary.
    302302      * @return The <strong>String</strong> to key mapped to.
    303303      * @see org.greenstone.gatherer.Dictionary
    304304      */
    305      private final String get(String key) {
    306           if(key.indexOf(".") == -1) {
    307                 key = "Autofilter." + key;
    308           }
    309           return Gatherer.dictionary.get(key, (String[])null);
    310      }
    311      /** Listens for actions on the button it is attached to, and when notified sets the return_value and disposes of the dialog. */
    312      private final class ButtonListener
    313           implements ActionListener {
    314           private boolean return_filter;
    315           /** Does an action on this button cause a filter to be returned. */
    316           /** Constructor takes an associated return value as an argument.
    317             * @param return_filter <i>true</i> if we update then return the filter, <i>false</i> to clear existing filter.
     305    private final String get(String key) {
     306    if(key.indexOf(".") == -1) {
     307        key = "Autofilter." + key;
     308    }
     309    return Gatherer.dictionary.get(key, (String[])null);
     310    }
     311    /** Listens for actions on the button it is attached to, and when notified sets the return_value and disposes of the dialog. */
     312    private final class ButtonListener
     313    implements ActionListener {
     314    private boolean return_filter;
     315    /** Does an action on this button cause a filter to be returned. */
     316    /** Constructor takes an associated return value as an argument.
     317     * @param return_filter <i>true</i> if we update then return the filter, <i>false</i> to clear existing filter.
     318     */
     319    public ButtonListener(boolean return_filter) {
     320        this.return_filter = return_filter;
     321    }
     322    /** When any registered component is actioned apon, set the value and hide the dialog. We hide rather than dispose, because hide assures the data values will be retained.
     323     * @param event An <strong>ActionEvent</strong> containing information about the action that caused this method call.
     324     * @see org.greenstone.gatherer.gui.metaaudit.Autofilter
     325     */
     326    public void actionPerformed(ActionEvent event) {
     327        if(return_filter) {
     328        if(control.getSelectedIndex() == 0) {
     329            filter.setFilter(1, 0, (String)value.getSelectedItem(), true);
     330            filter.setFilter(2, 0, null, true);
     331        }
     332        else {
     333            filter.setFilter(1, first_method.getSelectedIndex(), (String)first_value.getSelectedItem(), first_case.isSelected());
     334            if(!none_check.isSelected()) {
     335            if(and_check.isSelected()) {
     336                filter.setOperation(Autofilter.AND);
     337            }
     338            else {
     339                filter.setOperation(Autofilter.OR);
     340            }
     341            filter.setFilter(2, second_method.getSelectedIndex(), (String)second_value.getSelectedItem(), second_case.isSelected());
     342            }
     343        }
     344        if(order.getSelectedIndex() == 0) {
     345            filter.setSort(Autofilter.ASCENDING);
     346        }
     347        else {
     348            filter.setSort(Autofilter.DESCENDING);
     349        }
     350        }
     351        else {
     352        filter = null;
     353        }
     354        hide();
     355    }
     356    }
     357    /** Listens for actions on the check box it is attached to, and when notified sets the state of the second method and value to the specified state. */
     358    private final class CheckListener
     359    implements ActionListener {
     360    /** The default desire state any check button this listens to. */
     361    private boolean desired_state = false;
     362    /** The constructor takes an associated desired state.
     363     * @param desired_state The state that should be set when this is actioned, as a <i>boolean</i>.
    318364            */
    319           public ButtonListener(boolean return_filter) {
    320                 this.return_filter = return_filter;
    321           }
    322           /** When any registered component is actioned apon, set the value and hide the dialog. We hide rather than dispose, because hide assures the data values will be retained.
    323             * @param event An <strong>ActionEvent</strong> containing information about the action that caused this method call.
    324             * @see org.greenstone.gatherer.gui.metaaudit.Autofilter
    325             */
    326           public void actionPerformed(ActionEvent event) {
    327                 if(return_filter) {
    328                      if(control.getSelectedIndex() == 0) {
    329                           filter.setFilter(1, 0, (String)value.getSelectedItem(), true);
    330                           filter.setFilter(2, 0, null, true);
    331                      }
    332                      else {
    333                           filter.setFilter(1, first_method.getSelectedIndex(), (String)first_value.getSelectedItem(), first_case.isSelected());
    334                           if(!none_check.isSelected()) {
    335                                 if(and_check.isSelected()) {
    336                                      filter.setOperation(Autofilter.AND);
    337                                 }
    338                                 else {
    339                                      filter.setOperation(Autofilter.OR);
    340                                 }
    341                                 filter.setFilter(2, second_method.getSelectedIndex(), (String)second_value.getSelectedItem(), second_case.isSelected());
    342                           }
    343                      }
    344                      if(order.getSelectedIndex() == 0) {
    345                           filter.setSort(Autofilter.ASCENDING);
    346                      }
    347                      else {
    348                           filter.setSort(Autofilter.DESCENDING);
    349                      }
    350                 }
    351                 else {
    352                      filter = null;
    353                 }
    354                 hide();
    355           }
    356      }
    357      /** Listens for actions on the check box it is attached to, and when notified sets the state of the second method and value to the specified state. */
    358      private final class CheckListener
    359           implements ActionListener {
    360           /** The default desire state any check button this listens to. */
    361           private boolean desired_state = false;
    362           /** The constructor takes an associated desired state.
    363             * @param desired_state The state that should be set when this is actioned, as a <i>boolean</i>.
    364             */
    365           public CheckListener(boolean desired_state) {
    366                 this.desired_state = desired_state;
    367           }
    368           /** Whenever our registered components are actioned apon, set the state of the second method and value to the desired state. */
    369           public void actionPerformed(ActionEvent event) {
    370                 second_method.setEnabled(desired_state);
    371                 second_value.setEnabled(desired_state);
    372           }
    373      }
     365    public CheckListener(boolean desired_state) {
     366        this.desired_state = desired_state;
     367    }
     368    /** Whenever our registered components are actioned apon, set the state of the second method and value to the desired state. */
     369    public void actionPerformed(ActionEvent event) {
     370        second_method.setEnabled(desired_state);
     371        second_value.setEnabled(desired_state);
     372    }
     373    }
    374374}
    375375
Note: See TracChangeset for help on using the changeset viewer.