KickJava   Java API By Example, From Geeks To Geeks.

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


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  * Paul Mahar
22  *
23  */

24 package org.enhydra.tool.archive.wizard;
25
26 // ToolBox
27
import org.enhydra.tool.archive.ArchiveException;
28 import org.enhydra.tool.archive.JarPlan;
29 import org.enhydra.tool.archive.EarPlan;
30
31 // JDK
32
import java.awt.*;
33 import java.beans.Beans JavaDoc;
34 import java.io.File JavaDoc;
35 import javax.swing.*;
36
37 //
38
public class WebAppPanel extends ArchivePanel {
39     private BorderLayout layoutMain = null;
40     private WarSelector selectorPanel = null;
41
42     public WebAppPanel() {
43         try {
44             jbInit();
45             pmInit();
46         } catch (Exception JavaDoc ex) {
47             ex.printStackTrace();
48         }
49     }
50
51     public void readPlan(JarPlan plan) throws ArchiveException {
52         selectorPanel.setSelections(plan.getLibFiles());
53         if (plan instanceof EarPlan) {
54             EarPlan ep = (EarPlan) plan;
55
56             selectorPanel.setWebApplications(ep.getWebApplications());
57         }
58     }
59
60     public void writePlan(JarPlan plan) throws ArchiveException {
61         if (plan instanceof EarPlan) {
62             EarPlan ep = (EarPlan) plan;
63
64             ep.setWebApplications(selectorPanel.getWebApplications());
65         }
66     }
67
68     public void validatePlan() throws ArchiveException {
69         // always valid
70
}
71
72     public String JavaDoc getPageTitle() {
73         return "Web Application Modules";
74     }
75
76     public String JavaDoc getInstructions() {
77         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
78
79         buf.append("Select web applications (.war) to include in this");
80         buf.append(" enterprise application (.ear). You can modify the root");
81         buf.append(" context for each web application.");
82         return buf.toString();
83     }
84
85     // override ArchivePanel
86
protected void setWizard(ArchiveWizard wizard) {
87         super.setWizard(wizard);
88         selectorPanel.setWizard(wizard);
89     }
90
91     private void pmInit() {
92         String JavaDoc[] exts = {
93             "war"
94         };
95
96         selectorPanel.setExtensions(exts);
97         selectorPanel.setTitle("Web Application");
98     }
99
100     private void jbInit() throws Exception JavaDoc {
101         layoutMain =
102             (BorderLayout) Beans.instantiate(getClass().getClassLoader(),
103                                              BorderLayout.class.getName());
104         selectorPanel =
105             (WarSelector) Beans.instantiate(getClass().getClassLoader(),
106                 WarSelector.class.getName());
107         this.setLayout(layoutMain);
108         this.add(selectorPanel, BorderLayout.CENTER);
109     }
110
111 }
112
Popular Tags