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
27 package org.ximtec.igesture.tool.view.testbench.action;
28
29 import java.awt.event.ActionEvent;
30
31 import javax.swing.tree.TreePath;
32
33 import org.ximtec.igesture.algorithm.Algorithm;
34 import org.ximtec.igesture.algorithm.AlgorithmFactory;
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.view.testbench.wrapper.AlgorithmWrapper;
40
41
42
43
44
45
46
47 public class AddConfigurationAction extends TreePathAction {
48
49 public AddConfigurationAction(Controller controller, TreePath treePath) {
50 super(GestureConstants.CONFIGURATION_ADD, controller, treePath);
51 }
52
53
54 @Override
55 public void actionPerformed(ActionEvent arg0) {
56
57 AlgorithmWrapper algorithWrapper = (AlgorithmWrapper)getTreePath()
58 .getLastPathComponent();
59 Configuration configuration = new Configuration();
60 String algorithmName = algorithWrapper.getAlgorithm().getName();
61 Algorithm algorithm = AlgorithmFactory
62 .createAlgorithmInstance(algorithmName);
63
64 configuration.addAlgorithm(algorithmName);
65
66 for (Enum< ? > e : algorithm.getConfigParameters()) {
67 configuration.addParameter(algorithmName, e.name(), algorithm
68 .getDefaultParameterValue(e.name()));
69 }
70
71 algorithWrapper.addConfiguration(configuration);
72
73
74
75 }
76
77 }