1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package coras.client;
22
23 import java.awt.Cursor;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.KeyEvent;
26
27 import coras.client.ui.CorasFrame;
28 import coras.riskanalysis.RiskAnalysisProject;
29
30 /***
31 * @author fvr
32 *
33 * TODO To change the template for this generated type comment go to
34 * Window - Preferences - Java - Code Style - Code Templates
35 */
36 public class OpenRecentProjectAction extends CorasAction {
37
38 private String projectId;
39
40 public OpenRecentProjectAction(CorasClient client, String projectId, String projectName, int index) {
41 super(client, index + " " + projectName, KeyEvent.VK_0 + index, "Open Project " + projectName, "Open risk analysis project " + projectName);
42 this.projectId = projectId;
43 }
44
45 public void actionPerformed(ActionEvent e) {
46 if (projectId == null) {
47 return;
48 }
49 RiskAnalysisProject project = getClient().getProject();
50 if (project != null && projectId.equals(project.getId())) {
51 return;
52 }
53 if (!getClient().closeProject()) {
54 return;
55 }
56 final CorasFrame mainFrame = getClient().getMainFrame();
57 mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
58 new SwingWorker() {
59 public Object construct() {
60 RiskAnalysisProject newProject = RiskAnalysisProject.getProject(projectId);
61 getClient().setProject(newProject);
62 return null;
63 }
64 public void finished() {
65 mainFrame.setCursor(Cursor.getDefaultCursor());
66 }
67 }.start();
68 }
69
70 }