1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 /*
23  * ParcelPropertiesPanel.java
24  *
25  * Created on January 15, 2003
26  */
27 
28 package org.openoffice.netbeans.modules.office.wizard;
29 
30 import java.awt.Component;
31 import java.net.URL;
32 import java.net.MalformedURLException;
33 import java.util.HashSet;
34 import java.util.Iterator;
35 import java.util.Set;
36 import javax.swing.event.ChangeEvent;
37 import javax.swing.event.ChangeListener;
38 
39 import org.openide.WizardDescriptor;
40 import org.openide.loaders.TemplateWizard;
41 import org.openide.util.HelpCtx;
42 import org.openide.util.NbBundle;
43 
44 /** A single panel descriptor for a wizard.
45  * You probably want to make a wizard iterator to hold it.
46  *
47  * @author tomaso
48  */
49 public class ParcelPropertiesPanel implements WizardDescriptor.FinishPanel {
50 
51     /** The visual component that displays this panel.
52      * If you need to access the component from this class,
53      * just use getComponent().
54      */
55     private ParcelPropertiesVisualPanel component;
56 
57     /** Create the wizard panel descriptor. */
ParcelPropertiesPanel()58     public ParcelPropertiesPanel() {
59     }
60 
61     // Get the visual component for the panel. In this template, the component
62     // is kept separate. This can be more efficient: if the wizard is created
63     // but never displayed, or not all panels are displayed, it is better to
64     // create only those which really need to be visible.
getComponent()65     public Component getComponent() {
66         if (component == null) {
67             component = new ParcelPropertiesVisualPanel(this);
68         }
69         return component;
70     }
71 
getHelp()72     public HelpCtx getHelp() {
73         // Show no Help button for this panel:
74         return HelpCtx.DEFAULT_HELP;
75         // If you have context help:
76         // return new HelpCtx(ParcelPropertiesPanel.class);
77     }
78 
isValid()79     public boolean isValid() {
80         // If it is always OK to press Next or Finish, then:
81         return true;
82         // If it depends on some condition (form filled out...), then:
83         // return someCondition();
84         // and when this condition changes (last form field filled in...) then:
85         // fireChangeEvent();
86         // and uncomment the complicated stuff below.
87     }
88 
addChangeListener(ChangeListener l)89     public final void addChangeListener(ChangeListener l) {}
removeChangeListener(ChangeListener l)90     public final void removeChangeListener(ChangeListener l) {}
91     /*
92     private final Set listeners = new HashSet(1); // Set<ChangeListener>
93     public final void addChangeListener(ChangeListener l) {
94         synchronized (listeners) {
95             listeners.add(l);
96         }
97     }
98     public final void removeChangeListener(ChangeListener l) {
99         synchronized (listeners) {
100             listeners.remove(l);
101         }
102     }
103     protected final void fireChangeEvent() {
104         Iterator it;
105         synchronized (listeners) {
106             it = new HashSet(listeners).iterator();
107         }
108         ChangeEvent ev = new ChangeEvent(this);
109         while (it.hasNext()) {
110             ((ChangeListener)it.next()).stateChanged(ev);
111         }
112     }
113      */
114 
setName(String name)115     public void setName(String name) {
116         this.name = name;
117     }
118 
setLanguage(String language)119     public void setLanguage(String language) {
120         this.language = language;
121     }
122 
123     private String language = "Java";
124     private String name = null;
125 
126     // You can use a settings object to keep track of state.
127     // Normally the settings object will be the WizardDescriptor,
128     // so you can use WizardDescriptor.getProperty & putProperty
129     // to store information entered by the user.
readSettings(Object settings)130     public void readSettings(Object settings) {
131     }
132 
storeSettings(Object settings)133     public void storeSettings(Object settings) {
134         TemplateWizard wiz = (TemplateWizard)settings;
135         wiz.setTargetName(name);
136         wiz.putProperty(ParcelContentsIterator.PROP_LANGUAGE, language);
137     }
138 }
139