001: /*
002: * $RCSfile: ProductLanguagePanel.java,v $
003: * @modification $Date: 2001/09/28 19:35:30 $
004: * @version $Id: ProductLanguagePanel.java,v 1.1 2001/09/28 19:35:30 hfalk 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: import java.util.LinkedList;
016:
017: import javax.swing.*;
018: import javax.swing.border.*;
019:
020: /**
021: * This panel is shown in the product dialog
022: *
023: * This is not just a view panel because it has a reference to the
024: * VAIProductModel.
025: *
026: *
027: * @see com.memoire.vainstall.builder.gui.VAIProductInternalFrame
028: * @see javax.swing.JPanel
029: *
030: * @author Henrik Falk
031: * @version $Id: ProductLanguagePanel.java,v 1.1 2001/09/28 19:35:30 hfalk Exp $
032: */
033: public class ProductLanguagePanel extends JPanel implements
034: FocusListener, ItemListener {
035:
036: private VAIProductModel model;
037:
038: private final static Border loweredBorder = new SoftBevelBorder(
039: BevelBorder.LOWERED);
040:
041: JList languageMultiList;
042: JList languageSingleList;
043:
044: JRadioButton defaultButton;
045: JRadioButton chooseAllButton;
046: JRadioButton chooseBetweenButton;
047: JRadioButton chooseLanguageButton;
048:
049: ButtonGroup buttonGroup;
050:
051: public ProductLanguagePanel() {
052:
053: setBorder(loweredBorder);
054:
055: GridBagLayout layout = new GridBagLayout();
056: setLayout(layout);
057:
058: GridBagConstraints contraint = new GridBagConstraints();
059:
060: defaultButton = new JRadioButton();
061: defaultButton
062: .setText("Default - If language supported use that otherwise English.");
063: contraint.fill = GridBagConstraints.HORIZONTAL;
064: contraint.insets = new Insets(16, 16, 0, 16);
065: contraint.anchor = GridBagConstraints.WEST;
066: contraint.gridx = 0;
067: contraint.gridy = 0;
068: contraint.gridwidth = 1;
069: contraint.gridheight = 1;
070: contraint.weightx = 0;
071: contraint.weighty = 0;
072: layout.setConstraints(defaultButton, contraint);
073: add(defaultButton);
074:
075: chooseLanguageButton = new JRadioButton();
076: chooseLanguageButton
077: .setText("Use one of the supported languages:");
078: contraint.fill = GridBagConstraints.HORIZONTAL;
079: contraint.insets = new Insets(16, 16, 0, 16);
080: contraint.anchor = GridBagConstraints.WEST;
081: contraint.gridx = 0;
082: contraint.gridy = 1;
083: contraint.gridwidth = 1;
084: contraint.gridheight = 1;
085: contraint.weightx = 0;
086: contraint.weighty = 0;
087: layout.setConstraints(chooseLanguageButton, contraint);
088: add(chooseLanguageButton);
089:
090: JScrollPane languageSingleListPane = new JScrollPane();
091: languageSingleListPane
092: .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
093: languageSingleList = new JList(VAGlobals
094: .getAllSupportedLanguages());
095: languageSingleList
096: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
097: languageSingleListPane.getViewport().add(languageSingleList);
098: contraint.fill = GridBagConstraints.HORIZONTAL;
099: contraint.insets = new Insets(16, 16, 0, 16);
100: contraint.anchor = GridBagConstraints.WEST;
101: contraint.gridx = 0;
102: contraint.gridy = 2;
103: contraint.gridwidth = 1;
104: contraint.gridheight = 1;
105: contraint.weightx = 0;
106: contraint.weighty = 0;
107: layout.setConstraints(languageSingleListPane, contraint);
108: add(languageSingleListPane);
109:
110: chooseAllButton = new JRadioButton();
111: chooseAllButton
112: .setText("Choose - Between all supported languages.");
113: contraint.fill = GridBagConstraints.HORIZONTAL;
114: contraint.insets = new Insets(16, 16, 0, 16);
115: contraint.anchor = GridBagConstraints.WEST;
116: contraint.gridx = 0;
117: contraint.gridy = 3;
118: contraint.gridwidth = 1;
119: contraint.gridheight = 1;
120: contraint.weightx = 0;
121: contraint.weighty = 0;
122: layout.setConstraints(chooseAllButton, contraint);
123: add(chooseAllButton);
124:
125: chooseBetweenButton = new JRadioButton();
126: chooseBetweenButton
127: .setText("Choose - Between the supported languages:");
128: contraint.fill = GridBagConstraints.HORIZONTAL;
129: contraint.insets = new Insets(16, 16, 0, 16);
130: contraint.anchor = GridBagConstraints.WEST;
131: contraint.gridx = 0;
132: contraint.gridy = 4;
133: contraint.gridwidth = 1;
134: contraint.gridheight = 1;
135: contraint.weightx = 0;
136: contraint.weighty = 0;
137: layout.setConstraints(chooseBetweenButton, contraint);
138: add(chooseBetweenButton);
139:
140: JScrollPane languageMultiListPane = new JScrollPane();
141: languageMultiListPane
142: .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
143: languageMultiList = new JList(VAGlobals
144: .getAllSupportedLanguages());
145: languageMultiListPane.getViewport().add(languageMultiList);
146: contraint.fill = GridBagConstraints.HORIZONTAL;
147: contraint.insets = new Insets(16, 16, 0, 16);
148: contraint.anchor = GridBagConstraints.WEST;
149: contraint.gridx = 0;
150: contraint.gridy = 5;
151: contraint.gridwidth = 1;
152: contraint.gridheight = 1;
153: contraint.weightx = 0;
154: contraint.weighty = 0;
155: layout.setConstraints(languageMultiListPane, contraint);
156: add(languageMultiListPane);
157:
158: JPanel fillPanel = new JPanel();
159: contraint.fill = GridBagConstraints.BOTH;
160: contraint.insets = new Insets(4, 4, 4, 4);
161: contraint.anchor = GridBagConstraints.CENTER;
162: contraint.gridx = 1;
163: contraint.gridy = 6;
164: contraint.gridwidth = 1;
165: contraint.gridheight = 1;
166: contraint.weightx = 1;
167: contraint.weighty = 1;
168: layout.setConstraints(fillPanel, contraint);
169: add(fillPanel);
170:
171: buttonGroup = new ButtonGroup();
172: buttonGroup.add(defaultButton);
173: buttonGroup.add(chooseAllButton);
174: buttonGroup.add(chooseBetweenButton);
175: buttonGroup.add(chooseLanguageButton);
176:
177: }
178:
179: /**
180: * save
181: */
182: public void save() {
183: }
184:
185: /**
186: * initialize the panel
187: */
188: public void initialize(VAIProductModel model) {
189: this .model = model;
190:
191: languageMultiList.setEnabled(false);
192: languageSingleList.setEnabled(false);
193:
194: defaultButton.addItemListener(this );
195: chooseAllButton.addItemListener(this );
196: chooseBetweenButton.addItemListener(this );
197: chooseLanguageButton.addItemListener(this );
198: }
199:
200: /**
201: * stop
202: */
203: public void stop() {
204: }
205:
206: public void focusGained(FocusEvent evt) {
207: }
208:
209: public void focusLost(FocusEvent evt) {
210: /*
211: if (evt.getSource() == installFileNameField && installFileNameField.hasChanged() == true) {
212: model.setPackageName(installFileNameField.getText());
213: installFileNameField.setChanged(false);
214: }
215: */
216: }
217:
218: public void itemStateChanged(ItemEvent evt) {
219:
220: if (evt.getItem() == defaultButton) {
221: model.getLanguageList().clear();
222: model.addLanguage("default");
223: }
224:
225: if (evt.getItem() == chooseBetweenButton) {
226: model.getLanguageList().clear();
227: if (chooseBetweenButton.isSelected() == true) {
228: languageMultiList.setEnabled(true);
229: } else {
230: languageMultiList.getSelectionModel().clearSelection();
231: languageMultiList.setEnabled(false);
232: }
233: }
234:
235: if (evt.getItem() == chooseAllButton) {
236: model.getLanguageList().clear();
237: }
238:
239: if (evt.getItem() == chooseLanguageButton) {
240: model.getLanguageList().clear();
241: if (chooseLanguageButton.isSelected() == true) {
242: languageSingleList.setEnabled(true);
243: } else {
244: languageSingleList.getSelectionModel().clearSelection();
245: languageSingleList.setEnabled(false);
246: }
247: }
248: }
249: }
|