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.admin.action;
28
29 import java.awt.event.ActionEvent;
30 import java.io.File;
31 import java.util.logging.Logger;
32
33 import javax.swing.JFileChooser;
34 import javax.swing.JMenuItem;
35 import javax.swing.tree.TreePath;
36
37 import org.ximtec.igesture.core.GestureSet;
38 import org.ximtec.igesture.tool.GestureConstants;
39 import org.ximtec.igesture.tool.core.Controller;
40 import org.ximtec.igesture.tool.core.TreePathAction;
41 import org.ximtec.igesture.tool.util.FileType;
42 import org.ximtec.igesture.tool.view.admin.wrapper.GestureSetList;
43 import org.ximtec.igesture.util.XMLTool;
44
45
46 public class ImportGestureSetAction extends TreePathAction {
47
48 private static final Logger LOG = Logger
49 .getLogger(ImportGestureSetAction.class.getName());
50
51
52
53 public ImportGestureSetAction(Controller controller, TreePath treePath) {
54 super(GestureConstants.GESTURE_SET_IMPORT, controller, treePath);
55 }
56
57
58 public void actionPerformed(ActionEvent event) {
59 LOG.info("Import Gesture Set...");
60 GestureSetList rootSet = (GestureSetList)getTreePath().getLastPathComponent();
61
62 JFileChooser fileChooser = new JFileChooser();
63 fileChooser.setFileFilter(FileType.gestureSet.getFilter());
64 fileChooser.showOpenDialog((JMenuItem)event.getSource());
65 File selectedFile = fileChooser.getSelectedFile();
66
67 if (selectedFile != null) {
68 GestureSet gestureSet = XMLTool.importGestureSet(selectedFile);
69
70 if (gestureSet != null) {
71 rootSet.addGestureSet(gestureSet);
72 }
73 }
74 LOG.info("Gesture Set imported...");
75 }
76 }