View Javadoc

1   /*
2    * @(#)$Id: ImportTestSetAction.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   * 08.10.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.testset.action;
28  
29  import java.awt.event.ActionEvent;
30  import java.io.File;
31  
32  import javax.swing.JFileChooser;
33  import javax.swing.tree.TreePath;
34  
35  import org.ximtec.igesture.core.TestSet;
36  import org.ximtec.igesture.tool.GestureConstants;
37  import org.ximtec.igesture.tool.core.Controller;
38  import org.ximtec.igesture.tool.core.TreePathAction;
39  import org.ximtec.igesture.tool.util.FileType;
40  import org.ximtec.igesture.tool.view.testset.wrapper.TestSetList;
41  import org.ximtec.igesture.util.XMLTool;
42  
43  
44  /**
45   * Comment
46   * @version 1.0 08.10.2008
47   * @author Ueli Kurmann
48   */
49  public class ImportTestSetAction extends TreePathAction {
50  
51  
52     public ImportTestSetAction(Controller controller, TreePath treePath) {
53        super(GestureConstants.TESTSET_IMPORT, controller, treePath);
54     }
55  
56  
57     @Override
58     public void actionPerformed(ActionEvent e) {
59        TestSetList testSetList = (TestSetList)getTreePath().getLastPathComponent();
60  
61        JFileChooser fileChooser = new JFileChooser();
62        fileChooser.setFileFilter(FileType.testSet.getFilter());
63        fileChooser.showOpenDialog(null);
64        File selectedFile = fileChooser.getSelectedFile();
65  
66        if (selectedFile != null) {
67           TestSet testSet = XMLTool.importTestSet(selectedFile);
68  
69           if (testSet != null) {
70              testSetList.addTestSet(testSet);
71           }
72  
73        }
74     }
75  
76  }