Package org.jvnet.glassfish.comms.netbeans.sip.module.wizards

Source Code of org.jvnet.glassfish.comms.netbeans.sip.module.wizards.ProjectConfigPanel

/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License).  You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html or
* glassfish/bootstrap/legal/CDDLv1.0.txt.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at glassfish/bootstrap/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright (c) Ericsson AB, 2004-2007. All rights reserved.
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
*/

package org.jvnet.glassfish.comms.netbeans.sip.module.wizards;

import java.awt.Component;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.swing.JComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;

final class ProjectConfigPanel implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel {

    private WizardDescriptor wizardDescriptor;
    private ProjectConfigPanelVisual component;
   
    /** Create the wizard panel descriptor. */
    public ProjectConfigPanel() {
        component = null;
    }
   
    public boolean isFinishPanel() {
        return true;
    }

    public Component getComponent() {
        if (component == null) {
            component = new ProjectConfigPanelVisual(this);
        }
        return component;
    }
   
    public HelpCtx getHelp() {
        return new HelpCtx(ProjectConfigPanel.class);
    }
   
    public boolean isValid() {
        return ((ProjectConfigPanelVisual)getComponent()).valid(wizardDescriptor);
    }
   
    private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1);
    public void addChangeListener(ChangeListener l) {
        synchronized (listeners) {
            listeners.add(l);
        }
    }
    public void removeChangeListener(ChangeListener l) {
        synchronized (listeners) {
            listeners.remove(l);
        }
    }
    protected void fireChangeEvent() {
        Iterator it;
        synchronized (listeners) {
            it = new HashSet<ChangeListener>(listeners).iterator();
        }
        ChangeEvent ev = new ChangeEvent(this);
        while (it.hasNext()) {
            ((ChangeListener)it.next()).stateChanged(ev);
        }
    }
   
    public void readSettings(Object settings) {
        wizardDescriptor = (WizardDescriptor) settings;
        ((ProjectConfigPanelVisual)getComponent()).read (wizardDescriptor);
       
        // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
        // this name is used in NewProjectWizard to modify the title
        Object substitute = ((JComponent) component).getClientProperty("NewProjectWizard_Title"); // NOI18N
        if (substitute != null)
            wizardDescriptor.putProperty("NewProjectWizard_Title", substitute); // NOI18N
    }
   
    public void storeSettings(Object settings) {
        WizardDescriptor d = (WizardDescriptor) settings;
        ((ProjectConfigPanelVisual) getComponent()).store(d);
        d.putProperty("NewProjectWizard_Title", null); // NOI18N
    }
   
}
TOP

Related Classes of org.jvnet.glassfish.comms.netbeans.sip.module.wizards.ProjectConfigPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.