KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > wizard > ClassPathListPanel


1 /*
2  * Copyright 2002-2004 Greg Hinkle
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.mc4j.console.connection.wizard;
18
19 import org.mc4j.console.ManagementNode;
20 import org.openide.WizardDescriptor;
21 import org.openide.util.HelpCtx;
22
23 import javax.swing.event.ChangeListener JavaDoc;
24 import java.awt.*;
25 import java.io.File JavaDoc;
26 import java.util.List JavaDoc;
27
28 /**
29  * This panel supports a visual panel for managing a list of files and
30  * directories in a classpath.
31  *
32  * @author Greg Hinkle (ghinkle@users.sourceforge.net), January 2002
33  * @version $Revision: 570 $($Author: ghinkl $ / $Date: 2006-04-12 15:14:16 -0400 (Wed, 12 Apr 2006) $)
34  */

35 public class ClassPathListPanel implements WizardDescriptor.Panel /* .FinishPanel */ {
36
37     /** The visual component that displays this panel.
38      * If you need to access the component from this class,
39      * just use getComponent().
40      */

41     private ClassPathListVisualPanel component;
42
43
44     private ConnectionDescriptor descriptor;
45
46     /** Create the wizard panel descriptor. */
47     public ClassPathListPanel(ConnectionDescriptor descriptor) {
48         this.descriptor = descriptor;
49     }
50
51     /** Create the wizard panel descriptor. */
52     public ClassPathListPanel() {
53     }
54
55     // Get the visual component for the panel. In this template, the component
56
// is kept separate. This can be more efficient: if the wizard is created
57
// but never displayed, or not all panels are displayed, it is better to
58
// create only those which really need to be visible.
59
public Component getComponent() {
60         if (component == null) {
61             component = new ClassPathListVisualPanel(this);
62         }
63         return component;
64     }
65
66     public HelpCtx getHelp() {
67         // Show no Help button for this panel:
68
return HelpCtx.DEFAULT_HELP;
69         // If you have context help:
70
// return new HelpCtx(ClassPathListPanelPanel.class);
71
}
72
73     public boolean isValid() {
74         // If it is always OK to press Next or Finish, then:
75
return true;
76         // If it depends on some condition (form filled out...), then:
77
// return someCondition();
78
// and when this condition changes (last form field filled in...) then:
79
// fireChangeEvent();
80
// and uncomment the complicated stuff below.
81
}
82
83     public final void addChangeListener(ChangeListener JavaDoc l) {}
84     public final void removeChangeListener(ChangeListener JavaDoc l) {}
85     /*
86     private final Set listeners = new HashSet(1); // Set<ChangeListener>
87     public final void addChangeListener(ChangeListener l) {
88         synchronized (listeners) {
89             listeners.add(l);
90         }
91     }
92     public final void removeChangeListener(ChangeListener l) {
93         synchronized (listeners) {
94             listeners.remove(l);
95         }
96     }
97     protected final void fireChangeEvent() {
98         Iterator it;
99         synchronized (listeners) {
100             it = new HashSet(listeners).iterator();
101         }
102         ChangeEvent ev = new ChangeEvent(this);
103         while (it.hasNext()) {
104             ((ChangeListener)it.next()).stateChanged(ev);
105         }
106     }
107      */

108
109     private File JavaDoc[] installedLibraries;
110
111     public File JavaDoc[] getInstalledLibraries() {
112         return ManagementNode.getExtras(descriptor.getSettings().getConnectionType());
113     }
114
115     // You can use a settings object to keep track of state.
116
// Normally the settings object will be the WizardDescriptor,
117
// so you can use WizardDescriptor.getProperty & putProperty
118
// to store information entered by the user.
119
public void readSettings(Object JavaDoc settings) {
120         System.out.println("Reading " + settings.hashCode());
121         if (descriptor.getSettings().getClassPathEntries() != null) {
122             ((ClassPathListVisualPanel)getComponent()).setFileList(descriptor.getSettings().getClassPathEntries());
123         }
124         this.installedLibraries = ManagementNode.getExtras(descriptor.getSettings().getConnectionType());
125     }
126     public void storeSettings(Object JavaDoc settings) {
127
128         List JavaDoc<File JavaDoc> fileList = component.getFileList();
129
130         //System.out.println("Storing the latest libraries");
131
this.descriptor.getSettings().setClassPathEntries(fileList);
132     }
133
134 }
135
Popular Tags