KickJava   Java API By Example, From Geeks To Geeks.

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


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 //
27
import org.enhydra.tool.archive.ArchiveException;
28 import org.enhydra.tool.archive.JarPlan;
29
30 //
31
import java.awt.*;
32 import java.io.File JavaDoc;
33 import javax.swing.*;
34 import java.beans.*;
35 import java.lang.ref.WeakReference JavaDoc;
36 import javax.swing.border.*;
37
38 //
39
public class E3FilePanel extends ArchivePanel {
40     private FilePanel filePanel = null;
41     private GridBagLayout layoutMain = null;
42     private JPanel panelApp = null;
43     private GridBagLayout layoutApp = null;
44     private JTextArea textNote = null;
45
46     public E3FilePanel() {
47         try {
48             jbInit();
49             pmInit();
50         } catch (Exception JavaDoc ex) {
51             ex.printStackTrace();
52         }
53     }
54
55     public void readPlan(JarPlan plan) throws ArchiveException {
56         filePanel.setArchivePath(plan.getArchivePath());
57         filePanel.getDDTableModel().clear();
58         filePanel.getDDTable().setVisible(false);
59     }
60
61     public void writePlan(JarPlan plan) throws ArchiveException {
62         validatePlan();
63         plan.setArchivePath(filePanel.getArchivePath());
64     }
65
66     public void validatePlan() throws ArchiveException {
67         filePanel.validatePlan();
68     }
69
70     public String JavaDoc getPageTitle() {
71         return "Enhydra Application";
72     }
73
74     public String JavaDoc getInstructions() {
75         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
76
77         buf.append("Enter archive name for your Enhydra super servlet.");
78         return buf.toString();
79     }
80
81     // override ArchivePanel
82
protected void setWizardRef(ArchiveWizard wizard) {
83       super.setWizard(wizard);
84       filePanel.setWizard(wizard);
85     }
86
87     protected void preparePanel() {
88         String JavaDoc[] defaultDD = new String JavaDoc[0];
89         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
90
91         filePanel.setDefaultDD(defaultDD);
92         filePanel.preparePanel();
93     }
94
95     private void pmInit() {
96         filePanel.setExtension("jar");
97     }
98
99     private void jbInit() throws Exception JavaDoc {
100         filePanel = (FilePanel) Beans.instantiate(getClass().getClassLoader(),
101                                                   FilePanel.class.getName());
102         layoutMain =
103             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
104                                               GridBagLayout.class.getName());
105         panelApp = (JPanel) Beans.instantiate(getClass().getClassLoader(),
106                                               JPanel.class.getName());
107         layoutApp =
108             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
109                                               GridBagLayout.class.getName());
110         textNote = (JTextArea) Beans.instantiate(getClass().getClassLoader(),
111                                                  JTextArea.class.getName());
112
113         textNote.setWrapStyleWord(true);
114         textNote.setLineWrap(true);
115         textNote.setEnabled(false);
116         textNote.setText("Super servlet archives do not support deployment descriptors. You "
117                          + "will need to deploy a seperate configuration file with the super "
118                          + "servlet archive.");
119         textNote.setAutoscrolls(false);
120         textNote.setDisabledTextColor(UIManager.getColor("Label.foreground"));
121         textNote.setBackground(UIManager.getColor("Label.background"));
122         textNote.setEditable(false);
123         textNote.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
124         panelApp.setLayout(layoutApp);
125         panelApp.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(new Color(187, 218, 252), new Color(91, 107, 123)),
126                                             "Deployment"));
127         panelApp.add(textNote,
128                      new GridBagConstraints(0, 0, 1, 3, 0.4, 0.4,
129                                             GridBagConstraints.CENTER,
130                                             GridBagConstraints.BOTH,
131                                             new Insets(10, 10, 10, 10), 10,
132                                             10));
133         this.setLayout(layoutMain);
134         this.add(filePanel,
135                  new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1,
136                                         GridBagConstraints.CENTER,
137                                         GridBagConstraints.BOTH,
138                                         new Insets(0, 0, 0, 0), 0, 0));
139         this.add(panelApp,
140                  new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1,
141                                         GridBagConstraints.CENTER,
142                                         GridBagConstraints.BOTH,
143                                         new Insets(5, 5, 5, 5), 0, 0));
144     }
145
146 }
147
Popular Tags