KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $RCSfile: AbstractVAIProductAction.java,v $
3  * @modification $Date: 2001/09/28 19:31:19 $
4  * @version $Id: AbstractVAIProductAction.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.builder.VAIProductController;
11 import com.memoire.vainstall.builder.VAIProductModel;
12 import com.memoire.vainstall.builder.util.AbstractVAIProductNode;
13
14 import javax.swing.AbstractAction JavaDoc;
15 import javax.swing.JTree JavaDoc;
16
17 /**
18  * This is an abstract class that extends the AbstractAction class
19  * with the knowledge of the VAIProductController and VAIProductModel.
20  *
21  * This class is single threaded and subclasses only have to implement
22  * the runnit method.
23  *
24  * @see javax.swing.AbstractAction
25  * @see com.memoire.vainstall.builder.VAIProductController
26  * @see com.memoire.vainstall.builder.VAIProductModel
27  *
28  * @author Henrik Falk
29  * @version $Id: AbstractVAIProductAction.java,v 1.1 2001/09/28 19:31:19 hfalk Exp $
30  */

31 public abstract class AbstractVAIProductAction extends AbstractAction JavaDoc {
32
33     /**
34      * The product controller
35      */

36     VAIProductController controller;
37
38     /**
39      * The product data model
40      */

41     VAIProductModel model;
42
43     /**
44      * Default constructor
45      */

46     public AbstractVAIProductAction() {
47         super();
48     }
49
50     /**
51      * actionPerformed
52      * @param evt java.awt.event.ActionEvent
53      */

54     public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
55         runnit();
56     }
57
58     /**
59      * This method must be implemented by subclasses
60      */

61     public abstract void runnit();
62
63     /**
64      * Initializes this action
65      * @param controller VAIProductController
66      */

67     public void initialize(VAIProductController controller) {
68         this.controller = controller;
69         this.model = controller.getModel();
70     }
71
72     /**
73      * Returns the controller
74      * @return a VAIProductController
75      */

76     protected VAIProductController getController() {
77         return controller;
78     }
79  
80     /**
81      * Returns the model
82      * @return a VAIProductModel
83      */

84     protected VAIProductModel getModel() {
85         return model;
86     }
87
88     protected AbstractVAIProductNode getRootNode() {
89         if (controller == null) {
90             return null;
91         }
92         return controller.getRootNode();
93     }
94
95     protected JTree JavaDoc getTree() {
96         if (controller == null) {
97             return null;
98         }
99         return controller.getFrame().getTree();
100     }
101 }
102
Popular Tags