001: /*
002: * $RCSfile: ProductTargetPanel.java,v $
003: * @modification $Date: 2002/12/16 13:23:45 $
004: * @version $Id: ProductTargetPanel.java,v 1.2 2002/12/16 13:23:45 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: ProductTargetPanel.java,v 1.2 2002/12/16 13:23:45 deniger Exp $
031: */
032: public class ProductTargetPanel extends JPanel implements
033: FocusListener, ItemListener {
034:
035: private VAIProductModel model;
036:
037: private final static Border loweredBorder = new SoftBevelBorder(
038: BevelBorder.LOWERED);
039:
040: JCheckBox javaBox;
041:
042: JCheckBox jarBox;
043: JTextField jarSignerAliasField;
044: JTextField jarSignerPassphraseField;
045:
046: JCheckBox jnlpBox;
047: JTextField jnlpCodebaseField;
048: JTextField jnlpHomepageField;
049: JTextField jnlpVendorField;
050:
051: JCheckBox unixBox;
052: JCheckBox linuxi386Box;
053: JCheckBox win95Box;
054:
055: public ProductTargetPanel() {
056:
057: setBorder(loweredBorder);
058:
059: GridBagLayout layout = new GridBagLayout();
060: setLayout(layout);
061:
062: GridBagConstraints contraint = new GridBagConstraints();
063: /*
064:
065: # targets: java, jar, jnlp, unix, linux-i386, win95 (comma separated)
066: vainstall.destination.targets=unix,win95,java
067:
068: # Jar Section
069: vainstall.jarsigner.alias=desnoix
070: #vainstall.jarsigner.passphrase=
071:
072: # Jnlp Section
073: vainstall.jnlp.codebase=http://localhost/app/
074: vainstall.jnlp.homepage=http://localhost/
075: vainstall.jnlp.vendor=MyName
076: */
077:
078: JLabel targetLabel = new JLabel();
079: targetLabel
080: .setText("Select targets that VAInstall should build:");
081: contraint.fill = GridBagConstraints.NONE;
082: contraint.insets = new Insets(16, 16, 0, 16);
083: contraint.anchor = GridBagConstraints.WEST;
084: contraint.gridx = 0;
085: contraint.gridy = 0;
086: contraint.gridwidth = 2;
087: contraint.gridheight = 1;
088: contraint.weightx = 0;
089: contraint.weighty = 0;
090: layout.setConstraints(targetLabel, contraint);
091: add(targetLabel);
092:
093: javaBox = new JCheckBox();
094: javaBox.setText("Java. (*.class)");
095: contraint.fill = GridBagConstraints.NONE;
096: contraint.insets = new Insets(16, 32, 0, 16);
097: contraint.anchor = GridBagConstraints.WEST;
098: contraint.gridx = 0;
099: contraint.gridy = 1;
100: contraint.gridwidth = 1;
101: contraint.gridheight = 1;
102: contraint.weightx = 0;
103: contraint.weighty = 0;
104: layout.setConstraints(javaBox, contraint);
105: add(javaBox);
106:
107: jarBox = new JCheckBox();
108: jarBox.setText("Jar. (*.jar)");
109: contraint.fill = GridBagConstraints.NONE;
110: contraint.insets = new Insets(4, 32, 0, 16);
111: contraint.anchor = GridBagConstraints.WEST;
112: contraint.gridx = 0;
113: contraint.gridy = 2;
114: contraint.gridwidth = 1;
115: contraint.gridheight = 1;
116: contraint.weightx = 0;
117: contraint.weighty = 0;
118: layout.setConstraints(jarBox, contraint);
119: add(jarBox);
120:
121: // Jar stuff
122: JLabel jarSignerAliasLabel = new JLabel();
123: jarSignerAliasLabel.setText("Jar Signer Alias:");
124: contraint.fill = GridBagConstraints.NONE;
125: contraint.insets = new Insets(4, 64, 0, 16);
126: contraint.anchor = GridBagConstraints.EAST;
127: contraint.gridx = 0;
128: contraint.gridy = 3;
129: contraint.gridwidth = 1;
130: contraint.gridheight = 1;
131: contraint.weightx = 0;
132: contraint.weighty = 0;
133: layout.setConstraints(jarSignerAliasLabel, contraint);
134: add(jarSignerAliasLabel);
135:
136: jarSignerAliasField = new JTextField();
137: jarSignerAliasField.setEditable(false);
138: contraint.fill = GridBagConstraints.HORIZONTAL;
139: contraint.insets = new Insets(4, 64, 0, 16);
140: contraint.anchor = GridBagConstraints.WEST;
141: contraint.gridx = 1;
142: contraint.gridy = 3;
143: contraint.gridwidth = 1;
144: contraint.gridheight = 1;
145: contraint.weightx = 1;
146: contraint.weighty = 0;
147: layout.setConstraints(jarSignerAliasField, contraint);
148: add(jarSignerAliasField);
149:
150: JLabel jarSignerPassphraseLabel = new JLabel();
151: jarSignerPassphraseLabel.setText("Jar Signer Passphrase:");
152: contraint.fill = GridBagConstraints.NONE;
153: contraint.insets = new Insets(4, 64, 0, 16);
154: contraint.anchor = GridBagConstraints.EAST;
155: contraint.gridx = 0;
156: contraint.gridy = 4;
157: contraint.gridwidth = 1;
158: contraint.gridheight = 1;
159: contraint.weightx = 0;
160: contraint.weighty = 0;
161: layout.setConstraints(jarSignerPassphraseLabel, contraint);
162: add(jarSignerPassphraseLabel);
163:
164: jarSignerPassphraseField = new JTextField();
165: jarSignerPassphraseField.setEditable(false);
166: contraint.fill = GridBagConstraints.HORIZONTAL;
167: contraint.insets = new Insets(4, 64, 0, 16);
168: contraint.anchor = GridBagConstraints.WEST;
169: contraint.gridx = 1;
170: contraint.gridy = 4;
171: contraint.gridwidth = 1;
172: contraint.gridheight = 1;
173: contraint.weightx = 1;
174: contraint.weighty = 0;
175: layout.setConstraints(jarSignerPassphraseField, contraint);
176: add(jarSignerPassphraseField);
177:
178: jnlpBox = new JCheckBox();
179: jnlpBox.setText("Jnlp. (*.jnlp)");
180: contraint.fill = GridBagConstraints.NONE;
181: contraint.insets = new Insets(4, 32, 0, 16);
182: contraint.anchor = GridBagConstraints.WEST;
183: contraint.gridx = 0;
184: contraint.gridy = 5;
185: contraint.gridwidth = 1;
186: contraint.gridheight = 1;
187: contraint.weightx = 0;
188: contraint.weighty = 0;
189: layout.setConstraints(jnlpBox, contraint);
190: add(jnlpBox);
191:
192: // Jnlp stuff
193: JLabel jnlpCodebaseLabel = new JLabel();
194: jnlpCodebaseLabel.setText("Jnlp Codebase:");
195: contraint.fill = GridBagConstraints.NONE;
196: contraint.insets = new Insets(4, 64, 0, 16);
197: contraint.anchor = GridBagConstraints.EAST;
198: contraint.gridx = 0;
199: contraint.gridy = 6;
200: contraint.gridwidth = 1;
201: contraint.gridheight = 1;
202: contraint.weightx = 0;
203: contraint.weighty = 0;
204: layout.setConstraints(jnlpCodebaseLabel, contraint);
205: add(jnlpCodebaseLabel);
206:
207: jnlpCodebaseField = new JTextField();
208: jnlpCodebaseField.setEditable(false);
209: contraint.fill = GridBagConstraints.HORIZONTAL;
210: contraint.insets = new Insets(4, 64, 0, 16);
211: contraint.anchor = GridBagConstraints.WEST;
212: contraint.gridx = 1;
213: contraint.gridy = 6;
214: contraint.gridwidth = 1;
215: contraint.gridheight = 1;
216: contraint.weightx = 1;
217: contraint.weighty = 0;
218: layout.setConstraints(jnlpCodebaseField, contraint);
219: add(jnlpCodebaseField);
220:
221: JLabel jnlpHomepageLabel = new JLabel();
222: jnlpHomepageLabel.setText("Jnlp Homepage:");
223: contraint.fill = GridBagConstraints.NONE;
224: contraint.insets = new Insets(4, 64, 0, 16);
225: contraint.anchor = GridBagConstraints.EAST;
226: contraint.gridx = 0;
227: contraint.gridy = 7;
228: contraint.gridwidth = 1;
229: contraint.gridheight = 1;
230: contraint.weightx = 0;
231: contraint.weighty = 0;
232: layout.setConstraints(jnlpHomepageLabel, contraint);
233: add(jnlpHomepageLabel);
234:
235: jnlpHomepageField = new JTextField();
236: jnlpHomepageField.setEditable(false);
237: contraint.fill = GridBagConstraints.HORIZONTAL;
238: contraint.insets = new Insets(4, 64, 0, 16);
239: contraint.anchor = GridBagConstraints.WEST;
240: contraint.gridx = 1;
241: contraint.gridy = 7;
242: contraint.gridwidth = 1;
243: contraint.gridheight = 1;
244: contraint.weightx = 1;
245: contraint.weighty = 0;
246: layout.setConstraints(jnlpHomepageField, contraint);
247: add(jnlpHomepageField);
248:
249: JLabel jnlpVendorLabel = new JLabel();
250: jnlpVendorLabel.setText("Jnlp Vendor:");
251: contraint.fill = GridBagConstraints.NONE;
252: contraint.insets = new Insets(4, 64, 0, 16);
253: contraint.anchor = GridBagConstraints.EAST;
254: contraint.gridx = 0;
255: contraint.gridy = 8;
256: contraint.gridwidth = 1;
257: contraint.gridheight = 1;
258: contraint.weightx = 0;
259: contraint.weighty = 0;
260: layout.setConstraints(jnlpVendorLabel, contraint);
261: add(jnlpVendorLabel);
262:
263: jnlpVendorField = new JTextField();
264: jnlpVendorField.setEditable(false);
265: contraint.fill = GridBagConstraints.HORIZONTAL;
266: contraint.insets = new Insets(4, 64, 0, 16);
267: contraint.anchor = GridBagConstraints.WEST;
268: contraint.gridx = 1;
269: contraint.gridy = 8;
270: contraint.gridwidth = 1;
271: contraint.gridheight = 1;
272: contraint.weightx = 1;
273: contraint.weighty = 0;
274: layout.setConstraints(jnlpVendorField, contraint);
275: add(jnlpVendorField);
276:
277: unixBox = new JCheckBox();
278: unixBox.setText("Unix. (*.sh)");
279: contraint.fill = GridBagConstraints.NONE;
280: contraint.insets = new Insets(4, 32, 0, 16);
281: contraint.anchor = GridBagConstraints.WEST;
282: contraint.gridx = 0;
283: contraint.gridy = 9;
284: contraint.gridwidth = 1;
285: contraint.gridheight = 1;
286: contraint.weightx = 0;
287: contraint.weighty = 0;
288: layout.setConstraints(unixBox, contraint);
289: add(unixBox);
290:
291: linuxi386Box = new JCheckBox();
292: linuxi386Box.setText("Linux - i386. (*.lin)");
293: contraint.fill = GridBagConstraints.NONE;
294: contraint.insets = new Insets(4, 32, 0, 16);
295: contraint.anchor = GridBagConstraints.WEST;
296: contraint.gridx = 0;
297: contraint.gridy = 10;
298: contraint.gridwidth = 1;
299: contraint.gridheight = 1;
300: contraint.weightx = 0;
301: contraint.weighty = 0;
302: layout.setConstraints(linuxi386Box, contraint);
303: add(linuxi386Box);
304:
305: win95Box = new JCheckBox();
306: win95Box.setText("Windows - 95. (*.exe)");
307: contraint.fill = GridBagConstraints.NONE;
308: contraint.insets = new Insets(4, 32, 0, 16);
309: contraint.anchor = GridBagConstraints.WEST;
310: contraint.gridx = 0;
311: contraint.gridy = 11;
312: contraint.gridwidth = 1;
313: contraint.gridheight = 1;
314: contraint.weightx = 0;
315: contraint.weighty = 0;
316: layout.setConstraints(win95Box, contraint);
317: add(win95Box);
318:
319: JPanel fillPanel = new JPanel();
320: contraint.fill = GridBagConstraints.BOTH;
321: contraint.insets = new Insets(4, 4, 4, 4);
322: contraint.anchor = GridBagConstraints.CENTER;
323: contraint.gridx = 0;
324: contraint.gridy = 12;
325: contraint.gridwidth = 1;
326: contraint.gridheight = 1;
327: contraint.weightx = 0;
328: contraint.weighty = 1;
329: layout.setConstraints(fillPanel, contraint);
330: add(fillPanel);
331:
332: }
333:
334: /**
335: * save
336: */
337: public void save() {
338: }
339:
340: /**
341: * initialize the panel
342: */
343: public void initialize(VAIProductModel model) {
344: this .model = model;
345:
346: if (model.getTargetList().contains("java") == true) {
347: javaBox.setSelected(true);
348: }
349:
350: if (model.getTargetList().contains("jar") == true) {
351: jarBox.setSelected(true);
352: if (model
353: .getProperty("vainstall.archiver.target.jar.signer.alias") != null) {
354: jarSignerAliasField
355: .setText(model
356: .getProperty("vainstall.archiver.target.jar.signer.alias"));
357: }
358: if (model
359: .getProperty("vainstall.archiver.target.jar.signer.passphrase") != null) {
360: jarSignerPassphraseField
361: .setText(model
362: .getProperty("vainstall.archiver.target.jar.signer.passphrase"));
363: }
364:
365: jarSignerAliasField.setEditable(true);
366: jarSignerPassphraseField.setEditable(true);
367: }
368:
369: if (model.getTargetList().contains("jnlp") == true) {
370: jnlpBox.setSelected(true);
371:
372: if (model
373: .getProperty("vainstall.archiver.target.jnlp.codebase") != null) {
374: jnlpCodebaseField
375: .setText(model
376: .getProperty("vainstall.archiver.target.jnlp.codebase"));
377: }
378: if (model
379: .getProperty("vainstall.archiver.target.jnlp.homepage") != null) {
380: jnlpHomepageField
381: .setText(model
382: .getProperty("vainstall.archiver.target.jnlp.homepage"));
383: }
384: if (model
385: .getProperty("vainstall.archiver.target.jnlp.vendor") != null) {
386: jnlpVendorField
387: .setText(model
388: .getProperty("vainstall.archiver.target.jnlp.vendor"));
389: }
390:
391: jnlpCodebaseField.setEditable(true);
392: jnlpHomepageField.setEditable(true);
393: jnlpVendorField.setEditable(true);
394: }
395:
396: if (model.getTargetList().contains("unix") == true) {
397: unixBox.setSelected(true);
398: }
399:
400: if (model.getTargetList().contains("linux-i386") == true) {
401: linuxi386Box.setSelected(true);
402: }
403:
404: if (model.getTargetList().contains("win95") == true) {
405: win95Box.setSelected(true);
406: }
407:
408: javaBox.addItemListener(this );
409: jarBox.addItemListener(this );
410: jnlpBox.addItemListener(this );
411: unixBox.addItemListener(this );
412: linuxi386Box.addItemListener(this );
413: win95Box.addItemListener(this );
414:
415: jarSignerPassphraseField.addFocusListener(this );
416: jarSignerAliasField.addFocusListener(this );
417: jnlpHomepageField.addFocusListener(this );
418: jnlpVendorField.addFocusListener(this );
419: jnlpCodebaseField.addFocusListener(this );
420:
421: }
422:
423: /**
424: * stop
425: */
426: public void stop() {
427: }
428:
429: public void focusGained(FocusEvent evt) {
430: }
431:
432: public void focusLost(FocusEvent evt) {
433:
434: if (evt.getSource() == jarSignerPassphraseField) {
435: model.putProperty(
436: "vainstall.archiver.target.jar.signer.passphrase",
437: jarSignerPassphraseField.getText());
438: }
439:
440: if (evt.getSource() == jarSignerAliasField) {
441: model.putProperty(
442: "vainstall.archiver.target.jar.signer.alias",
443: jarSignerAliasField.getText());
444: }
445:
446: if (evt.getSource() == jnlpHomepageField) {
447: model.putProperty(
448: "vainstall.archiver.target.jnlp.codebase",
449: jnlpHomepageField.getText());
450: }
451:
452: if (evt.getSource() == jnlpVendorField) {
453: model.putProperty(
454: "vainstall.archiver.target.jnlp.homepage",
455: jnlpVendorField.getText());
456: }
457:
458: if (evt.getSource() == jnlpCodebaseField) {
459: model.putProperty("vainstall.archiver.target.jnlp.vendor",
460: jnlpCodebaseField.getText());
461: }
462: }
463:
464: public void itemStateChanged(ItemEvent evt) {
465:
466: if (evt.getItem() == javaBox) {
467: if (javaBox.isSelected() == true) {
468: model.addTarget("java");
469: } else {
470: model.removeTarget("java");
471: }
472: }
473:
474: if (evt.getItem() == jarBox) {
475: if (jarBox.isSelected() == true) {
476: jarSignerPassphraseField.setEditable(true);
477: jarSignerAliasField.setEditable(true);
478: jarSignerAliasField.requestFocus();
479:
480: model.addTarget("jar");
481: } else {
482: jarSignerAliasField.setText("");
483: jarSignerAliasField.setEditable(false);
484: jarSignerPassphraseField.setText("");
485: jarSignerPassphraseField.setEditable(false);
486:
487: model.removeTarget("jar");
488: model
489: .removeProperty("vainstall.archiver.target.jar.signer.alias");
490: model
491: .removeProperty("vainstall.archiver.target.jar.signer.passphrase");
492: }
493: }
494:
495: if (evt.getItem() == jnlpBox) {
496: if (jnlpBox.isSelected() == true) {
497: jnlpHomepageField.setEditable(true);
498: jnlpVendorField.setEditable(true);
499: jnlpCodebaseField.setEditable(true);
500: jnlpCodebaseField.requestFocus();
501:
502: model.addTarget("jnlp");
503: } else {
504: jnlpHomepageField.setEditable(false);
505: jnlpHomepageField.setText("");
506: jnlpVendorField.setEditable(false);
507: jnlpVendorField.setText("");
508: jnlpCodebaseField.setEditable(false);
509: jnlpCodebaseField.setText("");
510:
511: model.removeTarget("jnlp");
512: model
513: .removeProperty("vainstall.archiver.target.jnlp.codebase");
514: model
515: .removeProperty("vainstall.archiver.target.jnlp.homepage");
516: model
517: .removeProperty("vainstall.archiver.target.jnlp.vendor");
518: }
519: }
520:
521: if (evt.getItem() == unixBox) {
522: if (unixBox.isSelected() == true) {
523: model.addTarget("unix");
524: } else {
525: model.removeTarget("unix");
526: }
527: }
528:
529: if (evt.getItem() == linuxi386Box) {
530: if (linuxi386Box.isSelected() == true) {
531: model.addTarget("linux-i386");
532: } else {
533: model.removeTarget("linux-i386");
534: }
535: }
536:
537: if (evt.getItem() == win95Box) {
538: if (win95Box.isSelected() == true) {
539: model.addTarget("win95");
540: } else {
541: model.removeTarget("win95");
542: }
543: }
544:
545: }
546: }
|