KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > archive > wizard > ContentPanel


1
2 package org.enhydra.tool.archive.wizard;
3
4 //
5
import org.enhydra.tool.archive.ArchiveException;
6 import org.enhydra.tool.archive.JarPlan;
7 import org.enhydra.tool.archive.WarPlan;
8 import org.enhydra.tool.common.PathHandle;
9 //
10
import java.awt.*;
11 import java.beans.Beans JavaDoc;
12 import java.io.File JavaDoc;
13 import javax.swing.*;
14
15
16 //
17
public class ContentPanel extends ArchivePanel {
18     private BorderLayout layoutMain = null;
19     private TwoColumnFileSelector selectorPanel = null;
20
21     public ContentPanel() {
22         try {
23             jbInit();
24         } catch (Exception JavaDoc ex) {
25             ex.printStackTrace();
26         }
27     }
28
29     public void validatePlan() throws ArchiveException {
30         selectorPanel.validatePlan();
31     }
32
33     public void readPlan(JarPlan plan) throws ArchiveException {
34       WarPlan wp = (WarPlan) plan;
35       selectorPanel.setRoot(wp.getContentRoot());
36       selectorPanel.setSelections(wp.getContentFileArray());
37     }
38
39     public void writePlan(JarPlan plan) throws ArchiveException {
40       WarPlan wp = (WarPlan) plan;
41       validatePlan();
42       wp.setContentRoot(selectorPanel.getRoot());
43       wp.setContentFiles(selectorPanel.getSelections());
44     }
45
46     public String JavaDoc getPageTitle() {
47       return "Content";
48     }
49
50     protected void preparePanel() {
51       if (selectorPanel.getRootFile() == null) {
52         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
53         PathHandle path = null;
54         buf.append(getWorkingRoot());
55         buf.append(File.separator);
56         buf.append("output/content");
57         path = PathHandle.createPathHandle(buf.toString());
58         if (path.isDirectory()) {
59           selectorPanel.setDefaultSelect(true);
60           selectorPanel.setRoot(path.getPath());
61         }
62       }
63     }
64
65     public String JavaDoc getInstructions() {
66       StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
67       buf.append("Select files to include in content");
68       return buf.toString();
69     }
70
71
72
73     private void jbInit() throws Exception JavaDoc {
74         layoutMain =
75             (BorderLayout) Beans.instantiate(getClass().getClassLoader(),
76                                              BorderLayout.class.getName());
77         selectorPanel =
78             (TwoColumnFileSelector) Beans.instantiate(getClass().getClassLoader(),
79                                              TwoColumnFileSelector.class.getName());
80
81         this.setLayout(layoutMain);
82         this.add(selectorPanel, BorderLayout.CENTER);
83     }
84
85
86
87 }
88
Popular Tags