<commit_before>/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package net.java.sip.communicator.impl.gui.customcontrols.wizard;

import java.beans.*;
import java.util.*;

import javax.swing.*;

import net.java.sip.communicator.service.gui.*;

/**
 * The model for the Wizard component, which tracks the text, icons, and
 * enabled state of each of the buttons, as well as the current panel that
 * is displayed. Note that the model, in its current form, is not intended
 * to be subclassed.
 * 
 * @author <NAME>
 */


public class WizardModel {

    /**
     * Identification string for the current panel.
     */    
    public static final String CURRENT_PAGE_PROPERTY
        = "currentPageProperty";
    
    /**
     * Property identification String for the Back button's text
     */    
    public static final String BACK_BUTTON_TEXT_PROPERTY
        = "backButtonTextProperty";
    /**
     * Property identification String for the Back button's icon
     */    
    public static final String BACK_BUTTON_ICON_PROPERTY
        = "backButtonIconProperty";
    /**
     * Property identification String for the Back button's enabled state
     */    
    public static final String BACK_BUTTON_ENABLED_PROPERTY
        = "backButtonEnabledProperty";

    /**
     * Property identification String for the Next button's text
     */    
    public static final String NEXT_FINISH_BUTTON_TEXT_PROPERTY
        = "nextButtonTextProperty";
    /**
     * Property identification String for the Next button's icon
     */    
    public static final String NEXT_FINISH_BUTTON_ICON_PROPERTY
        = "nextButtonIconProperty";
    /**
     * Property identification String for the Next button's enabled state
     */    
    public static final String NEXT_FINISH_BUTTON_ENABLED_PROPERTY
        = "nextButtonEnabledProperty";
    
    /**
     * Property identification String for the Cancel button's text
     */    
    public static final String CANCEL_BUTTON_TEXT_PROPERTY
        = "cancelButtonTextProperty";
    /**
     * Property identification String for the Cancel button's icon
     */    
    public static final String CANCEL_BUTTON_ICON_PROPERTY
        = "cancelButtonIconProperty";
    /**
     * Property identification String for the Cancel button's enabled state
     */    
    public static final String CANCEL_BUTTON_ENABLED_PROPERTY
        = "cancelButtonEnabledProperty";
    
    private WizardPage currentPanel;
        
    private HashMap panelHashmap;
    
    private HashMap buttonTextHashmap;
    private HashMap buttonIconHashmap;
    private HashMap buttonEnabledHashmap;
    
    private PropertyChangeSupport propertyChangeSupport;
    
    
    /**
     * Default constructor.
     */    
    public WizardModel() {
        panelHashmap = new HashMap();
        
        buttonTextHashmap = new HashMap();
        buttonIconHashmap = new HashMap();
        buttonEnabledHashmap = new HashMap();
        
        propertyChangeSupport = new PropertyChangeSupport(this);

    }
    
    /**
     * Returns the currently displayed WizardPage.
     * @return The currently displayed WizardPage
     */    
    WizardPage getCurrentWizardPage() {
        return currentPanel;
    }
    
    /**
     * Registers the WizardPage in the model using the
     * Object-identifier specified.
     * @param id Object-based identifier
     * @param page WizardPage that describes the panel
     */    
     void registerPage(Object id, WizardPage page) {
        panelHashmap.put(id, page);
    }
     
     /**
      * Unregisters the <tt>WizardPage</tt> corresponding to the given id.
      * 
      * @param id The id of the <tt>WizardPage</tt>.
      */
    void unregisterPage(Object id) {
        panelHashmap.remove(id);
    }
        
    /**
     * Returns the <tt>WizardPage</tt> corresponding to the given identifier.
     * @param id The identifier of the page.
     * @return the <tt>WizardPage</tt> corresponding to the given identifier.
     */
    WizardPage getWizardPage(Object id) {        
        return (WizardPage)panelHashmap.get(id);
    }
    
    Iterator getAllPages() {
        return panelHashmap.entrySet().iterator();
    }
    
    /**
     * Sets the current panel to that identified by the Object passed in.
     * @param id Object-based panel identifier
     * @return boolean indicating success or failure
     */    
     boolean setCurrentPanel(Object id) {
        //  First, get the hashtable reference to the panel that should
        //  be displayed.
        
        WizardPage nextPanel =
            (WizardPage)panelHashmap.get(id);
        
        
        //  If we couldn't find the panel that should be displayed, return
        //  false.
        
        if (nextPanel == null)
            throw new WizardPanelNotFoundException();   

        WizardPage oldPanel = currentPanel;
        currentPanel = nextPanel;
        
        if (oldPanel != currentPanel) {
            firePropertyChange(CURRENT_PAGE_PROPERTY,
                    oldPanel, currentPanel);
        }        
        return true;        
    }
    
    /**
     * Returns the text for the Back button.
     * @return the text for the Back button.
     */
    Object getBackButtonText() {
        return buttonTextHashmap.get(BACK_BUTTON_TEXT_PROPERTY);<commit_msg>trailing spaces removed<commit_after>/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package net.java.sip.communicator.impl.gui.customcontrols.wizard;

import java.beans.*;
import java.util.*;

import javax.swing.*;

import net.java.sip.communicator.service.gui.*;

/**
 * The model for the Wizard component, which tracks the text, icons, and
 * enabled state of each of the buttons, as well as the current panel that
 * is displayed. Note that the model, in its current form, is not intended
 * to be subclassed.
 * 
 * @author <NAME>
 */


public class WizardModel {

    /**
     * Identification string for the current panel.
     */    
    public static final String CURRENT_PAGE_PROPERTY
        = "currentPageProperty";
    
    /**
     * Property identification String for the Back button's text
     */    
    public static final String BACK_BUTTON_TEXT_PROPERTY
        = "backButtonTextProperty";
    /**
     * Property identification String for the Back button's icon
     */    
    public static final String BACK_BUTTON_ICON_PROPERTY
        = "backButtonIconProperty";
    /**
     * Property identification String for the Back button's enabled state
     */    
    public static final String BACK_BUTTON_ENABLED_PROPERTY
        = "backButtonEnabledProperty";

    /**
     * Property identification String for the Next button's text
     */    
    public static final String NEXT_FINISH_BUTTON_TEXT_PROPERTY
        = "nextButtonTextProperty";
    /**
     * Property identification String for the Next button's icon
     */    
    public static final String NEXT_FINISH_BUTTON_ICON_PROPERTY
        = "nextButtonIconProperty";
    /**
     * Property identification String for the Next button's enabled state
     */    
    public static final String NEXT_FINISH_BUTTON_ENABLED_PROPERTY
        = "nextButtonEnabledProperty";
    
    /**
     * Property identification String for the Cancel button's text
     */    
    public static final String CANCEL_BUTTON_TEXT_PROPERTY
        = "cancelButtonTextProperty";
    /**
     * Property identification String for the Cancel button's icon
     */    
    public static final String CANCEL_BUTTON_ICON_PROPERTY
        = "cancelButtonIconProperty";
    /**
     * Property identification String for the Cancel button's enabled state
     */    
    public static final String CANCEL_BUTTON_ENABLED_PROPERTY
        = "cancelButtonEnabledProperty";
    
    private WizardPage currentPanel;
        
    private HashMap panelHashmap;
    
    private HashMap buttonTextHashmap;
    private HashMap buttonIconHashmap;
    private HashMap buttonEnabledHashmap;
    
    private PropertyChangeSupport propertyChangeSupport;
    
    
    /**
     * Default constructor.
     */    
    public WizardModel() {
        panelHashmap = new HashMap();
        
        buttonTextHashmap = new HashMap();
        buttonIconHashmap = new HashMap();
        buttonEnabledHashmap = new HashMap();
        
        propertyChangeSupport = new PropertyChangeSupport(this);

    }
    
    /**
     * Returns the currently displayed WizardPage.
     * @return The currently displayed WizardPage
     */    
    WizardPage getCurrentWizardPage() {
        return currentPanel;
    }
    
    /**
     * Registers the WizardPage in the model using the
     * Object-identifier specified.
     * @param id Object-based identifier
     * @param page WizardPage that describes the panel
     */    
     void registerPage(Object id, WizardPage page) {
        panelHashmap.put(id, page);
    }
     
     /**
      * Unregisters the <tt>WizardPage</tt> corresponding to the given id.
      * 
      * @param id The id of the <tt>WizardPage</tt>.
      */
    void unregisterPage(Object id) {
        panelHashmap.remove(id);
    }
        
    /**
     * Returns the <tt>WizardPage</tt> corresponding to the given identifier.
     * @param id The identifier of the page.
     * @return the <tt>WizardPage</tt> corresponding to the given identifier.
     */
    WizardPage getWizardPage(Object id) {        
        return (WizardPage)panelHashmap.get(id);
    }
    
    Iterator getAllPages() {
        return panelHashmap.entrySet().iterator();
    }
    
    /**
     * Sets the current panel to that identified by the Object passed in.
     * @param id Object-based panel identifier
     * @return boolean indicating success or failure
     */    
     boolean setCurrentPanel(Object id) {
        //  First, get the hashtable reference to the panel that should
        //  be displayed.
        
        WizardPage nextPanel =
            (WizardPage)panelHashmap.get(id);

        //  If we couldn't find the panel that should be displayed, return
        //  false.
        if (nextPanel == null)
            throw new WizardPanelNotFoundException();

        WizardPage oldPanel = currentPanel;
        currentPanel = nextPanel;
        
        if (oldPanel != currentPanel) {
            firePropertyChange(CURRENT_PAGE_PROPERTY,
                    oldPanel, currentPanel);
        }

        return true;
    }
    
    /**
     * Returns the text for the Back button.
     * @return the text for the Back button.
     */
    Object getBackButtonText() {
        return buttonTextHashmap.get(BACK_BUTTON_TEXT_PROPERTY);
{'fraction_non_alphanumeric': 0.07403988183161005, 'fraction_numerical': 0.0, 'mean_word_length': 2.3260669327602086, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3231202', 'n_tokens_mistral': 2833, 'n_tokens_neox': 2806, 'n_words': 879}