1 package org.ximtec.igesture.tool.view.devicemanager.action;
2
3 import java.awt.event.ActionEvent;
4 import java.io.File;
5
6 import javax.swing.JButton;
7 import javax.swing.JFileChooser;
8
9 import org.sigtec.graphix.widget.BasicAction;
10 import org.ximtec.igesture.tool.GestureConstants;
11 import org.ximtec.igesture.tool.service.GuiBundleService;
12 import org.ximtec.igesture.tool.util.FileType;
13 import org.ximtec.igesture.tool.view.devicemanager.DeviceManagerController;
14
15
16
17
18
19
20 public class LoadDeviceConfigurationAction extends BasicAction {
21
22 private DeviceManagerController controller;
23
24 public LoadDeviceConfigurationAction(DeviceManagerController controller)
25 {
26 super(GestureConstants.LOAD_DEVICE_CONFIGURATION, controller.getLocator().getService(
27 GuiBundleService.IDENTIFIER, GuiBundleService.class));
28 this.controller = controller;
29 }
30
31 @Override
32 public void actionPerformed(ActionEvent e) {
33
34 JFileChooser fileChooser = new JFileChooser();
35 fileChooser.setFileFilter(FileType.deviceConfiguration.getFilter());
36 if(fileChooser.showOpenDialog((JButton) e.getSource()) == JFileChooser.APPROVE_OPTION)
37 {
38 File selectedFile = fileChooser.getSelectedFile();
39
40 if (selectedFile != null) {
41 controller.loadConfiguration(selectedFile);
42 }
43 }
44
45 }
46
47 }