001: /*
002: * $RCSfile: ProductStepDirectoryPanel.java,v $
003: * @modification $Date: 2002/06/04 09:39:57 $
004: * @version $Id: ProductStepDirectoryPanel.java,v 1.2 2002/06/04 09:39:57 deniger Exp $
005: *
006: */
007:
008: package com.memoire.vainstall.builder.gui;
009:
010: import com.memoire.vainstall.VAGlobals;
011: import com.memoire.vainstall.builder.*;
012:
013: import java.awt.*;
014: import java.awt.event.*;
015:
016: import javax.swing.*;
017: import javax.swing.border.*;
018:
019: /**
020: * This panel is shown in the product dialog
021: *
022: * This is not just a view panel because it has a reference to the
023: * VAIProductModel.
024: *
025: *
026: * @see com.memoire.vainstall.builder.gui.VAIProductInternalFrame
027: * @see javax.swing.JPanel
028: *
029: * @author Henrik Falk
030: * @version $Id: ProductStepDirectoryPanel.java,v 1.2 2002/06/04 09:39:57 deniger Exp $
031: */
032: public class ProductStepDirectoryPanel extends JPanel implements
033: FocusListener {
034:
035: private VAIProductModel model;
036:
037: private final static Border loweredBorder = new SoftBevelBorder(
038: BevelBorder.LOWERED);
039:
040: RequiredTextField defaultInstallationField;
041:
042: public ProductStepDirectoryPanel() {
043:
044: setBorder(loweredBorder);
045:
046: GridBagLayout layout = new GridBagLayout();
047: setLayout(layout);
048:
049: GridBagConstraints contraint = new GridBagConstraints();
050:
051: /*
052: # Destination path by default (can be redefined at install time)
053: # This is ignored if "vainstall.destination.installMode" is not "install".
054: # Predefined macros or drive letters can be used in leading brackets:
055: # HOME=platform-specific home dir
056: # PROGRAM=platform-specific program files location:
057: # ("C:\Program Files" under Windows or "/usr/local" under Unix)
058: # C: -> "C:" drive under Windows, "/" under Unix
059: vainstall.destination.defaultPath=[HOME]hellotest
060: */
061:
062: // Description
063: JLabel decriptionLabel = new JLabel();
064: decriptionLabel.setBorder(BorderFactory
065: .createTitledBorder("Description"));
066: decriptionLabel
067: .setText("Destination path by default (can be redefined at install time).");
068: contraint.fill = GridBagConstraints.BOTH;
069: contraint.insets = new Insets(16, 16, 0, 16);
070: contraint.anchor = GridBagConstraints.WEST;
071: contraint.gridx = 0;
072: contraint.gridy = 0;
073: contraint.gridwidth = 2;
074: contraint.gridheight = 1;
075: contraint.weightx = 1;
076: contraint.weighty = 0;
077: layout.setConstraints(decriptionLabel, contraint);
078: add(decriptionLabel);
079:
080: // Title
081: JLabel defaultInstallationLabel = new JLabel();
082: defaultInstallationLabel
083: .setText("Default installation Directory:");
084: contraint.fill = GridBagConstraints.BOTH;
085: contraint.insets = new Insets(16, 16, 0, 16);
086: contraint.anchor = GridBagConstraints.WEST;
087: contraint.gridx = 0;
088: contraint.gridy = 1;
089: contraint.gridwidth = 1;
090: contraint.gridheight = 1;
091: contraint.weightx = 0;
092: contraint.weighty = 0;
093: layout.setConstraints(defaultInstallationLabel, contraint);
094: add(defaultInstallationLabel);
095:
096: defaultInstallationField = new RequiredTextField();
097: contraint.fill = GridBagConstraints.HORIZONTAL;
098: contraint.insets = new Insets(16, 16, 0, 16);
099: contraint.anchor = GridBagConstraints.CENTER;
100: contraint.gridx = 1;
101: contraint.gridy = 1;
102: contraint.gridwidth = 1;
103: contraint.gridheight = 1;
104: contraint.weightx = 1;
105: contraint.weighty = 0;
106: layout.setConstraints(defaultInstallationField, contraint);
107: add(defaultInstallationField);
108:
109: JPanel fillPanel = new JPanel();
110: contraint.fill = GridBagConstraints.BOTH;
111: contraint.insets = new Insets(4, 4, 4, 4);
112: contraint.anchor = GridBagConstraints.CENTER;
113: contraint.gridx = 0;
114: contraint.gridy = 2;
115: contraint.gridwidth = 1;
116: contraint.gridheight = 1;
117: contraint.weightx = 0;
118: contraint.weighty = 1;
119: layout.setConstraints(fillPanel, contraint);
120: add(fillPanel);
121:
122: }
123:
124: /**
125: * save
126: */
127: public void save() {
128: }
129:
130: /**
131: * initialize the panel
132: */
133: public void initialize(VAIProductModel model) {
134: this .model = model;
135:
136: defaultInstallationField.addFocusListener(this );
137: defaultInstallationField.initialize(model,
138: "Default Installation Directory");
139:
140: if (model.getProperty("vainstall.installer.default.directory") != null) {
141: defaultInstallationField
142: .setText(model
143: .getProperty("vainstall.installer.default.directory"));
144: }
145:
146: }
147:
148: /**
149: * stop
150: */
151: public void stop() {
152: }
153:
154: public void focusGained(FocusEvent evt) {
155: }
156:
157: public void focusLost(FocusEvent evt) {
158:
159: if (evt.getSource() == defaultInstallationField
160: && defaultInstallationField.hasChanged() == true) {
161: model.putProperty("vainstall.installer.default.directory",
162: defaultInstallationField.getText());
163: defaultInstallationField.setChanged(false);
164: }
165: }
166: }
|