View Javadoc

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