aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage2.java
blob: 94ddfa1af30389c65111357a33a5db6d72c9e238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * 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.main.contactlist.addcontact;

import javax.swing.event.*;

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

/**
 * The <tt>AddContactWizardPage2</tt> is the second page of the "Add Contact"
 * wizard. Contains the <tt>SelectGroupPanel</tt>, where the user should
 * select the group, where the new contact will be added.
 * 
 * @author Yana Stamcheva
 */
public class AddContactWizardPage2
        implements  WizardPage,
                    CellEditorListener
{
    public static final String IDENTIFIER = "SELECT_GROUP_PANEL";
    
    private final SelectGroupPanel selectGroupPanel;

    private final NewContact newContact;
    
    /**
     * Creates an instance of <tt>AddContactWizardPage2</tt>.
     * @param wizard the parent wizard, where this page is contained
     * @param newContact An object that collects all user choices through the
     * wizard.
     */
    public AddContactWizardPage2(   AddContactWizard wizard, 
                                    NewContact newContact)
    {
        this.newContact = newContact;

        selectGroupPanel = new SelectGroupPanel(wizard, newContact);
    }
    
    /**
     * Implements the <tt>WizardPanelDescriptor</tt> method to return the
     * identifier of the next wizard page.
     */
    public Object getNextPageIdentifier()
    {
        return AddContactWizardPage3.IDENTIFIER;
    }
    
    /**
     * Implements the <tt>WizardPanelDescriptor</tt> method to return the
     * identifier of the previous wizard page.
     */
    public Object getBackPageIdentifier()
    {
        return AddContactWizardPage1.IDENTIFIER;
    }

    /**
     * Before the panel is displayed checks the selections and enables the
     * next button if a checkbox is already selected or disables it if 
     * nothing is selected.
     */
    public void pageShowing()
    {
        selectGroupPanel.setNextButtonAccordingToComboBox();
    }
    
    /**
     * When user canceled editing the next button is enabled or disabled
     * depending on if the user has selected a check box or not.
     */
    public void editingCanceled(ChangeEvent e)
    {
        selectGroupPanel.setNextButtonAccordingToComboBox();
    }

    /**
     * When user stopped editing the next button is enabled or disabled
     * depending on if the user has selected a check box or not.
     */
    public void editingStopped(ChangeEvent e)
    {
        selectGroupPanel.setNextButtonAccordingToComboBox();
    }

    public Object getIdentifier()
    {
        return IDENTIFIER;
    }

    public Object getWizardForm()
    {
        return selectGroupPanel;
    }

    public void pageHiding()
    {
    }

    public void pageShown()
    {
    }

    public void commitPage()
    {
        this.newContact.setGroup(selectGroupPanel.getSelectedGroup());
    }

    public void pageBack()
    {
    }
}