// Path: node-projects/src/main/java/org/netbeans/modules/nodejs/api/NodeJSPlatformType.java
// public abstract class NodeJSPlatformType implements Comparable<NodeJSPlatformType> {
// 
//     public abstract String name ();
// 
//     public static Collection<? extends NodeJSPlatformType> allTypes () {
//         return Lookup.getDefault().lookupAll( NodeJSPlatformType.class );
//     }
// 
//     public abstract String add ( File f, Map<String, Object> props, String displayName );
// 
//     public abstract NodeJSExecutable find ( String name );
// 
//     public abstract void all ( List<? super NodeJSExecutable> populate );
// 
//     public abstract String displayName ();
// 
//     public boolean canAdd () {
//         return false;
//     }
// 
//     public String add () {
//         throw new UnsupportedOperationException();
//     }
// 
//     public boolean canRemove ( NodeJSExecutable exe ) {
//         return false;
//     }
// 
//     public void remove ( NodeJSExecutable exe ) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public int compareTo ( NodeJSPlatformType t ) {
//         return displayName().compareTo( t.displayName() );
//     }
// 
//     public boolean equals ( Object o ) {
//         return o instanceof NodeJSPlatformType && name().equals( ((NodeJSPlatformType) o).name() );
//     }
// 
//     public int hashCode () {
//         return name().hashCode();
//     }
// 
//     public String toString () {
//         return name();
//     }
// 
//     public List<WizardDescriptor.Panel<WizardDescriptor>> getAddPlatformWizardPages () {
//         return Collections.emptyList();
//     }
// 
//     public static Map<String, Object> toJson ( File outFile ) throws IOException {
//         FileObject fo = FileUtil.toFileObject( FileUtil.normalizeFile( outFile ) );
//         Map<String, Object> m = ObjectMapperProvider.newObjectMapper().readValue( fo.asText(), STRING_OBJECT_MAP);
//         return m;
//     }
// }


import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.event.ChangeListener;
import org.netbeans.modules.nodejs.api.NodeJSPlatformType;
import org.openide.WizardDescriptor;
import org.openide.util.ChangeSupport;
import org.openide.util.HelpCtx;
/* Copyright (C) 2014 Tim Boudreau

 Permission is hereby granted, free of charge, to any person obtaining a copy 
 of this software and associated documentation files (the "Software"), to 
 deal in the Software without restriction, including without limitation the 
 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
 sell copies of the Software, and to permit persons to whom the Software is 
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all 
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
package org.netbeans.modules.nodejs.platform.wizard;


public class ChoosePlatformPanel implements WizardDescriptor.Panel<WizardDescriptor>, PropertyChangeListener {
    private final ChangeSupport supp = new ChangeSupport( this );
    /**
     * The visual component that displays this panel. If you need to access the
     * component from this class, just use getComponent().
     */
    private ChoosePlatformVisualPanel component;

    // Get the visual component for the panel. In this template, the component
    // is kept separate. This can be more efficient: if the wizard is created
    // but never displayed, or not all panels are displayed, it is better to
    // create only those which really need to be visible.
    @Override
    public ChoosePlatformVisualPanel getComponent () {
        if (component == null) {
            component = new ChoosePlatformVisualPanel();
            component.addPropertyChangeListener( this );
        }
        return component;
    }

    @Override
    public HelpCtx getHelp () {
        // Show no Help button for this panel:
        return HelpCtx.DEFAULT_HELP;
        // If you have context help:
        // return new HelpCtx("help.key.here");
    }

    @Override
    public boolean isValid () {
        // If it is always OK to press Next or Finish, then:
        return component != null && component.getType() != null;
        // If it depends on some condition (form filled out...) and
        // this condition changes (last form field filled in...) then
        // use ChangeSupport to implement add/removeChangeListener below.
        // WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
    }

    @Override
    public void addChangeListener ( ChangeListener l ) {
        supp.addChangeListener( l );
    }

    @Override
    public void removeChangeListener ( ChangeListener l ) {
        supp.removeChangeListener( l );
    }

    @Override
    public void readSettings ( WizardDescriptor wiz ) {
        // use wiz.getProperty to retrieve previous panel state
// Path: node-projects/src/main/java/org/netbeans/modules/nodejs/api/NodeJSPlatformType.java
// public abstract class NodeJSPlatformType implements Comparable<NodeJSPlatformType> {
// 
//     public abstract String name ();
// 
//     public static Collection<? extends NodeJSPlatformType> allTypes () {
//         return Lookup.getDefault().lookupAll( NodeJSPlatformType.class );
//     }
// 
//     public abstract String add ( File f, Map<String, Object> props, String displayName );
// 
//     public abstract NodeJSExecutable find ( String name );
// 
//     public abstract void all ( List<? super NodeJSExecutable> populate );
// 
//     public abstract String displayName ();
// 
//     public boolean canAdd () {
//         return false;
//     }
// 
//     public String add () {
//         throw new UnsupportedOperationException();
//     }
// 
//     public boolean canRemove ( NodeJSExecutable exe ) {
//         return false;
//     }
// 
//     public void remove ( NodeJSExecutable exe ) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public int compareTo ( NodeJSPlatformType t ) {
//         return displayName().compareTo( t.displayName() );
//     }
// 
//     public boolean equals ( Object o ) {
//         return o instanceof NodeJSPlatformType && name().equals( ((NodeJSPlatformType) o).name() );
//     }
// 
//     public int hashCode () {
//         return name().hashCode();
//     }
// 
//     public String toString () {
//         return name();
//     }
// 
//     public List<WizardDescriptor.Panel<WizardDescriptor>> getAddPlatformWizardPages () {
//         return Collections.emptyList();
//     }
// 
//     public static Map<String, Object> toJson ( File outFile ) throws IOException {
//         FileObject fo = FileUtil.toFileObject( FileUtil.normalizeFile( outFile ) );
//         Map<String, Object> m = ObjectMapperProvider.newObjectMapper().readValue( fo.asText(), STRING_OBJECT_MAP);
//         return m;
//     }
// }


// Path: node-projects/src/main/java/org/netbeans/modules/nodejs/platform/wizard/ChoosePlatformPanel.java
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.event.ChangeListener;
import org.netbeans.modules.nodejs.api.NodeJSPlatformType;
import org.openide.WizardDescriptor;
import org.openide.util.ChangeSupport;
import org.openide.util.HelpCtx;

/* Copyright (C) 2014 Tim Boudreau

 Permission is hereby granted, free of charge, to any person obtaining a copy 
 of this software and associated documentation files (the "Software"), to 
 deal in the Software without restriction, including without limitation the 
 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
 sell copies of the Software, and to permit persons to whom the Software is 
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all 
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
package org.netbeans.modules.nodejs.platform.wizard;


public class ChoosePlatformPanel implements WizardDescriptor.Panel<WizardDescriptor>, PropertyChangeListener {
    private final ChangeSupport supp = new ChangeSupport( this );
    /**
     * The visual component that displays this panel. If you need to access the
     * component from this class, just use getComponent().
     */
    private ChoosePlatformVisualPanel component;

    // Get the visual component for the panel. In this template, the component
    // is kept separate. This can be more efficient: if the wizard is created
    // but never displayed, or not all panels are displayed, it is better to
    // create only those which really need to be visible.
    @Override
    public ChoosePlatformVisualPanel getComponent () {
        if (component == null) {
            component = new ChoosePlatformVisualPanel();
            component.addPropertyChangeListener( this );
        }
        return component;
    }

    @Override
    public HelpCtx getHelp () {
        // Show no Help button for this panel:
        return HelpCtx.DEFAULT_HELP;
        // If you have context help:
        // return new HelpCtx("help.key.here");
    }

    @Override
    public boolean isValid () {
        // If it is always OK to press Next or Finish, then:
        return component != null && component.getType() != null;
        // If it depends on some condition (form filled out...) and
        // this condition changes (last form field filled in...) then
        // use ChangeSupport to implement add/removeChangeListener below.
        // WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
    }

    @Override
    public void addChangeListener ( ChangeListener l ) {
        supp.addChangeListener( l );
    }

    @Override
    public void removeChangeListener ( ChangeListener l ) {
        supp.removeChangeListener( l );
    }

    @Override
    public void readSettings ( WizardDescriptor wiz ) {
        // use wiz.getProperty to retrieve previous panel state
        getComponent().setType( (NodeJSPlatformType) wiz.getProperty( "type" ) );