~ubuntu-branches/ubuntu/utopic/eclipse-eclox/utopic

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
/*******************************************************************************
 * Copyright (C) 2003-2004, 2013, Guillaume Brocker
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Guillaume Brocker - Initial API and implementation
 *
 ******************************************************************************/ 

package eclox.ui;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;


/**
 * Implements the plugin preference page.
 * 
 * @author gbrocker
 */
public class PreferencePage extends org.eclipse.jface.preference.FieldEditorPreferencePage implements IWorkbenchPreferencePage
{
	/**
	 * Constructor.
	 */
	public PreferencePage() {
		super( GRID );
	}
	
	public void init( IWorkbench workbench ) {
		setPreferenceStore( Plugin.getDefault().getPreferenceStore() );
	}
	
	/**
	 * Creates the preference page fields.
	 */
	protected void createFieldEditors() {
		Composite	rootControl = getFieldEditorParent();
	
		// Create the controls.
		
		BooleanFieldEditor escapeValueStrings = new BooleanFieldEditor(IPreferences.HANDLE_ESCAPED_VALUES, "Handle escapes for \" and \\ in value strings", rootControl);
		escapeValueStrings.setPreferenceStore( getPreferenceStore() );
		addField( escapeValueStrings );
		
		IntegerFieldEditor historySize = new IntegerFieldEditor(IPreferences.BUILD_HISTORY_SIZE, "Build history size:", rootControl);
		historySize.setPreferenceStore( getPreferenceStore() );
		historySize.setValidRange( 1, 100 );
		addField( historySize );

		RadioGroupFieldEditor autoSave = new RadioGroupFieldEditor(
			IPreferences.AUTO_SAVE,
			"Save all modified files before building",
			1,
			new String[][] {
				{IPreferences.AUTO_SAVE_NEVER, IPreferences.AUTO_SAVE_NEVER},
				{IPreferences.AUTO_SAVE_ALWAYS, IPreferences.AUTO_SAVE_ALWAYS},
				{IPreferences.AUTO_SAVE_ASK, IPreferences.AUTO_SAVE_ASK},
			},
			rootControl,
			true );
		autoSave.setPreferenceStore( getPreferenceStore() );
		addField( autoSave );
	}

}