KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > sunresources > wizards > TargetPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * TargetPanel.java
21  *
22  * Created on February 6, 2004, 2:54 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards;
26
27 import org.openide.util.HelpCtx;
28 import org.openide.loaders.TemplateWizard;
29 import org.openide.util.NbBundle;
30
31 import java.awt.Component JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33 import javax.swing.event.ChangeListener JavaDoc;
34
35 import org.netbeans.modules.j2ee.sun.ide.sunresources.beans.ResourceUtils;
36
37 import org.netbeans.modules.j2ee.sun.sunresources.beans.WizardConstants;
38
39 /**
40  *
41  * @author nityad
42  */

43 public class TargetPanel extends ResourceWizardPanel implements WizardConstants{
44     
45     private org.openide.WizardDescriptor.Panel panel;
46     private ResourceConfigHelper helper;
47     
48     /** Creates a new instance of TargetPanel */
49     public TargetPanel(ResourceConfigHelper helper) {
50         this.helper = helper;
51     }
52     
53     public void setPanel(org.openide.WizardDescriptor.Panel panel) {
54         this.panel = panel;
55     }
56     
57     public TargetPanel getPanel() {
58         return this;
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.
65
public Component JavaDoc getComponent() {
66        return panel.getComponent();
67     }
68     
69     public HelpCtx getHelp() {
70       return new HelpCtx("AS_Wiz_Target"); //NOI18N
71
}
72      
73     public boolean isValid() {
74         try{
75             //Fix for bug# 5025573 - Check for invalid file names
76
Component JavaDoc comp[] = ((JPanel JavaDoc)getComponent()).getComponents();
77             JPanel JavaDoc pane = (JPanel JavaDoc)comp[0];
78             Component JavaDoc paneComp[] = pane.getComponents();
79             String JavaDoc targetName = ((javax.swing.JTextField JavaDoc)paneComp[1]).getText();
80             if (targetName != null && targetName.length() != 0 && (! targetName.equals("<default name>"))){
81                if (! ResourceUtils.isFriendlyFilename(targetName))
82                     return false;
83             }
84         }catch(Exception JavaDoc ex){
85         }
86         return panel.isValid();
87     }
88     
89     public synchronized void addChangeListener(ChangeListener JavaDoc listener) {
90         panel.addChangeListener(listener);
91     }
92
93     public synchronized void removeChangeListener(ChangeListener JavaDoc listener) {
94         panel.removeChangeListener(listener);
95     }
96
97     // You can use a settings object to keep track of state.155
98
// Normally the settings object will be the WizardDescriptor,
99
// so you can use WizardDescriptor.getProperty & putProperty
100
// to store information entered by the user.
101
public void readSettings(Object JavaDoc settings) {
102        panel.readSettings(settings);
103     }
104     
105     public void storeSettings(Object JavaDoc settings) {
106         panel.storeSettings(settings);
107     }
108 }
109
Popular Tags