View Javadoc

1   /*
2    * @(#)$Id: SelectOutputDirAction.java 689 2009-07-22 00:10:27Z bsigner $
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  package org.ximtec.igesture.tool.view.batch.action;
27  
28  import java.awt.event.ActionEvent;
29  import java.io.File;
30  
31  import javax.swing.JFileChooser;
32  
33  import org.sigtec.graphix.widget.BasicAction;
34  import org.ximtec.igesture.tool.GestureConstants;
35  import org.ximtec.igesture.tool.core.Controller;
36  import org.ximtec.igesture.tool.service.GuiBundleService;
37  import org.ximtec.igesture.tool.view.batch.BatchView;
38  
39  public class SelectOutputDirAction extends BasicAction {
40  
41    private BatchView view;
42  
43    public SelectOutputDirAction(Controller controller, BatchView view) {
44      super(GestureConstants.BATCH_BROWSE_OUTPUT, controller.getLocator().getService(GuiBundleService.IDENTIFIER,
45          GuiBundleService.class));
46  
47      this.view = view;
48    }
49  
50    @Override
51    public void actionPerformed(ActionEvent action) {
52      JFileChooser chooser = new JFileChooser();
53      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
54      chooser.showOpenDialog(null);
55      File file = chooser.getSelectedFile();
56      if (file != null) {
57        view.setOutputDir(file.getAbsolutePath());
58      }
59    }
60  
61  }