KickJava   Java API By Example, From Geeks To Geeks.

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


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
25 package org.enhydra.tool.archive.wizard;
26
27 //
28
import org.enhydra.tool.archive.ArchiveException;
29 import org.enhydra.tool.archive.ClassFilter;
30 import org.enhydra.tool.archive.JarPlan;
31 import org.enhydra.tool.archive.WarPlan;
32 import org.enhydra.tool.common.PathHandle;
33
34 //
35
import java.awt.*;
36 import java.beans.Beans JavaDoc;
37 import java.io.File JavaDoc;
38 import java.lang.ref.WeakReference JavaDoc;
39 import javax.swing.*;
40
41 //
42
public class ClassesPanel extends ArchivePanel {
43     private BorderLayout layoutMain = null;
44     private TwoColumnFileSelector selectorPanel = null;
45
46     public ClassesPanel() {
47         try {
48             jbInit();
49             pmInit();
50         } catch (Exception JavaDoc ex) {
51             ex.printStackTrace();
52         }
53     }
54
55     public void validatePlan() throws ArchiveException {
56         selectorPanel.validatePlan();
57     }
58
59     public void readPlan(JarPlan plan) throws ArchiveException {
60         selectorPanel.setRoot(plan.getClassRoot());
61         selectorPanel.setSelections(plan.getClassFileArray());
62     }
63
64     public void writePlan(JarPlan plan) throws ArchiveException {
65         validatePlan();
66         plan.setClassRoot(selectorPanel.getRoot());
67         plan.setClassFiles(selectorPanel.getSelections());
68     }
69
70     public String JavaDoc getPageTitle() {
71         return "Classes";
72     }
73
74     public String JavaDoc getInstructions() {
75         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
76
77         buf.append("Select files to include in classes");
78         return buf.toString();
79     }
80
81     protected void preparePanel() {
82         if (selectorPanel.getRootFile() == null) {
83             StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
84             PathHandle path = null;
85
86             buf.append(getWorkingRoot());
87             buf.append(File.separator);
88             buf.append("classes");
89             path = PathHandle.createPathHandle(buf.toString());
90             if (path.isDirectory()) {
91                 selectorPanel.setDefaultSelect(true);
92             } else {
93                 selectorPanel.setDefaultSelect(false);
94                 path = PathHandle.createPathHandle(getWorkingRoot());
95             }
96             if (path.isDirectory()) {
97                 selectorPanel.setRoot(path.getPath());
98             }
99         }
100     }
101
102     private void pmInit() {
103         selectorPanel.setFilter(new ClassFilter());
104     }
105
106     private void jbInit() throws Exception JavaDoc {
107         layoutMain =
108             (BorderLayout) Beans.instantiate(getClass().getClassLoader(),
109                                              BorderLayout.class.getName());
110         selectorPanel =
111             (TwoColumnFileSelector) Beans.instantiate(getClass().getClassLoader(),
112                 TwoColumnFileSelector.class.getName());
113         this.setLayout(layoutMain);
114         this.add(selectorPanel, BorderLayout.CENTER);
115     }
116
117 }
118
Popular Tags