01: /*
02: * $RCSfile: LastOpenProductAction.java,v $
03: * @modification $Date: 2001/09/28 19:31:19 $
04: * @version $Id: LastOpenProductAction.java,v 1.1 2001/09/28 19:31:19 hfalk Exp $
05: *
06: */
07:
08: package com.memoire.vainstall.builder.action;
09:
10: import com.memoire.vainstall.VAGlobals;
11: import com.memoire.vainstall.builder.*;
12: import com.memoire.vainstall.builder.util.*;
13:
14: import java.io.File;
15: import java.util.Hashtable;
16:
17: import javax.swing.JOptionPane;
18:
19: /**
20: * This class handles the situation in which the user wants to
21: * open one of the last 5 opened projects.
22: *
23: * The numbers are 0-indexed.
24: *
25: * @see com.memoire.vainstall.builder.util.AbstractVAIBuilderAction
26: *
27: * @author Henrik Falk
28: * @version $Id: LastOpenProductAction.java,v 1.1 2001/09/28 19:31:19 hfalk Exp $
29: */
30: public class LastOpenProductAction extends AbstractVAIBuilderAction {
31:
32: private int menuNumber = 0;
33:
34: public LastOpenProductAction() {
35: super ();
36: }
37:
38: /**
39: * Initializes this action
40: * @param controller VAIBuilderController
41: * @param number The 0-indexed number of the last opened project
42: */
43: public void initialize(VAIBuilderController controller, int number) {
44:
45: initialize(controller);
46:
47: menuNumber = number;
48: }
49:
50: /**
51: * Implements the runnit method
52: */
53: public void runnit() {
54:
55: String fullName = (String) getModel()
56: .getLastOpenedProjectList().get(menuNumber);
57:
58: String projectDirectory = fullName.substring(0, fullName
59: .lastIndexOf(File.separator));
60:
61: // if product already opened then just get it into focus
62: Hashtable list = getController().getProductControllerList();
63: VAIProductController product = (VAIProductController) list
64: .get(projectDirectory);
65: if (product != null) {
66: try {
67: product.getFrame().setVisible(true);
68: product.getFrame().setSelected(true);
69: product.getFrame().setMaximum(true);
70: } catch (Exception exc) {
71: exc.printStackTrace();
72: return;
73: }
74: return;
75: }
76:
77: // Open product
78: VAIProductController productController = new VAIProductController();
79: productController.getModel().setProductDirectory(
80: projectDirectory);
81: try {
82: productController.getModel().load();
83: } catch (VAIBuilderException exc) {
84: JOptionPane.showMessageDialog(getController().getFrame(),
85: exc.getMessageAsHtml(), VAGlobals.NAME,
86: JOptionPane.ERROR_MESSAGE);
87: return;
88: }
89: getController().addProduct(projectDirectory, productController);
90:
91: }
92:
93: }
|