gt: 		if (filterable == null) {
context: /*
   *    ALMA - Atacama Large Millimiter Array
   *    (c) European Southern Observatory, 2002
   *    Copyright by ESO (in the framework of the ALMA collaboration)
   *    and Cosylab 2002, All rights reserved
   *
   *    This library is free software; you can redistribute it and/or
   *    modify it under the terms of the GNU Lesser General Public
   *    License as published by the Free Software Foundation; either
   *    version 2.1 of the License, or (at your option) any later version.
   *
   *    This library is distributed in the hope that it will be useful,
   *    but WITHOUT ANY WARRANTY; without even the implied warranty of
   *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   *    Lesser General Public License for more details.
   *
   *    You should have received a copy of the GNU Lesser General Public
   *    License along with this library; if not, write to the Free Software
   *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
   *    MA 02111-1307  USA
   */
  package com.cosylab.logging.settings;
  
  import java.awt.BorderLayout;
  import java.awt.Dialog;
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.Insets;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  import java.io.File;
  import java.io.IOException;
  import java.util.List;
  
  import javax.swing.ImageIcon;
  import javax.swing.JButton;
  import javax.swing.JDialog;
  import javax.swing.JFileChooser;
  import javax.swing.JLabel;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JSeparator;
  import javax.swing.JToolBar;
  import javax.swing.WindowConstants;
  import javax.swing.filechooser.FileFilter;
  
  import alma.acs.gui.widgets.CheckList;
  import alma.acs.gui.widgets.CheckList.CheckListTableEntry;
  
  import com.cosylab.logging.LoggingClient;
  import com.cosylab.logging.engine.Filter;
  import com.cosylab.logging.engine.Filterable;
  import com.cosylab.logging.engine.FiltersVector;
  
  /**
   * Serves the purpose of selecting the right filters.
   * Filters are used to display logs in the table according to the user's preferences.
   * They are used by the engine too.
   * <P>
   * The existing filter are set by {@link #setFilters(FiltersVector)} and will be used for restoring
   * if the user discards the changes.
   * <BR>
   * The list of fields defined/edited by the user is in the {@link CheckList} widget that stores
   * the filter and its activation state.
   *  
   * Creation date: (1/2/2002 22:53:33)
   * 
   * @author: Ales Pucelj (ales.pucelj@kgb.ijs.si)
   */
  public class FilterChooserDialog extends JDialog {
  
  	// The table of filters with their activation state
  	private CheckList filterList;
  
  	private JLabel description = null;
  
  	private JButton buttonClose = null;
  
  	private JButton buttonApply = null;
  	
  	private JButton buttonRestore = null;
  	
  	// The toolbar with its buttons
  	private JToolBar toolBar = new JToolBar();
  	private JButton buttonAdd = null;
  	private JButton buttonRemove = null;
  	private JButton buttonModify = null;
  	
  	// The menu bar with its items
  	private JMenuBar menuBar = new JMenuBar();
  	private JMenuItem loadMI=new JMenuItem("Load");
  	private JMenuItem saveMI=new JMenuItem("Save");
  	private JMenuItem saveAsMI=new JMenuItem("Save as");
  	private JMenuItem closeMI=new JMenuItem("Close");
  	private JMenuItem activateAllMI=new JMenuItem("Activate all");
  	private JMenuItem deactivateAllMI=new JMenuItem("Deactivate all");
  	private JMenuItem clearAllMI=new JMenuItem("Clear all");
  	
  	// The listener
  	private ButtonListener bl = new ButtonListener();
  	
  	// The logging client
  	private LoggingClient loggingClient;
  	
  	// The Filterable object to apply filters to
  	private Filterable filterable=null;
  	
  	/** 
  	 * The filters defined at startup (used to implement the restore)
  	 */
  	private FiltersVector initialFilters = new FiltersVector();
  	
  	// true if the vector of filters has been modified
  	private boolean modified=false;
  	
  	/**
  	 * The name of the last save/load filter file
  	 * (to implement the save as option)
  	 */
  	private String filterFileName = null;
  
  	/**
  	 * The cobject that receives the events generated
  	 * by the button 
  	 * 
  	 * @author acaproni
  	 *
  	 */
  	private class ButtonListener implements ActionListener {
  		private FilterChooserDialog fcd = FilterChooserDialog.this;
  
  		private Filter editFilter(Filter f) {
  			FilterParameterDialog fpd = new FilterParameterDialog(FilterChooserDialog.this);
  			fpd.setFilter(f);
  			fpd.setVisible(true);
  			if (fpd.okPressed()) {
  				return fpd.getFilter();
  			}
  			return null;
  		}
  
  		/**
  		 * @see <code>ActionListener</code>
  		 * @see <code>ActionEvent</code>
  		 */
  		public void actionPerformed(ActionEvent e) {
  			if (e.getSource() == buttonClose || e.getSource() == closeMI) { // Close
  				if (modified) {
  					int ret = JOptionPane.showConfirmDialog(FilterChooserDialog.this,
  							"<HTML>You have modified the filters withouth saving/applying.<BR>Do you really want to close?</HTML>",
  							"Close confimation", JOptionPane.YES_NO_OPTION);
  					if (ret != JOptionPane.YES_OPTION) {
  						return;
  					}
  				}
  				setVisible(false);
  				loggingClient.enableFiltersWidgets(true);
  				return;
  			} else if (e.getSource() == buttonModify) { // Modify/Edit
  				CheckListTableEntry selectedEntry=filterList.getSelectedEntry();
  				if (selectedEntry!=null) {
  					Filter editedFilter=editFilter((Filter)selectedEntry.getItem());
  					if (editedFilter!=null) {
  						modified=true;
  						selectedEntry.setItem(editedFilter);
  						filterList.updateSelectedEntry();
  					}
  					
  				} else {
  					JOptionPane.showMessageDialog(FilterChooserDialog.this,
  							"Invalid item to modify", "Error",
  							JOptionPane.ERROR_MESSAGE);
  				}
  			} else if (e.getSource() == buttonAdd) { // Add
  				Filter f = editFilter(null);
  				if (f != null) {
  					filterList.addElement(true,f);
  					modified=true;
  				}
  			} else if (e.getSource() == buttonRemove) { // Remove
  				CheckListTableEntry removedEntry=filterList.removeSelectedEntry();
  				if (removedEntry!=null) {
  					// An entry has been really removed
  					modified=true;
  				}
  			} else if (e.getSource() == activateAllMI) {
  				filterList.activateAll(true);
  				modified=true;
  			} else if (e.getSource() == deactivateAllMI) { // Deactivate All
  				filterList.activateAll(false);
  				modified=true;
  			} else if (e.getSource() == clearAllMI) { // Delete all
  				if (filterList.getItemsSize()>0) {
  					int ret = JOptionPane.showConfirmDialog(FilterChooserDialog.this,
  							"Do you really want to delete all the filters?",
  							"Delete all filters", JOptionPane.YES_NO_OPTION);
  					if (ret == JOptionPane.YES_OPTION) {
  						filterList.clear();
  						modified=true;
  					}
  				}
  			}  else if (e.getSource() == buttonApply) { // Apply
  				applyFilters();
  				modified=false;
  			} else if (e.getSource() == loadMI) { // Load
  				loadFilters();
  			} else if (e.getSource() == saveMI) { // Save
  				saveFilters(filterFileName);
  			} else if (e.getSource() == saveAsMI) { // Save as
  				saveAsFilters();
  			} else if (e.getSource() == buttonRestore) { // Restore
  				restoreFilters();
  			} else {
  				System.out.println("Unhandled event: " + e);
  			}
  			FilterChooserDialog.this.updateButtons();
  		}
  	}
  	
  	/**
  	 * The filter to load save filters as xml files
  	 * The filter checks for the extension .xml in the name
  	 * 
  	 * @author acaproni
  	 */
  	private static class XmlFileFilter extends FileFilter {
  		public boolean accept(File f) {
  			// Check if the name has the extension .xml at the end and is readable
  			boolean pass = f.isFile() && f.getName().toUpperCase().endsWith(".XML") && f.canRead();
  			// Check if the file is a directory
  			pass = pass || f.isDirectory();
  			// Check if f is a hidden file
  			pass = pass && !f.isHidden();
  			return pass; 
  		}
  		
  		public String getDescription() {
  			return "xml file";
  		}
  	}
  	
  	/**
  	 * FilterChooserDialog constructor.
  	 * 
  	 * @param title The tile of the window
  	 * @param logLci The loggingClient showing this dialog
  	 * @param model The table model
  	 */
  	public FilterChooserDialog(String title, LoggingClient logCli, Filterable filterable) {
  		super((Dialog)null,title);
  