View Javadoc

1   /*
2    * @(#)$Id: SelectConfigFileAction.java 775 2009-11-27 16:22:42Z kurmannu $
3    *
4    * Author   : Ueli Kurmann, igesture@uelikurmann.ch
5    *                                   
6    *                                   
7    * Purpose  : 
8    *
9    * -----------------------------------------------------------------------
10   *
11   * Revision Information:
12   *
13   * Date       Who     Reason
14   *
15   * 23.03.2008 ukurmann  Initial Release
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  
27  package org.ximtec.igesture.tool.view.batch.action;
28  
29  import java.awt.event.ActionEvent;
30  import java.io.File;
31  
32  import javax.swing.JFileChooser;
33  
34  import org.ximtec.igesture.tool.GestureConstants;
35  import org.ximtec.igesture.tool.core.Controller;
36  import org.ximtec.igesture.tool.core.LocateableAction;
37  import org.ximtec.igesture.tool.util.FileType;
38  import org.ximtec.igesture.tool.view.batch.BatchView;
39  
40  
41  public class SelectConfigFileAction extends LocateableAction {
42  
43     private BatchView view;
44  
45  
46     public SelectConfigFileAction(Controller controller, BatchView view) {
47        super(GestureConstants.BATCH_BROWSE_CONFIG, controller.getLocator());
48  
49        this.view = view;
50  
51     }
52  
53  
54     @Override
55     public void actionPerformed(ActionEvent action) {
56        JFileChooser chooser = new JFileChooser();
57        chooser.setFileFilter(FileType.igb.getFilter());
58        chooser.showOpenDialog(null);
59        File file = chooser.getSelectedFile();
60        if (file != null) {
61           view.setConfigFile(file.getAbsolutePath());
62        }
63     }
64  
65  }