~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to scripting/php/webproject/src/org/netbeans/modules/php/project/wizards/ProviderSpecificPanel.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
3
 *
 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
5
 *
 
6
 * The contents of this file are subject to the terms of either the GNU
 
7
 * General Public License Version 2 only ("GPL") or the Common
 
8
 * Development and Distribution License("CDDL") (collectively, the
 
9
 * "License"). You may not use this file except in compliance with the
 
10
 * License. You can obtain a copy of the License at
 
11
 * http://www.netbeans.org/cddl-gplv2.html
 
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 
13
 * specific language governing permissions and limitations under the
 
14
 * License.  When distributing the software, include this License Header
 
15
 * Notice in each file and include the License file at
 
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 
17
 * particular file as subject to the "Classpath" exception as provided
 
18
 * by Sun in the GPL Version 2 section of the License file that
 
19
 * accompanied this code. If applicable, add the following below the
 
20
 * License Header, with the fields enclosed by brackets [] replaced by
 
21
 * your own identifying information:
 
22
 * "Portions Copyrighted [year] [name of copyright owner]"
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
26
 * The Original Software is NetBeans. The Initial Developer of the Original
 
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
 
28
 * Microsystems, Inc. All Rights Reserved.
 
29
 *
 
30
 * If you wish your version of this file to be governed by only the CDDL
 
31
 * or only the GPL Version 2, indicate your decision by adding
 
32
 * "[Contributor] elects to include this software in this distribution
 
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 
34
 * single choice of license, a recipient has the option to distribute
 
35
 * your version of this file under either the CDDL, the GPL Version 2 or
 
36
 * to extend the choice of license to its licensees as provided above.
 
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 
38
 * Version 2 license, then the option applies only if the new code is
 
39
 * made subject to such option by the copyright holder.
 
40
 */
 
41
package org.netbeans.modules.php.project.wizards;
 
42
 
 
43
import java.awt.Component;
 
44
import java.util.Collection;
 
45
import java.util.LinkedList;
 
46
 
 
47
import javax.swing.event.ChangeEvent;
 
48
import javax.swing.event.ChangeListener;
 
49
 
 
50
import org.openide.WizardDescriptor;
 
51
import org.openide.WizardDescriptor.FinishablePanel;
 
52
import org.openide.WizardDescriptor.Panel;
 
53
import org.openide.util.HelpCtx;
 
54
import org.openide.util.NbBundle;
 
55
 
 
56
 
 
57
/**
 
58
 * @author ads
 
59
 *
 
60
 */
 
61
final class ProviderSpecificPanel implements Panel, FinishablePanel {
 
62
    
 
63
    ProviderSpecificPanel() {
 
64
        init( );
 
65
    }
 
66
        
 
67
    /* (non-Javadoc)
 
68
     * @see org.openide.WizardDescriptor.Panel#addChangeListener(javax.swing.event.ChangeListener)
 
69
     */
 
70
    public void addChangeListener( ChangeListener listener ) {
 
71
        synchronized ( myListeners ) {
 
72
            myListeners.add(listener);
 
73
        }
 
74
    }
 
75
 
 
76
    /* (non-Javadoc)
 
77
     * @see org.openide.WizardDescriptor.Panel#removeChangeListener(javax.swing.event.ChangeListener)
 
78
     */
 
79
    public void removeChangeListener( ChangeListener listener ) {
 
80
        synchronized ( myListeners ) {
 
81
            myListeners.remove(listener);
 
82
        }
 
83
    }
 
84
 
 
85
    /* (non-Javadoc)
 
86
     * @see org.openide.WizardDescriptor.Panel#getComponent()
 
87
     */
 
88
    public Component getComponent() {
 
89
        return myComponent;
 
90
    }
 
91
 
 
92
    /* (non-Javadoc)
 
93
     * @see org.openide.WizardDescriptor.Panel#getHelp()
 
94
     */
 
95
    public HelpCtx getHelp() {
 
96
        return new HelpCtx( ProviderSpecificPanel.class );
 
97
    }
 
98
 
 
99
    /* (non-Javadoc)
 
100
     * @see org.openide.WizardDescriptor.Panel#isValid()
 
101
     */
 
102
    public boolean isValid() {
 
103
        return getVisual().dataIsValid( getDescriptor() );
 
104
    }
 
105
 
 
106
    /* (non-Javadoc)
 
107
     * @see org.openide.WizardDescriptor.Panel#readSettings(java.lang.Object)
 
108
     */
 
109
    public void readSettings( Object settings ) {
 
110
        myDescriptor = (WizardDescriptor) settings;
 
111
        
 
112
        getVisual().read ( getDescriptor() );
 
113
        
 
114
        /*
 
115
         * Copied from Make project configuration panel
 
116
         */
 
117
        // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
 
118
        // this name is used in NewProjectWizard to modify the title
 
119
        Object substitute = getVisual().getClientProperty(
 
120
                PhpConfigureProjectVisual.NEW_PROJECT_WIZARD_TITLE);
 
121
        if (substitute != null) {
 
122
            getDescriptor().putProperty(
 
123
                    PhpConfigureProjectVisual.NEW_PROJECT_WIZARD_TITLE, substitute);
 
124
        }
 
125
    }
 
126
 
 
127
    /* (non-Javadoc)
 
128
     * @see org.openide.WizardDescriptor.Panel#storeSettings(java.lang.Object)
 
129
     */
 
130
    public void storeSettings( Object settings ) {
 
131
        WizardDescriptor descriptor = (WizardDescriptor) settings;
 
132
        getVisual().store(descriptor);
 
133
        ((WizardDescriptor) descriptor).putProperty(
 
134
                PhpConfigureProjectVisual.NEW_PROJECT_WIZARD_TITLE, null); 
 
135
    }
 
136
    
 
137
    /* (non-Javadoc)
 
138
     * @see org.openide.WizardDescriptor.FinishablePanel#isFinishPanel()
 
139
     */
 
140
    public boolean isFinishPanel() {
 
141
        return true;
 
142
    }
 
143
    
 
144
    final void fireChangeEvent() {
 
145
        ChangeListener[] listeners;
 
146
        synchronized ( myListeners) {
 
147
            listeners = myListeners.toArray( 
 
148
                    new ChangeListener[ myListeners.size() ] );
 
149
        }
 
150
        ChangeEvent event = new ChangeEvent(this);
 
151
        for (ChangeListener listener : listeners) {
 
152
            listener.stateChanged(event);
 
153
        }
 
154
    }
 
155
    
 
156
    private ProviderPanelVisual getVisual() {
 
157
        return myComponent;
 
158
    }
 
159
    
 
160
    private WizardDescriptor getDescriptor() {
 
161
        return myDescriptor;
 
162
    }
 
163
    
 
164
    private void init( ) {
 
165
        myComponent = new ProviderPanelVisual( this );
 
166
        
 
167
        /*String[] initialSteps = getDescriptor().getInitialSteps();
 
168
        String[] steps = new String[initialSteps.length + 1];
 
169
        System.arraycopy(initialSteps, 0, steps, 0, initialSteps.length);
 
170
        steps[initialSteps.length] = AddHostWizard.ELIPSIS;
 
171
        getVisual().putClientProperty( AddHostWizard.PROP_CONTENT_DATA, steps);
 
172
 
 
173
        getVisual().putClientProperty(AddHostWizard.SELECTED_INDEX, 0);*/
 
174
        
 
175
        /*
 
176
         * Provide a name of the step in the title bar.
 
177
         */
 
178
        getVisual().setName(NbBundle.getBundle( NewPhpProjectWizardIterator.class).
 
179
                getString( NewPhpProjectWizardIterator.STEP_EXECUTION));
 
180
    }
 
181
 
 
182
 
 
183
    private ProviderPanelVisual myComponent;
 
184
    
 
185
    private final Collection<ChangeListener> myListeners = 
 
186
        new LinkedList<ChangeListener>();
 
187
    
 
188
    private WizardDescriptor myDescriptor;
 
189
    
 
190
}