01: /*
02: * $RCSfile: AbstractVAIProductNode.java,v $
03: * @modification $Date: 2001/09/28 19:41:42 $
04: * @version $Id: AbstractVAIProductNode.java,v 1.1 2001/09/28 19:41:42 hfalk Exp $
05: *
06: */
07:
08: package com.memoire.vainstall.builder.util;
09:
10: import com.memoire.vainstall.builder.action.AbstractVAIProductAction;
11: import com.memoire.vainstall.builder.VAIProductController;
12: import com.memoire.vainstall.builder.VAIProductModel;
13:
14: import javax.swing.JPopupMenu;
15: import javax.swing.tree.*;
16:
17: /**
18: * This is a abstract node in a tree which is able to perform methods on
19: * a product which is edited.
20: * The class is a kind of base support class for generating tree like
21: * views on the datamodel
22: *
23: * @see com.memoire.vainstall.builder.VAIBuilderController
24: * @see com.memoire.vainstall.builder.VAIBuilderModel
25: * @see com.memoire.vainstall.builder.util.VAINodeInterface
26: * @see javax.swing.tree.DefaultMutableTreeNode
27: *
28: * @author Henrik Falk
29: * @version $Id: AbstractVAIProductNode.java,v 1.1 2001/09/28 19:41:42 hfalk Exp $
30: */
31: public abstract class AbstractVAIProductNode extends
32: DefaultMutableTreeNode implements VAINodeInterface {
33:
34: /**
35: * Keep reference to product controller
36: */
37: VAIProductController controller;
38:
39: /**
40: * Keep reference to product data model
41: */
42: VAIProductModel model;
43:
44: /**
45: * Default constructor
46: */
47: public AbstractVAIProductNode() {
48: super ();
49:
50: // we are the user object due implementation of VAINodeInterface
51: setUserObject(this );
52: }
53:
54: public String toString() {
55: return "";
56: }
57:
58: /**
59: * initialize the node
60: * @param controller VAIProductController
61: */
62: public void initialize(VAIProductController controller) {
63: this .controller = controller;
64: this .model = controller.getModel();
65: }
66:
67: /**
68: * return the product controller
69: * @return the product controller
70: */
71: protected VAIProductController getController() {
72: return controller;
73: }
74:
75: /**
76: * return the product data model
77: * @return the product data model
78: */
79: protected VAIProductModel getModel() {
80: return model;
81: }
82:
83: public abstract JPopupMenu getPopupMenu();
84:
85: protected AbstractVAIProductAction getActionFor(String actionName) {
86: if (controller == null) {
87: return null;
88: }
89: return (AbstractVAIProductAction) getController()
90: .getActionList().get(actionName);
91: }
92:
93: }
|