1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
48
49
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 }