mev-4.0.01/source/org/tigr/microarray/mev/cluster/gui/impl/usc/USCFileDialog.java

Code
Comments
Other
Rev Date Author Line
2 26 Feb 07 jari 1 /*
2 26 Feb 07 jari 2  * Created on Sep 27, 2004
2 26 Feb 07 jari 3  */
2 26 Feb 07 jari 4 package org.tigr.microarray.mev.cluster.gui.impl.usc;
2 26 Feb 07 jari 5
2 26 Feb 07 jari 6 import java.awt.Component;
2 26 Feb 07 jari 7 import java.awt.Dimension;
2 26 Feb 07 jari 8 import java.awt.Frame;
2 26 Feb 07 jari 9 import java.awt.GridBagLayout;
2 26 Feb 07 jari 10 import java.awt.GridLayout;
2 26 Feb 07 jari 11 import java.awt.Insets;
2 26 Feb 07 jari 12 import java.awt.Toolkit;
2 26 Feb 07 jari 13 import java.awt.event.ActionEvent;
2 26 Feb 07 jari 14 import java.awt.event.ActionListener;
2 26 Feb 07 jari 15 import java.awt.event.ItemEvent;
2 26 Feb 07 jari 16 import java.awt.event.ItemListener;
2 26 Feb 07 jari 17 import java.awt.event.WindowEvent;
2 26 Feb 07 jari 18 import java.io.File;
2 26 Feb 07 jari 19 import java.util.Vector;
2 26 Feb 07 jari 20
2 26 Feb 07 jari 21 import javax.swing.DefaultListCellRenderer;
2 26 Feb 07 jari 22 import javax.swing.DefaultListModel;
2 26 Feb 07 jari 23 import javax.swing.JButton;
2 26 Feb 07 jari 24 import javax.swing.JFrame;
2 26 Feb 07 jari 25 import javax.swing.JLabel;
2 26 Feb 07 jari 26 import javax.swing.JList;
2 26 Feb 07 jari 27 import javax.swing.JOptionPane;
2 26 Feb 07 jari 28 import javax.swing.JPanel;
2 26 Feb 07 jari 29 import javax.swing.JScrollPane;
2 26 Feb 07 jari 30 import javax.swing.JSplitPane;
2 26 Feb 07 jari 31 import javax.swing.border.EtchedBorder;
2 26 Feb 07 jari 32 import javax.swing.border.TitledBorder;
2 26 Feb 07 jari 33
2 26 Feb 07 jari 34 import org.tigr.microarray.mev.TMEV;
2 26 Feb 07 jari 35 import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog;
2 26 Feb 07 jari 36 import org.tigr.microarray.mev.cluster.gui.impl.dialogs.DialogListener;
2 26 Feb 07 jari 37 import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow;
2 26 Feb 07 jari 38 import org.tigr.microarray.mev.file.FileTreePane;
2 26 Feb 07 jari 39 import org.tigr.microarray.mev.file.FileTreePaneEvent;
2 26 Feb 07 jari 40 import org.tigr.microarray.mev.file.FileTreePaneListener;
2 26 Feb 07 jari 41 import org.tigr.microarray.mev.file.GBA;
2 26 Feb 07 jari 42
2 26 Feb 07 jari 43 /**
2 26 Feb 07 jari 44  * Just a FileBrowser for user to load their Results File
2 26 Feb 07 jari 45  * 
2 26 Feb 07 jari 46  * @author vu
2 26 Feb 07 jari 47  */
2 26 Feb 07 jari 48 public class USCFileDialog extends AlgorithmDialog {
2 26 Feb 07 jari 49   //member variables
2 26 Feb 07 jari 50   private GBA gba;
2 26 Feb 07 jari 51   private int result;
2 26 Feb 07 jari 52   
2 26 Feb 07 jari 53   private FileTreePane fileTreePane;
2 26 Feb 07 jari 54   private JPanel fileSelectionPanel;
2 26 Feb 07 jari 55   private JPanel fileListPanel;
2 26 Feb 07 jari 56   private JLabel fileAvailableLabel;
2 26 Feb 07 jari 57   private JLabel fileSelectedLabel;
2 26 Feb 07 jari 58   private JList fileAvailableList;
2 26 Feb 07 jari 59   private JList fileSelectedList;
2 26 Feb 07 jari 60   private JScrollPane fileAvailableScrollPane;
2 26 Feb 07 jari 61   private JScrollPane fileSelectedScrollPane;
2 26 Feb 07 jari 62   private JButton fileAddButton;
2 26 Feb 07 jari 63   //private JButton fileAddAllButton;
2 26 Feb 07 jari 64   private JButton fileRemoveButton;
2 26 Feb 07 jari 65   //private JButton fileRemoveAllButton;
2 26 Feb 07 jari 66   private JPanel fileButtonPanel;
2 26 Feb 07 jari 67   private JPanel selectionPanel;
2 26 Feb 07 jari 68   private JSplitPane splitPane;
2 26 Feb 07 jari 69   
2 26 Feb 07 jari 70   
2 26 Feb 07 jari 71   public USCFileDialog(Frame parent) {
2 26 Feb 07 jari 72     super( new JFrame(), "USC:Load Training Data Set", true );
2 26 Feb 07 jari 73     this.setResizable( true );
2 26 Feb 07 jari 74     this.setSize( 1000, 750 );
2 26 Feb 07 jari 75     
2 26 Feb 07 jari 76     this.gba = new GBA();
2 26 Feb 07 jari 77     
2 26 Feb 07 jari 78     this.getContentPane().setLayout( new GridLayout() );
2 26 Feb 07 jari 79     
2 26 Feb 07 jari 80     //create the FileTree
2 26 Feb 07 jari 81     String dataPath = "/" + TMEV.getDataPath();
2 26 Feb 07 jari 82     //System.out.println("USCFileDialog.dataPath:" + dataPath);
2 26 Feb 07 jari 83     this.fileTreePane = new FileTreePane( dataPath );
2 26 Feb 07 jari 84     //this.fileTreePane.openDataPath();
2 26 Feb 07 jari 85     //this.fileTreePane = new FileTreePane( "C:" + File.separator + "Dev" + File.separator + "MeV" + File.separator + "files" + File.separator + "human" );
2 26 Feb 07 jari 86     this.fileTreePane.addFileTreePaneListener(new FileTreePaneEventHandler());
2 26 Feb 07 jari 87     this.fileTreePane.setPreferredSize(new java.awt.Dimension(250, 50));
2 26 Feb 07 jari 88     
2 26 Feb 07 jari 89     //create the available and selected List
2 26 Feb 07 jari 90     this.fileSelectionPanel = new JPanel();
2 26 Feb 07 jari 91     this.fileSelectionPanel.setLayout( new GridBagLayout() );
2 26 Feb 07 jari 92     this.fileSelectionPanel.setBorder(new TitledBorder(new EtchedBorder(), "Training Data Sets"));
2 26 Feb 07 jari 93     this.fileAvailableLabel = new JLabel("Available files");
2 26 Feb 07 jari 94     this.fileSelectedLabel = new JLabel("Selected file");
2 26 Feb 07 jari 95     this.fileAvailableList = new JList(new DefaultListModel());
2 26 Feb 07 jari 96     this.fileAvailableList.setCellRenderer(new ListRenderer());
2 26 Feb 07 jari 97     this.fileSelectedList = new JList(new DefaultListModel());
2 26 Feb 07 jari 98     this.fileSelectedList.setCellRenderer(new ListRenderer());
2 26 Feb 07 jari 99     this.fileAvailableScrollPane = new JScrollPane(this.fileAvailableList);
2 26 Feb 07 jari 100     this.fileSelectedScrollPane = new JScrollPane(this.fileSelectedList);
2 26 Feb 07 jari 101     this.fileAddButton = new JButton("Add");
2 26 Feb 07 jari 102     this.fileAddButton.addActionListener(new EventHandler());
2 26 Feb 07 jari 103     //this.fileAddAllButton = new JButton("Add All");
2 26 Feb 07 jari 104     //this.fileAddAllButton.addActionListener(new EventHandler());
2 26 Feb 07 jari 105     this.fileRemoveButton = new JButton("Remove");
2 26 Feb 07 jari 106     this.fileRemoveButton.addActionListener(new EventHandler());
2 26 Feb 07 jari 107     //this.fileRemoveAllButton = new JButton("Remove All");
2 26 Feb 07 jari 108     //this.fileRemoveAllButton.addActionListener(new EventHandler());
2 26 Feb 07 jari 109         
2 26 Feb 07 jari 110     Dimension largestfileButtonSize = this.fileRemoveButton.getPreferredSize();
2 26 Feb 07 jari 111     this.fileAddButton.setPreferredSize( largestfileButtonSize );
2 26 Feb 07 jari 112     //this.fileAddAllButton.setPreferredSize( largestfileButtonSize );
2 26 Feb 07 jari 113     this.fileRemoveButton.setPreferredSize( largestfileButtonSize );
2 26 Feb 07 jari 114     //this.fileRemoveAllButton.setPreferredSize( largestfileButtonSize );
2 26 Feb 07 jari 115         
2 26 Feb 07 jari 116     this.fileButtonPanel = new JPanel();
2 26 Feb 07 jari 117     this.fileButtonPanel.setLayout(new GridBagLayout());
2 26 Feb 07 jari 118         
2 26 Feb 07 jari 119     gba.add(this.fileButtonPanel, this.fileAddButton, 0, 0, 1, 1, 0, 0, GBA.N, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 120     //gba.add(this.fileButtonPanel, this.fileAddAllButton, 0, 1, 1, 1, 0, 0, GBA.N, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 121     gba.add(this.fileButtonPanel, this.fileRemoveButton, 0, 2, 1, 1, 0, 0, GBA.N, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 122     //gba.add(this.fileButtonPanel, this.fileRemoveAllButton, 0, 3, 1, 1, 0, 0, GBA.N, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 123         
2 26 Feb 07 jari 124     this.fileListPanel = new JPanel();
2 26 Feb 07 jari 125     this.fileListPanel.setLayout(new GridBagLayout());
2 26 Feb 07 jari 126         
2 26 Feb 07 jari 127     gba.add(this.fileListPanel, this.fileAvailableLabel, 0, 0, 1, 1, 0, 0, GBA.N, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 128     gba.add(this.fileListPanel, this.fileSelectedLabel, 2, 0, 1, 1, 0, 0, GBA.N, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 129     gba.add(this.fileListPanel, this.fileAvailableScrollPane, 0, 1, 1, 4, 1, 1, GBA.B, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 130     gba.add(this.fileListPanel, this.fileButtonPanel, 1, 1, 1, 4, 0, 1, GBA.V, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 131     gba.add(this.fileListPanel, this.fileSelectedScrollPane, 2, 1, 1, 4, 1, 1, GBA.B, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 132         
2 26 Feb 07 jari 133     gba.add(this.fileSelectionPanel, this.fileListPanel, 0, 0, 1, 1, 1, 1, GBA.B, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 134      
2 26 Feb 07 jari 135     //this.fileAddAllButton.setFocusPainted(false);
2 26 Feb 07 jari 136     this.fileAddButton.setFocusPainted(false);
2 26 Feb 07 jari 137     //this.fileRemoveAllButton.setFocusPainted(false);
2 26 Feb 07 jari 138     this.fileRemoveButton.setFocusPainted(false);
2 26 Feb 07 jari 139
2 26 Feb 07 jari 140     selectionPanel = new JPanel();
2 26 Feb 07 jari 141     selectionPanel.setLayout(new GridBagLayout());
2 26 Feb 07 jari 142     gba.add(selectionPanel, this.fileSelectionPanel, 0, 1, 1, 2, 1, 1, GBA.B, GBA.C, new Insets(5, 5, 5, 5), 0, 0);
2 26 Feb 07 jari 143         
2 26 Feb 07 jari 144     splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.fileTreePane, selectionPanel);
2 26 Feb 07 jari 145     
2 26 Feb 07 jari 146     //listen for actions
2 26 Feb 07 jari 147     Listener listener = new Listener();
2 26 Feb 07 jari 148     super.addWindowListener(listener);
2 26 Feb 07 jari 149     super.setActionListeners(listener);
2 26 Feb 07 jari 150     
2 26 Feb 07 jari 151     this.addContent( splitPane );
2 26 Feb 07 jari 152     this.fileTreePane.openDataPath();
2 26 Feb 07 jari 153   }//end constructor
2 26 Feb 07 jari 154   
2 26 Feb 07 jari 155   
2 26 Feb 07 jari 156   public File getSelectedFile() {
2 26 Feb 07 jari 157     DefaultListModel selModel = ( DefaultListModel ) this.fileSelectedList.getModel();
2 26 Feb 07 jari 158     Object[] selFiles = selModel.toArray();
2 26 Feb 07 jari 159     File f = ( File ) selFiles[ 0 ];
2 26 Feb 07 jari 160     return f;
2 26 Feb 07 jari 161   }
2 26 Feb 07 jari 162   
2 26 Feb 07 jari 163   
2 26 Feb 07 jari 164   public boolean fileSelected() {
2 26 Feb 07 jari 165     boolean toReturn;
2 26 Feb 07 jari 166     
2 26 Feb 07 jari 167     DefaultListModel selModel = ( DefaultListModel ) this.fileSelectedList.getModel();
2 26 Feb 07 jari 168     Object[] selFiles = selModel.toArray();
2 26 Feb 07 jari 169     if( selFiles.length == 1 ) {
2 26 Feb 07 jari 170       toReturn = true;
2 26 Feb 07 jari 171     } else {
2 26 Feb 07 jari 172       toReturn = false;
2 26 Feb 07 jari 173     }
2 26 Feb 07 jari 174     
2 26 Feb 07 jari 175     return toReturn;
2 26 Feb 07 jari 176   }
2 26 Feb 07 jari 177   
2 26 Feb 07 jari 178   
2 26 Feb 07 jari 179   /**
2 26 Feb 07 jari 180    * Returns a Vector of the files that were in the fileSelectedList
2 26 Feb 07 jari 181    * @return  Vector of File objects
2 26 Feb 07 jari 182    */
2 26 Feb 07 jari 183   public Vector getSelectedFiles() {
2 26 Feb 07 jari 184     Vector toReturn = new Vector();
2 26 Feb 07 jari 185     
2 26 Feb 07 jari 186     DefaultListModel selModel = ( DefaultListModel ) this.fileSelectedList.getModel();
2 26 Feb 07 jari 187     Object[] selFiles = selModel.toArray();
2 26 Feb 07 jari 188     for( int i = 0; i < selFiles.length; i ++ ) {
2 26 Feb 07 jari 189       File f = ( File ) selFiles[ i ];
2 26 Feb 07 jari 190       toReturn.add( f );
2 26 Feb 07 jari 191     }
2 26 Feb 07 jari 192     
2 26 Feb 07 jari 193     return toReturn;
2 26 Feb 07 jari 194   }//end getSelectedFiles()
2 26 Feb 07 jari 195   
2 26 Feb 07 jari 196     
2 26 Feb 07 jari 197   /**
2 26 Feb 07 jari 198    * Shows the dialog.
2 26 Feb 07 jari 199    */
2 26 Feb 07 jari 200   public int showModal() {
2 26 Feb 07 jari 201     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
2 26 Feb 07 jari 202     setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2);
2 26 Feb 07 jari 203     show();
2 26 Feb 07 jari 204     return result;
2 26 Feb 07 jari 205   }//end showModal()
2 26 Feb 07 jari 206   
2 26 Feb 07 jari 207   
2 26 Feb 07 jari 208   /**
2 26 Feb 07 jari 209    * Handles displaying the correct files in the fileAvailableList
2 26 Feb 07 jari 210    * @param filePath      Path of the file selected in the FileTreePane
2 26 Feb 07 jari 211    * @param vFileName  Vector of file names contained within filePath
2 26 Feb 07 jari 212    */
2 26 Feb 07 jari 213   public void processFileList( String filePath, Vector vFileName ) {
2 26 Feb 07 jari 214     DefaultListModel model = (DefaultListModel) this.fileAvailableList.getModel();
2 26 Feb 07 jari 215     model.clear();
2 26 Feb 07 jari 216     
2 26 Feb 07 jari 217     if( vFileName.size() > 0 ) {
2 26 Feb 07 jari 218       for( int i = 0; i < vFileName.size(); i ++ ) {
2 26 Feb 07 jari 219         String sFileName = ( String ) vFileName.elementAt( i );
2 26 Feb 07 jari 220         if( acceptFile( sFileName ) ) {
2 26 Feb 07 jari 221           File f = new File( sFileName );
2 26 Feb 07 jari 222           model.addElement( f );
2 26 Feb 07 jari 223         }
2 26 Feb 07 jari 224       }
2 26 Feb 07 jari 225     }
2 26 Feb 07 jari 226   }//end processFileList()
2 26 Feb 07 jari 227   
2 26 Feb 07 jari 228   
2 26 Feb 07 jari 229   /**
2 26 Feb 07 jari 230    * Add the selected file(s) to the fileSelectedList, but don't duplicate
2 26 Feb 07 jari 231    * @param fAdd
2 26 Feb 07 jari 232    */
2 26 Feb 07 jari 233   public void addFile( File fAdd ) {
2 26 Feb 07 jari 234     DefaultListModel selModel = ( DefaultListModel ) this.fileSelectedList.getModel();
2 26 Feb 07 jari 235     Object[] selFiles = selModel.toArray();
2 26 Feb 07 jari 236     if( selFiles.length == 0 ) {
2 26 Feb 07 jari 237       selModel.addElement( fAdd );
2 26 Feb 07 jari 238     }
2 26 Feb 07 jari 239     /*
2 26 Feb 07 jari 240     //make sure it's not already there
2 26 Feb 07 jari 241     boolean found = false;
2 26 Feb 07 jari 242     Object[] selFiles = selModel.toArray();
2 26 Feb 07 jari 243     for( int j = 0; j < selFiles.length; j ++ ) {
2 26 Feb 07 jari 244       File jFile = ( File ) selFiles[ j ];
2 26 Feb 07 jari 245       if( fAdd.getName().equals( jFile.getName() ) ) {
2 26 Feb 07 jari 246         found = true;
2 26 Feb 07 jari 247         break;
2 26 Feb 07 jari 248       }
2 26 Feb 07 jari 249     }
2 26 Feb 07 jari 250       
2 26 Feb 07 jari 251     if( ! found ) {
2 26 Feb 07 jari 252       selModel.addElement( fAdd );
2 26 Feb 07 jari 253     }
2 26 Feb 07 jari 254     */
2 26 Feb 07 jari 255   }//end addFile()
2 26 Feb 07 jari 256   
2 26 Feb 07 jari 257   
2 26 Feb 07 jari 258   public void onAdd() {
2 26 Feb 07 jari 259     int[] chosenIndices = this.fileAvailableList.getSelectedIndices();
2 26 Feb 07 jari 260     DefaultListModel availModel = ( DefaultListModel ) this.fileAvailableList.getModel();
2 26 Feb 07 jari 261     
2 26 Feb 07 jari 262     for( int i = 0; i < chosenIndices.length; i ++ ) {
2 26 Feb 07 jari 263       File addFile = ( File ) availModel.getElementAt( chosenIndices[i] );
2 26 Feb 07 jari 264       
2 26 Feb 07 jari 265       this.addFile( addFile );
2 26 Feb 07 jari 266     }
2 26 Feb 07 jari 267   }//end onAdd()
2 26 Feb 07 jari 268   
2 26 Feb 07 jari 269   
2 26 Feb 07 jari 270   public void onAddAll() {
2 26 Feb 07 jari 271     DefaultListModel availModel = ( DefaultListModel ) this.fileAvailableList.getModel();
2 26 Feb 07 jari 272     int kount = availModel.size();
2 26 Feb 07 jari 273     
2 26 Feb 07 jari 274     for( int i = 0; i < kount; i ++ ) {
2 26 Feb 07 jari 275       File addFile = ( File ) availModel.getElementAt( i );
2 26 Feb 07 jari 276       
2 26 Feb 07 jari 277       this.addFile( addFile );
2 26 Feb 07 jari 278     }
2 26 Feb 07 jari 279   }//end onAddAll()
2 26 Feb 07 jari 280   
2 26 Feb 07 jari 281   
2 26 Feb 07 jari 282   public void onRemove() {
2 26 Feb 07 jari 283     int[] chosenIndices = this.fileSelectedList.getSelectedIndices();
2 26 Feb 07 jari 284     DefaultListModel selModel = ( DefaultListModel ) this.fileSelectedList.getModel();
2 26 Feb 07 jari 285     
2 26 Feb 07 jari 286     //loop backwards to avoid looking off the end while we remove Objects from array
2 26 Feb 07 jari 287     for( int i = chosenIndices.length - 1; i >= 0; i -- ) {
2 26 Feb 07 jari 288       selModel.remove( chosenIndices[ i ] );
2 26 Feb 07 jari 289     }
2 26 Feb 07 jari 290   }//end onRemove()
2 26 Feb 07 jari 291   
2 26 Feb 07 jari 292   
2 26 Feb 07 jari 293   public void onRemoveAll() {
2 26 Feb 07 jari 294     DefaultListModel selModel = ( DefaultListModel ) this.fileSelectedList.getModel();
2 26 Feb 07 jari 295     selModel.removeAllElements();
2 26 Feb 07 jari 296   }//end onRemoveAll()
2 26 Feb 07 jari 297   
2 26 Feb 07 jari 298   
2 26 Feb 07 jari 299   public boolean acceptFile( String fileName ) {
2 26 Feb 07 jari 300     if( fileName.toLowerCase().endsWith( ".txt" ) ) {
2 26 Feb 07 jari 301       return true;
2 26 Feb 07 jari 302     } else {
2 26 Feb 07 jari 303       return false;
2 26 Feb 07 jari 304     }
2 26 Feb 07 jari 305   }//end acceptFile()
2 26 Feb 07 jari 306   
2 26 Feb 07 jari 307         
2 26 Feb 07 jari 308   private class FileTreePaneEventHandler implements FileTreePaneListener {
2 26 Feb 07 jari 309     public void nodeSelected(FileTreePaneEvent event) {   
2 26 Feb 07 jari 310       String filePath = (String) event.getValue("Path");
2 26 Feb 07 jari 311       Vector fileNames = (Vector) event.getValue("Filenames");
2 26 Feb 07 jari 312       
2 26 Feb 07 jari 313       processFileList(filePath, fileNames);
2 26 Feb 07 jari 314     }
2 26 Feb 07 jari 315         
2 26 Feb 07 jari 316     public void nodeCollapsed(FileTreePaneEvent event) {}
2 26 Feb 07 jari 317     public void nodeExpanded(FileTreePaneEvent event) {}
2 26 Feb 07 jari 318   }//end FileTreePaneEventHandler class
2 26 Feb 07 jari 319   
2 26 Feb 07 jari 320         
2 26 Feb 07 jari 321   private class ListRenderer extends DefaultListCellRenderer {
2 26 Feb 07 jari 322     public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
2 26 Feb 07 jari 323       super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
2 26 Feb 07 jari 324       File file = (File) value;
2 26 Feb 07 jari 325       setText(file.getName());
2 26 Feb 07 jari 326       return this;
2 26 Feb 07 jari 327     }
2 26 Feb 07 jari 328   }//end ListRenderer class
2 26 Feb 07 jari 329
2 26 Feb 07 jari 330         
2 26 Feb 07 jari 331   private class EventHandler implements ActionListener {
2 26 Feb 07 jari 332     public void actionPerformed(ActionEvent event) {
2 26 Feb 07 jari 333                 
2 26 Feb 07 jari 334       Object source = event.getSource();
2 26 Feb 07 jari 335           
2 26 Feb 07 jari 336       if (source == fileAddButton) {
2 26 Feb 07 jari 337         onAdd();
2 26 Feb 07 jari 338       //} else if (source == fileAddAllButton) {
2 26 Feb 07 jari 339         //onAddAll();
2 26 Feb 07 jari 340       } else if (source == fileRemoveButton) {
2 26 Feb 07 jari 341         onRemove();
2 26 Feb 07 jari 342       //} else if (source == fileRemoveAllButton) {
2 26 Feb 07 jari 343         //onRemoveAll();
2 26 Feb 07 jari 344       }
2 26 Feb 07 jari 345     }//end actionPerformed()
2 26 Feb 07 jari 346   }//end Eventhandler class
2 26 Feb 07 jari 347   
2 26 Feb 07 jari 348     
2 26 Feb 07 jari 349   /**
2 26 Feb 07 jari 350    * The class to listen to the dialog and check boxes items events.
2 26 Feb 07 jari 351    */
2 26 Feb 07 jari 352   private class Listener extends DialogListener implements ItemListener {
2 26 Feb 07 jari 353         
2 26 Feb 07 jari 354     public void actionPerformed(ActionEvent e) {
2 26 Feb 07 jari 355       String command = e.getActionCommand();
2 26 Feb 07 jari 356       if (command.equals("ok-command")) {
2 26 Feb 07 jari 357         if( fileSelected() ) {
2 26 Feb 07 jari 358           result = JOptionPane.OK_OPTION;
2 26 Feb 07 jari 359           dispose();
2 26 Feb 07 jari 360         } else { 
2 26 Feb 07 jari 361           System.out.println( "No File Selected" );
2 26 Feb 07 jari 362         }
2 26 Feb 07 jari 363       } else if (command.equals("cancel-command")) {
2 26 Feb 07 jari 364         result = JOptionPane.CANCEL_OPTION;
2 26 Feb 07 jari 365         dispose();
2 26 Feb 07 jari 366       } else if (command.equals("reset-command")) {
2 26 Feb 07 jari 367         //resetControls();
2 26 Feb 07 jari 368         result = JOptionPane.CANCEL_OPTION;
2 26 Feb 07 jari 369         return;
2 26 Feb 07 jari 370       } else if (command.equals("info-command")) {
2 26 Feb 07 jari 371         
2 26 Feb 07 jari 372         HelpWindow hw = new HelpWindow( USCFileDialog.this, "USC Load Result Dialog" );
2 26 Feb 07 jari 373         result = JOptionPane.CANCEL_OPTION;
2 26 Feb 07 jari 374         if(hw.getWindowContent()){
2 26 Feb 07 jari 375           hw.setSize(450,600);
2 26 Feb 07 jari 376           hw.setLocation();
2 26 Feb 07 jari 377           hw.show();
2 26 Feb 07 jari 378           return;
2 26 Feb 07 jari 379         } else {
2 26 Feb 07 jari 380           hw.setVisible(false);
2 26 Feb 07 jari 381           hw.dispose();
2 26 Feb 07 jari 382           return;
2 26 Feb 07 jari 383         }
2 26 Feb 07 jari 384       }
2 26 Feb 07 jari 385     }
2 26 Feb 07 jari 386         
2 26 Feb 07 jari 387     public void itemStateChanged(ItemEvent e) {
2 26 Feb 07 jari 388       //okButton.setEnabled(genes_box.isSelected() || cluster_box.isSelected());
2 26 Feb 07 jari 389     }
2 26 Feb 07 jari 390         
2 26 Feb 07 jari 391     public void windowClosing(WindowEvent e) {
2 26 Feb 07 jari 392       System.out.println( "windowClosing()" );
2 26 Feb 07 jari 393       result = JOptionPane.CLOSED_OPTION;
2 26 Feb 07 jari 394       dispose();
2 26 Feb 07 jari 395     }
2 26 Feb 07 jari 396   }//end internal Listener class
2 26 Feb 07 jari 397   
2 26 Feb 07 jari 398   
2 26 Feb 07 jari 399   public static void main( String[] args ) {
2 26 Feb 07 jari 400     USCFileDialog fd = new USCFileDialog( new Frame() );
2 26 Feb 07 jari 401     fd.showModal();
2 26 Feb 07 jari 402   }
2 26 Feb 07 jari 403 }//end class