View Javadoc

1   /*
2    * @(#)$Id: ExportGestureSetAction.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   * 23.03.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  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  }