KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.enhydra.tool.common.PathHandle;
31
32 // JDK
33
import java.awt.*;
34 import java.beans.Beans JavaDoc;
35 import java.io.File JavaDoc;
36 import java.util.ArrayList JavaDoc;
37 import java.util.Arrays JavaDoc;
38 import javax.swing.*;
39
40 //
41
public class EnterpriseModulePanel extends ArchivePanel {
42     private BorderLayout layoutMain = null;
43     private OneColumnFileSelector selectorPanel = null;
44
45     public EnterpriseModulePanel() {
46         try {
47             jbInit();
48             pmInit();
49         } catch (Exception JavaDoc ex) {
50             ex.printStackTrace();
51         }
52     }
53
54     public void readPlan(JarPlan plan) throws ArchiveException {
55         selectorPanel.setSelections(plan.getLibFiles());
56         if (plan instanceof EarPlan) {
57             EarPlan ep = (EarPlan) plan;
58             selectorPanel.setSelections(ep.getEnterpriseModules());
59         }
60     }
61
62     public void writePlan(JarPlan plan) throws ArchiveException {
63         ArrayList JavaDoc listEar = new ArrayList JavaDoc();
64         ArrayList JavaDoc listEjb = new ArrayList JavaDoc();
65
66         if (plan instanceof EarPlan) {
67             EarPlan ep = (EarPlan) plan;
68             ep.setEnterpriseModules(selectorPanel.getSelections());
69         }
70         listEar.clear();
71         listEjb.clear();
72     }
73
74     public void validatePlan() throws ArchiveException {
75
76         // always valid
77
}
78
79     public String JavaDoc getPageTitle() {
80         return "Enterprise Modules";
81     }
82
83     public String JavaDoc getInstructions() {
84         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
85
86         buf.append("Select the enterprise JavaBeans (.jar)");
87         buf.append(" and enterprise applications (.ear) to include in");
88         buf.append(" this enterprise application.");
89         return buf.toString();
90     }
91
92     // override ArchivePanel
93
protected void setWizard(ArchiveWizard wizard) {
94         super.setWizard(wizard);
95         selectorPanel.setWizard(wizard);
96     }
97
98     private void pmInit() {
99         String JavaDoc[] exts = {
100             "jar", "ear"
101         };
102
103         selectorPanel.setExtensions(exts);
104         selectorPanel.setTitle("Enterprise Module");
105     }
106
107     private void jbInit() throws Exception JavaDoc {
108         layoutMain =
109             (BorderLayout) Beans.instantiate(getClass().getClassLoader(),
110                                              BorderLayout.class.getName());
111         selectorPanel =
112             (OneColumnFileSelector) Beans.instantiate(getClass().getClassLoader(),
113                 OneColumnFileSelector.class.getName());
114         this.setLayout(layoutMain);
115         this.add(selectorPanel, BorderLayout.CENTER);
116     }
117
118 }
119
Popular Tags