KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > builder > gui > ProductStepDirectoryPanel


1 /*
2  * $RCSfile: ProductStepDirectoryPanel.java,v $
3  * @modification $Date: 2002/06/04 09:39:57 $
4  * @version $Id: ProductStepDirectoryPanel.java,v 1.2 2002/06/04 09:39:57 deniger Exp $
5  *
6  */

7
8 package com.memoire.vainstall.builder.gui;
9
10 import com.memoire.vainstall.VAGlobals;
11 import com.memoire.vainstall.builder.*;
12
13 import java.awt.*;
14 import java.awt.event.*;
15
16 import javax.swing.*;
17 import javax.swing.border.*;
18
19 /**
20  * This panel is shown in the product dialog
21  *
22  * This is not just a view panel because it has a reference to the
23  * VAIProductModel.
24  *
25  *
26  * @see com.memoire.vainstall.builder.gui.VAIProductInternalFrame
27  * @see javax.swing.JPanel
28  *
29  * @author Henrik Falk
30  * @version $Id: ProductStepDirectoryPanel.java,v 1.2 2002/06/04 09:39:57 deniger Exp $
31  */

32 public class ProductStepDirectoryPanel extends JPanel implements FocusListener {
33
34     private VAIProductModel model;
35
36     private final static Border loweredBorder = new SoftBevelBorder(BevelBorder.LOWERED);
37
38     RequiredTextField defaultInstallationField;
39
40     public ProductStepDirectoryPanel() {
41
42         setBorder(loweredBorder);
43
44         GridBagLayout layout = new GridBagLayout();
45         setLayout(layout);
46
47         GridBagConstraints contraint=new GridBagConstraints();
48
49 /*
50 # Destination path by default (can be redefined at install time)
51 # This is ignored if "vainstall.destination.installMode" is not "install".
52 # Predefined macros or drive letters can be used in leading brackets:
53 # HOME=platform-specific home dir
54 # PROGRAM=platform-specific program files location:
55 # ("C:\Program Files" under Windows or "/usr/local" under Unix)
56 # C: -> "C:" drive under Windows, "/" under Unix
57 vainstall.destination.defaultPath=[HOME]hellotest
58 */

59
60         // Description
61
JLabel decriptionLabel = new JLabel();
62         decriptionLabel.setBorder(BorderFactory.createTitledBorder("Description"));
63         decriptionLabel.setText("Destination path by default (can be redefined at install time).");
64         contraint.fill = GridBagConstraints.BOTH;
65         contraint.insets = new Insets(16,16,0,16);
66         contraint.anchor = GridBagConstraints.WEST;
67         contraint.gridx = 0;
68         contraint.gridy = 0;
69         contraint.gridwidth = 2;
70         contraint.gridheight = 1;
71         contraint.weightx = 1;
72         contraint.weighty = 0;
73         layout.setConstraints(decriptionLabel,contraint);
74         add(decriptionLabel);
75
76         // Title
77
JLabel defaultInstallationLabel = new JLabel();
78         defaultInstallationLabel.setText("Default installation Directory:");
79         contraint.fill = GridBagConstraints.BOTH;
80         contraint.insets = new Insets(16,16,0,16);
81         contraint.anchor = GridBagConstraints.WEST;
82         contraint.gridx = 0;
83         contraint.gridy = 1;
84         contraint.gridwidth = 1;
85         contraint.gridheight = 1;
86         contraint.weightx = 0;
87         contraint.weighty = 0;
88         layout.setConstraints(defaultInstallationLabel,contraint);
89         add(defaultInstallationLabel);
90
91         defaultInstallationField = new RequiredTextField();
92         contraint.fill = GridBagConstraints.HORIZONTAL;
93         contraint.insets = new Insets(16,16,0,16);
94         contraint.anchor = GridBagConstraints.CENTER;
95         contraint.gridx = 1;
96         contraint.gridy = 1;
97         contraint.gridwidth = 1;
98         contraint.gridheight = 1;
99         contraint.weightx = 1;
100         contraint.weighty = 0;
101         layout.setConstraints(defaultInstallationField,contraint);
102         add(defaultInstallationField);
103
104         JPanel fillPanel = new JPanel();
105         contraint.fill = GridBagConstraints.BOTH;
106         contraint.insets = new Insets(4,4,4,4);
107         contraint.anchor = GridBagConstraints.CENTER;
108         contraint.gridx = 0;
109         contraint.gridy = 2;
110         contraint.gridwidth = 1;
111         contraint.gridheight = 1;
112         contraint.weightx = 0;
113         contraint.weighty = 1;
114         layout.setConstraints(fillPanel,contraint);
115         add(fillPanel);
116
117     }
118
119
120     /**
121      * save
122      */

123     public void save() {
124     }
125
126     /**
127      * initialize the panel
128      */

129     public void initialize(VAIProductModel model) {
130         this.model = model;
131
132         defaultInstallationField.addFocusListener(this);
133         defaultInstallationField.initialize(model,"Default Installation Directory");
134
135         if (model.getProperty("vainstall.installer.default.directory") != null) {
136             defaultInstallationField.setText(model.getProperty("vainstall.installer.default.directory"));
137         }
138
139     }
140
141     /**
142      * stop
143      */

144     public void stop() {
145     }
146
147     public void focusGained(FocusEvent evt) {
148     }
149
150     public void focusLost(FocusEvent evt) {
151
152         if (evt.getSource() == defaultInstallationField && defaultInstallationField.hasChanged() == true) {
153             model.putProperty("vainstall.installer.default.directory",defaultInstallationField.getText());
154             defaultInstallationField.setChanged(false);
155         }
156     }
157 }
158
Popular Tags