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 package org.ximtec.igesture.tool.view.admin.action;
27
28 import java.awt.event.ActionEvent;
29 import java.io.File;
30
31 import javax.swing.JFileChooser;
32 import javax.swing.JMenuItem;
33 import javax.swing.tree.TreePath;
34
35 import org.ximtec.igesture.core.GestureSet;
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.util.XMLTool;
41
42
43 public class ExportGestureSetAction extends TreePathAction {
44
45
46 public ExportGestureSetAction(Controller controller, TreePath treePath) {
47 super(GestureConstants.GESTURE_SET_EXPORT, controller, treePath);
48 }
49
50
51 public void actionPerformed(ActionEvent event) {
52 GestureSet gestureSet = (GestureSet)getTreePath().getLastPathComponent();
53
54 final JFileChooser fileChooser = new JFileChooser();
55 fileChooser.setFileFilter(FileType.gestureSet.getFilter());
56 fileChooser.showSaveDialog((JMenuItem)event.getSource());
57 final File selectedFile = fileChooser.getSelectedFile();
58
59 if (selectedFile != null) {
60 XMLTool.exportGestureSet(gestureSet, selectedFile);
61 }
62
63 }
64 }