View Javadoc

1   /*
2    * @(#)$Id: ExportConfigurationAction.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  
27  package org.ximtec.igesture.tool.view.testbench.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.configuration.Configuration;
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  
44  /**
45   * Comment
46   * @version 1.0 23.03.2008
47   * @author Ueli Kurmann
48   */
49  public class ExportConfigurationAction extends TreePathAction {
50  
51     public ExportConfigurationAction(Controller controller, TreePath treePath) {
52        super(GestureConstants.CONFIGURATION_EXPORT, controller, treePath);
53     }
54     
55     @Override
56     public void actionPerformed(ActionEvent arg0) {
57        
58        Configuration configuration = (Configuration)getTreePath().getLastPathComponent();
59        
60        JFileChooser fileChooser = new JFileChooser();
61        fileChooser.setFileFilter(FileType.igb.getFilter());
62        fileChooser.showSaveDialog(null);
63        final File file = fileChooser.getSelectedFile();
64  
65        if (file != null) {
66           XMLTool.exportConfiguration(configuration, file);
67        }
68  
69     }
70  
71  }