View Javadoc

1   /*
2    * @(#)$Id: AddSampleAction.java 788 2010-03-27 16:58:03Z bpuype $
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.testset.action;
28  
29  import java.awt.event.ActionEvent;
30  
31  import org.ximtec.igesture.core.Gesture;
32  import org.ximtec.igesture.core.TestClass;
33  import org.ximtec.igesture.io.GestureDevice;
34  import org.ximtec.igesture.tool.GestureConstants;
35  import org.ximtec.igesture.tool.core.Controller;
36  import org.ximtec.igesture.tool.core.LocateableAction;
37  import org.ximtec.igesture.tool.service.SwingMouseReaderService;
38  
39  
40  public class AddSampleAction extends LocateableAction {
41  
42     private TestClass testClass;
43     private Controller controller;
44     
45     private GestureDevice<?,?> gestureDevice;
46  
47     public AddSampleAction(Controller controller, TestClass descriptor, GestureDevice<?, ?> device) {
48        super(GestureConstants.GESTURE_SAMPLE_ADD, controller.getLocator());
49        this.controller = controller;
50        this.testClass = descriptor;
51        this.gestureDevice = device;
52     }
53  
54  
55     @Override
56     public void actionPerformed(ActionEvent action) {
57        
58  //      GestureDevice<?, ?> gestureDevice = controller.getLocator().getService(
59  //            SwingMouseReaderService.IDENTIFIER, GestureDevice.class);
60  //      
61        if(gestureDevice.getGesture() != null){
62           Gesture<?> gesture = gestureDevice.getGesture();
63           gestureDevice.clear();
64           gesture.setName(testClass.getName());
65           testClass.add(gesture);
66        }
67       
68     }
69  
70  }