/*
    No longer needed -- retained for historical reasons.

    You can now define which menu is installed for which
    install type/component/target directory in JExpress Developer.

    Delete unneeded menus depending on which install type is selected

    Notes:
     1. You should adjust the method "deleteUnusedMenus" to fit your project's configuration.
     2. This class should be entered into the "After uninstaller created" field in the Custom panel.
        Important: Do *not* include this class "After menus added" or "After uninstaller created".
     3. To learn how to create a multiple install type installer, see
        the Tutorial 8 (http://www.denova.com/JExpress/Manual/HowTo/manhow8.html).
     4. You are welcome to adapt this class to meet your needs as long as you
        only use it with the JExpress product

    Copyright (C) 1998-2010 DeNova
    
*/


import javax.swing.JLabel;
import java.awt.BorderLayout;
import com.denova.ui.Fonts;
import com.denova.ui.WizardPanel;
import com.denova.util.PropertyList;
import com.denova.JExpress.Installer.CustomInstaller;
import com.denova.JExpress.Installer.InstallPropertyNames;

public class DeleteMenuItemsPanel extends WizardPanel
                                  implements InstallPropertyNames {

    public DeleteMenuItemsPanel ( PropertyList properties) {

    	// initialize WizardPanel superclass
        super ( properties);

        // let them know what's happening
        setLayout ( new BorderLayout () );
        JLabel notice = new JLabel ( CustomInstaller. getLocalizedString ( "UpdatingVersion" ),
                                     JLabel.CENTER);
        notice.setFont(Fonts.Bold);
    	add(notice);
    }

    /** 
     * Enter the panel. 
     *
     * Do not call this method; only the wizard should call it.
     */
    public synchronized void enter()
    {
        boolean isMultiType = CustomInstaller. multipleFileGroups();

        if ( isMultiType ) {

            String installType = getPropertyList(). getProperty ( InstallType, "" );
            deleteUnusedMenus ( installType );
        }

        // we don't want any user interaction
        // so move them to the next panel automatically
        showNextPanel ();
    }

    public void deleteUnusedMenus ( String installType ) {

        PropertyList menus = getPropertyList (). getPropertyListProperty ( MenusAttributeName );

        // if the user selected this option
        if ( installType. equals ( "Hello World" ) ) {

            // delete menu item
            menus. removeProperty ( "Goodbye World" );

        }

        // if the user selected another option, then
        else if ( installType. equals ( "Goodbye World" ) ) {

            // delete menu item
            menus. removeProperty ( "Hello World" );
        }

        getPropertyList (). setPropertyListProperty ( MenusAttributeName, menus );
    }

    public boolean isNextButtonEnabled () {
        // the Next button is disabled until we've checked the RegisterPanel
	    return false;
	}

}  // DeleteMenuItemsPanel