KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > preferences > TeamPreferencePage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.preferences;
12
13 import org.eclipse.jface.dialogs.Dialog;
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.preference.PreferencePage;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.layout.GridData;
18 import org.eclipse.swt.layout.GridLayout;
19 import org.eclipse.swt.widgets.*;
20 import org.eclipse.team.internal.ui.*;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPreferencePage;
23 import org.eclipse.ui.help.WorkbenchHelp;
24
25 public class TeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
26     Button syncModeButton;
27     
28     public TeamPreferencePage() {
29         setDescription(Policy.bind("TeamPreferencePage.General_settings_for_Team_support_1")); //$NON-NLS-1$
30
}
31     
32     /**
33      * @see PreferencePage#createContents(Composite)
34      */

35     protected Control createContents(Composite parent) {
36         Composite composite = new Composite(parent, SWT.NULL);
37
38         // set F1 help
39
WorkbenchHelp.setHelp(composite, IHelpContextIds.TEAM_PREFERENCE_PAGE);
40         
41         // GridLayout
42
GridLayout layout = new GridLayout();
43         layout.numColumns = 1;
44         layout.marginWidth = 0;
45         layout.marginHeight = 0;
46         composite.setLayout(layout);
47
48         // GridData
49
GridData data = new GridData();
50         data.verticalAlignment = GridData.FILL;
51         data.horizontalAlignment = GridData.FILL;
52         composite.setLayoutData(data);
53             
54         // Create the checkbox for sync mode
55
syncModeButton = createCheckBox(composite, Policy.bind("TeamPreferencePage.&Use_Incoming/Outgoing_mode_when_synchronizing_2")); //$NON-NLS-1$
56

57         initializeValues();
58         Dialog.applyDialogFont(parent);
59         return composite;
60     }
61     /**
62      * Creates an new checkbox instance and sets the default
63      * layout data.
64      *
65      * @param group the composite in which to create the checkbox
66      * @param label the string to set into the checkbox
67      * @return the new checkbox
68      */

69     private Button createCheckBox(Composite group, String JavaDoc label) {
70         Button button = new Button(group, SWT.CHECK | SWT.LEFT);
71         button.setText(label);
72         GridData data = new GridData();
73         data.horizontalSpan = 1;
74         button.setLayoutData(data);
75         return button;
76     }
77     /**
78      * Returns preference store that belongs to the our plugin.
79      * This is important because we want to store
80      * our preferences separately from the desktop.
81      *
82      * @return the preference store for this plugin
83      */

84     protected IPreferenceStore doGetPreferenceStore() {
85         return TeamUIPlugin.getPlugin().getPreferenceStore();
86     }
87     /**
88      * Defaults was clicked. Restore the CVS preferences to
89      * their default values
90      */

91     protected void performDefaults() {
92         super.performDefaults();
93         IPreferenceStore store = getPreferenceStore();
94         //syncModeButton.setSelection(store.getDefaultBoolean(ISharedImages.PREF_ALWAYS_IN_INCOMING_OUTGOING));
95
}
96     /**
97      * OK was clicked. Store the CVS preferences.
98      *
99      * @return whether it is okay to close the preference page
100      */

101     public boolean performOk() {
102         IPreferenceStore store = getPreferenceStore();
103         //store.setValue(ISharedImages.PREF_ALWAYS_IN_INCOMING_OUTGOING, syncModeButton.getSelection());
104
TeamUIPlugin.getPlugin().savePluginPreferences();
105         return true;
106     }
107     /**
108      * Initializes states of the controls from the preference store.
109      */

110     private void initializeValues() {
111         IPreferenceStore store = getPreferenceStore();
112         //syncModeButton.setSelection(store.getBoolean(ISharedImages.PREF_ALWAYS_IN_INCOMING_OUTGOING));
113
}
114    /**
115     * @see IWorkbenchPreferencePage#init(IWorkbench)
116     */

117     public void init(IWorkbench workbench) {
118     }
119 }
120
Popular Tags