~ubuntu-branches/ubuntu/quantal/freeguide/quantal

« back to all changes in this revision

Viewing changes to src/program/gui/wizard/PrivacyWizardPanel.java

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2006-09-30 10:14:18 UTC
  • mfrom: (1.2.3 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060930101418-pkilk36yy22nbt3r
Tags: 0.10.4-2
Update the watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  FreeGuide J2
3
 
 *
4
 
 *  Copyright (c) 2001-2004 by Andy Balaam and the FreeGuide contributors
5
 
 *
6
 
 *  freeguide-tv.sourceforge.net
7
 
 *
8
 
 *  Released under the GNU General Public License
9
 
 *  with ABSOLUTELY NO WARRANTY.
10
 
 *
11
 
 *  See the file COPYING for more information.
12
 
 */
13
 
 
14
 
package freeguide.gui.wizard;
15
 
 
16
 
import freeguide.gui.dialogs.*;
17
 
import freeguide.lib.fgspecific.*;
18
 
import java.awt.*;
19
 
import java.awt.event.*;
20
 
import javax.swing.*;
21
 
 
22
 
/**
23
 
 *  A JPanel to go on a FreeGuideWizard to choose the user's privacy
24
 
 * preferences.
25
 
 *
26
 
 *@author     Andy Balaam
27
 
 *@created    5th December 2003
28
 
 *@version    1
29
 
 */
30
 
public class PrivacyWizardPanel extends WizardPanel implements ActionListener {
31
 
 
32
 
    /**
33
 
     *  Create a new PrivacyWizardPanel.
34
 
     *
35
 
     */
36
 
    PrivacyWizardPanel() {
37
 
        super();
38
 
    }
39
 
 
40
 
 
41
 
    /**
42
 
     *  Construct the GUI of this Wizard Panel.
43
 
     */
44
 
    public void construct() {
45
 
 
46
 
        java.awt.GridBagConstraints gridBagConstraints;
47
 
 
48
 
        JPanel midPanel = new JPanel();
49
 
                JPanel bottomPanel = new JPanel();
50
 
        JLabel topLabel = new JLabel();
51
 
        JLabel bottomLabel = new JLabel();
52
 
                JLabel bottomLabel2 = new JLabel();
53
 
                JLabel bottomLabel3 = new JLabel();
54
 
                JButton butMoreInfo = new JButton();
55
 
 
56
 
                nickField = new JTextField();
57
 
                
58
 
        setLayout(new java.awt.GridBagLayout());
59
 
 
60
 
                bottomPanel.setLayout(new java.awt.GridBagLayout());
61
 
                
62
 
        topLabel.setFont(new java.awt.Font("Dialog", 0, 12));
63
 
        topLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
64
 
        topLabel.setText( "Would you like to check for updates when FreeGuide starts?" );
65
 
                gridBagConstraints = new java.awt.GridBagConstraints();
66
 
        gridBagConstraints.gridx = 0;
67
 
        gridBagConstraints.gridy = 0;
68
 
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
69
 
        gridBagConstraints.weighty = 0.3;
70
 
        add( topLabel, gridBagConstraints );
71
 
 
72
 
        midPanel.setLayout(new java.awt.GridBagLayout());
73
 
 
74
 
                noButton = new JRadioButton("No, I'm quite happy with this version.");
75
 
                yesIPButton     = new JRadioButton(
76
 
                        "Yes, and you can show my IP address." );
77
 
                yesNothingButton= new JRadioButton("Yes, but don't show anything .");
78
 
                yesNickButton   = new JRadioButton(
79
 
                        "Yes, and use this nickname for me:" );
80
 
                
81
 
                noButton.setMnemonic(KeyEvent.VK_N);
82
 
                yesIPButton.setMnemonic(KeyEvent.VK_Y);
83
 
                yesNothingButton.setMnemonic(KeyEvent.VK_E);
84
 
                yesNickButton.setMnemonic(KeyEvent.VK_S);
85
 
                
86
 
                butMoreInfo.setMnemonic(KeyEvent.VK_M);
87
 
                
88
 
        ButtonGroup group = new ButtonGroup();
89
 
                group.add(noButton);
90
 
                group.add(yesIPButton);
91
 
                group.add(yesNothingButton);
92
 
                group.add(yesNickButton);
93
 
 
94
 
                noButton.addActionListener(this);
95
 
                yesIPButton.addActionListener(this);
96
 
                yesNothingButton.addActionListener(this);
97
 
                yesNickButton.addActionListener(this);
98
 
 
99
 
        gridBagConstraints = new java.awt.GridBagConstraints();
100
 
        gridBagConstraints.gridx = 0;
101
 
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
102
 
        gridBagConstraints.weightx = 0.9;
103
 
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
104
 
 
105
 
                gridBagConstraints.gridy = 0;
106
 
                midPanel.add(noButton, gridBagConstraints);
107
 
                gridBagConstraints.gridy = 1;
108
 
        midPanel.add(yesIPButton, gridBagConstraints);
109
 
                gridBagConstraints.gridy = 2;
110
 
                midPanel.add(yesNothingButton, gridBagConstraints);
111
 
                gridBagConstraints.gridy = 3;
112
 
                midPanel.add(yesNickButton, gridBagConstraints);
113
 
                
114
 
                gridBagConstraints.gridy = 4;
115
 
                midPanel.add(nickField, gridBagConstraints);
116
 
 
117
 
                gridBagConstraints = new java.awt.GridBagConstraints();
118
 
        gridBagConstraints.gridx = 0;
119
 
        gridBagConstraints.gridy = 1;
120
 
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
121
 
        gridBagConstraints.weighty = 0.4;
122
 
        add( midPanel, gridBagConstraints );
123
 
 
124
 
                bottomLabel.setLayout(new java.awt.GridBagLayout());
125
 
                
126
 
        bottomLabel.setFont(new java.awt.Font("Dialog", 0, 12));
127
 
        bottomLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
128
 
        bottomLabel.setText( "It is useful to us to know how many people" );
129
 
                        
130
 
                bottomLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
131
 
        bottomLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
132
 
        bottomLabel2.setText( " are using FreeGuide,but your information won't" );
133
 
        
134
 
                bottomLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
135
 
        bottomLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
136
 
        bottomLabel3.setText( "be used for anything except counting." );
137
 
                
138
 
                gridBagConstraints = new java.awt.GridBagConstraints();
139
 
        gridBagConstraints.gridx = 0;
140
 
        gridBagConstraints.gridy = 0;
141
 
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
142
 
        bottomPanel.add( bottomLabel, gridBagConstraints );
143
 
                
144
 
                gridBagConstraints.gridy = 1;
145
 
                bottomPanel.add( bottomLabel2, gridBagConstraints );
146
 
                
147
 
                gridBagConstraints.gridy = 2;
148
 
                bottomPanel.add( bottomLabel3, gridBagConstraints );
149
 
                
150
 
                butMoreInfo.setText( "More Info..." );
151
 
                butMoreInfo.addActionListener(
152
 
            new java.awt.event.ActionListener() {
153
 
                public void actionPerformed(java.awt.event.ActionEvent evt) {
154
 
                    moreInfo();
155
 
                }
156
 
            });
157
 
                
158
 
                gridBagConstraints.gridx = 1;
159
 
                gridBagConstraints.gridy = 0;
160
 
                gridBagConstraints.gridheight = 3;
161
 
                gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
162
 
                gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
163
 
                gridBagConstraints.insets = new java.awt.Insets(3, 8, 3, 3);
164
 
                bottomPanel.add( butMoreInfo, gridBagConstraints );
165
 
                
166
 
                gridBagConstraints = new java.awt.GridBagConstraints();
167
 
        gridBagConstraints.gridx = 0;
168
 
        gridBagConstraints.gridy = 2;
169
 
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
170
 
        gridBagConstraints.weighty = 0.3;
171
 
                add( bottomPanel, gridBagConstraints );
172
 
 
173
 
                doEnabling();
174
 
                
175
 
    }
176
 
        
177
 
    // --------------------------------------------
178
 
 
179
 
        public void actionPerformed(ActionEvent e) {
180
 
                
181
 
                doEnabling();
182
 
                
183
 
        }
184
 
        
185
 
        private void doEnabling() {
186
 
                
187
 
                if( yesNickButton.isSelected() ) {
188
 
                        nickField.setEnabled( true );
189
 
                        nickField.setBackground( Color.WHITE );
190
 
                } else {
191
 
                        nickField.setEnabled( false );
192
 
                        nickField.setBackground( Color.LIGHT_GRAY );
193
 
                }
194
 
                
195
 
        }
196
 
        
197
 
        private void moreInfo() {
198
 
                
199
 
                new PrivacyInfoDialog().setVisible( true );
200
 
                
201
 
        }
202
 
        
203
 
    /**
204
 
     *  Description of the Method
205
 
     *
206
 
     *@param  pref  Description of the Parameter
207
 
     */
208
 
    protected void saveToPrefs(FGPreferences pref) {
209
 
        pref.put(configEntry, (String) getBoxValue());
210
 
    }
211
 
 
212
 
 
213
 
    /**
214
 
     *  Description of the Method
215
 
     *
216
 
     *@param  pref  Description of the Parameter
217
 
     */
218
 
    protected void loadFromPrefs(FGPreferences pref) {
219
 
        setBoxValue( pref.get( configEntry, "yes_ip" ) );
220
 
    }
221
 
 
222
 
 
223
 
    // --------------------------------------------
224
 
 
225
 
    /**
226
 
     *  Gets the boxValue attribute of the PrivacyWizardPanel object
227
 
     *
228
 
     *@return    The boxValue value
229
 
     */
230
 
    protected Object getBoxValue() {
231
 
                
232
 
                if( yesIPButton.isSelected() ) {
233
 
                        return "yes_ip";
234
 
                } else if( yesNickButton.isSelected() ) {
235
 
                        return "yes_nick:" + nickField.getText();
236
 
                } else if( yesNothingButton.isSelected() ) {
237
 
                        return "yes_nothing";
238
 
                } else if( noButton.isSelected() ) {
239
 
                        return "no";
240
 
                }               
241
 
 
242
 
                return "";
243
 
                
244
 
    }
245
 
 
246
 
 
247
 
    /**
248
 
     *  Sets the boxValue attribute of the PrivacyWizardPanel object
249
 
     *
250
 
     *@param  val  The new boxValue value
251
 
     */
252
 
    protected void setBoxValue(Object val) {
253
 
        String value = (String)val;
254
 
                
255
 
                if( value.startsWith("yes_nick:") ) {
256
 
                        yesNickButton.setSelected( true );
257
 
                        nickField.setText( value.substring( 9 ) );
258
 
                } else if( value.equals("yes_ip") ) {
259
 
                        yesIPButton.setSelected( true );
260
 
                } else if( value.equals("yes_nothing") ) {
261
 
                        yesNothingButton.setSelected( true );
262
 
                } else if( value.equals("no") ) {
263
 
                        noButton.setSelected( true );
264
 
                }
265
 
        
266
 
                doEnabling();
267
 
        
268
 
    }
269
 
 
270
 
        JRadioButton yesIPButton;
271
 
        JRadioButton yesNickButton;
272
 
        JRadioButton yesNothingButton;
273
 
        JRadioButton noButton;
274
 
        JTextField nickField;
275
 
 
276
 
}
277