KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > builder > action > LastOpenProductAction


1 /*
2  * $RCSfile: LastOpenProductAction.java,v $
3  * @modification $Date: 2001/09/28 19:31:19 $
4  * @version $Id: LastOpenProductAction.java,v 1.1 2001/09/28 19:31:19 hfalk Exp $
5  *
6  */

7
8 package com.memoire.vainstall.builder.action;
9
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 JavaDoc;
15 import java.util.Hashtable JavaDoc;
16
17 import javax.swing.JOptionPane JavaDoc;
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 JavaDoc fullName = (String JavaDoc)getModel().getLastOpenedProjectList().get(menuNumber);
56
57         String JavaDoc projectDirectory = fullName.substring(0,fullName.lastIndexOf(File.separator));
58
59         // if product already opened then just get it into focus
60
Hashtable JavaDoc list = getController().getProductControllerList();
61         VAIProductController product = (VAIProductController)list.get(projectDirectory);
62         if (product != null) {
63             try {
64                 product.getFrame().setVisible(true);
65                 product.getFrame().setSelected(true);
66                 product.getFrame().setMaximum(true);
67             } catch(Exception JavaDoc exc) {
68                 exc.printStackTrace();
69                 return;
70             }
71             return;
72         }
73
74         // Open product
75
VAIProductController productController = new VAIProductController();
76         productController.getModel().setProductDirectory(projectDirectory);
77         try {
78             productController.getModel().load();
79         } catch (VAIBuilderException exc) {
80             JOptionPane.showMessageDialog(getController().getFrame(),
81                 exc.getMessageAsHtml(),
82                 VAGlobals.NAME,
83                 JOptionPane.ERROR_MESSAGE);
84             return;
85         }
86         getController().addProduct(projectDirectory,productController);
87
88     }
89
90 }
91
Popular Tags