View Javadoc

1   /*
2    * @(#)$Id: NewProjectAction.java 689 2009-07-22 00:10:27Z bsigner $
3    *
4    * Author		:	Michele Croci, mcroci@gmail.com
5    *
6    * Purpose		:   Action for creating a new gesture mapping project.
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date				Who			Reason
13   *
14   * 	Nov 15, 2007	crocimi		Initial Release
15   *  Jan 14, 2008    bsigner     Cleanup
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.geco.gui.action;
28  
29  import java.awt.event.ActionEvent;
30  
31  import javax.swing.JOptionPane;
32  
33  import org.sigtec.graphix.widget.BasicAction;
34  import org.ximtec.igesture.geco.gui.MainView;
35  import org.ximtec.igesture.geco.util.Constant;
36  import org.ximtec.igesture.geco.util.GuiBundleTool;
37  
38  
39  /**
40   * Action for creating a new gesture mapping project.
41   * 
42   * @version 0.9, Nov 2007
43   * @author Michele Croci, mcroci@gmail.com
44   * @author Beat Signer, signer@inf.ethz.ch
45   */
46  public class NewProjectAction extends BasicAction {
47  
48     /**
49      * The key used to retrieve action details from the resource bundle.
50      */
51     public static final String KEY = "NewProjectAction";
52  
53     private MainView mainView;
54  
55  
56     public NewProjectAction(MainView mainView) {
57        super(KEY, GuiBundleTool.getBundle());
58        this.mainView = mainView;
59     }
60  
61  
62     /**
63      * Creates a new mapping.
64      * 
65      * @param event the action event.
66      */
67     public void actionPerformed(ActionEvent event) {
68        // display save dialog, if needed
69  
70        if (mainView.getModel().needSave()) {
71           int n = JOptionPane.showConfirmDialog(mainView,
72                 Constant.SAVE_DIALOG_TITLE, Constant.EMPTY_STRING,
73                 JOptionPane.YES_NO_OPTION);
74  
75           if (n == 0) {
76              (new SaveProjectAction(mainView)).save();
77           }
78  
79        }
80  
81        // display new project dialog
82        mainView.getComponentHandler().getNewProjectDialog().showDialog();
83     } // actionPerformed
84  
85  }