KickJava   Java API By Example, From Geeks To Geeks.

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


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.Descriptor;
29 import org.enhydra.tool.archive.JarPlan;
30 import org.enhydra.tool.archive.EjbPlan;
31
32 // JDK
33
import java.awt.*;
34 import java.io.File JavaDoc;
35 import javax.swing.*;
36 import java.lang.ref.WeakReference JavaDoc;
37 import java.beans.*;
38
39 //
40
public class ServiceFilePanel extends ArchivePanel {
41     private FilePanel filePanel = null;
42     private GridBagLayout layoutMain = null;
43
44     public ServiceFilePanel() {
45         try {
46             jbInit();
47             pmInit();
48         } catch (Exception JavaDoc ex) {
49             ex.printStackTrace();
50         }
51     }
52
53     public void readPlan(JarPlan plan) throws ArchiveException {
54         Descriptor[] rows = new Descriptor[0];
55         filePanel.setArchivePath(plan.getArchivePath());
56         rows = plan.getDescriptors();
57         filePanel.getDDTableModel().clear();
58         for (int i = 0 ; i < rows.length ; i++ ) {
59            filePanel.getDDTableModel().addDescriptor(rows[i]);
60         }
61         if (rows.length > 0) {
62           filePanel.getDDTable().setRowSelectionInterval(0, 0);
63         }
64     }
65
66     public void writePlan(JarPlan plan) throws ArchiveException {
67         int count = 0;
68         validatePlan();
69         count = filePanel.getDDTableModel().getRowCount();
70         plan.setArchivePath(filePanel.getArchivePath());
71         plan.setDescriptors(filePanel.getDDTableModel().getDescriptors());
72     }
73
74     public void validatePlan() throws ArchiveException {
75         filePanel.validatePlan();
76     }
77
78     public String JavaDoc getPageTitle() {
79         return "Enhydra Service";
80     }
81
82     public String JavaDoc getInstructions() {
83         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
84
85         buf.append("Enter details for the Enhydra service archive.");
86         return buf.toString();
87     }
88
89     protected void preparePanel() {
90         String JavaDoc[] defaultDD = new String JavaDoc[1];
91         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
92
93         buf.append(getWorkingRoot());
94         buf.append(File.separator);
95         buf.append("src");
96         buf.append(File.separator);
97         buf.append("META-INF");
98         buf.append(File.separator);
99         buf.append("enhydra-service.xml");
100         defaultDD[0] = buf.toString();
101         filePanel.setDefaultDD(defaultDD);
102         filePanel.preparePanel();
103     }
104
105     private void pmInit() {
106         filePanel.setExtension("jar");
107     }
108
109     // override ArchivePanel
110
protected void setWizard(ArchiveWizard wizard) {
111       super.setWizard(wizard);
112       filePanel.setWizard(wizard);
113     }
114
115     private void jbInit() throws Exception JavaDoc {
116         filePanel = (FilePanel) Beans.instantiate(getClass().getClassLoader(),
117                                                   FilePanel.class.getName());
118         layoutMain =
119             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
120                                               GridBagLayout.class.getName());
121         this.setLayout(layoutMain);
122         this.add(filePanel,
123                  new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1,
124                                         GridBagConstraints.CENTER,
125                                         GridBagConstraints.BOTH,
126                                         new Insets(0, 0, 0, 0), 0, 0));
127     }
128
129 }
130
Popular Tags