Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fcd29643ff281bf3fec2c7a40b5cd8d49a7915ae (plain) (blame)
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
/*******************************************************************************
 * Copyright (c) 2012 Google, Inc and others.
 * 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:
 * 	   Sergey Prigogin (Google) - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;

import org.eclipse.core.resources.IProject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;

import org.eclipse.cdt.ui.PreferenceConstants;

import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;

/**
 * Configures C Editor typing preferences.
 */
class CodeStyleBlock extends OptionsConfigurationBlock {
	private static final Key CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER = getCDTUIKey(PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER);

	private static Key[] getAllKeys() {
		return new Key[] {
				CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER,
			};
	}

	public CodeStyleBlock(IStatusChangeListener context, IProject project,
			IWorkbenchPreferenceContainer container) {
		super(context, project, getAllKeys(), container);
	}
	
	@Override
	public Control createContents(Composite parent) {
		ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
		scrolled.setExpandHorizontal(true);
		scrolled.setExpandVertical(true);
		
		Composite control= new Composite(scrolled, SWT.NONE);
		GridLayout layout= new GridLayout();
		control.setLayout(layout);

		Composite composite = addSubsection(control, PreferencesMessages.CodeStyleBlock_class_member_order); 
		fillClassMemberOrderSection(composite);
		
		scrolled.setContent(control);
		final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		scrolled.setMinSize(size.x, size.y);
		return scrolled;
	}

	private void fillClassMemberOrderSection(Composite composite) {
		GridLayout layout= new GridLayout();
		layout.numColumns= 3;
		composite.setLayout(layout);

		addRadioButton(composite, PreferencesMessages.CodeStyleBlock_public_private,
				CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, FALSE_TRUE, 0);
		addRadioButton(composite, PreferencesMessages.CodeStyleBlock_private_public,
				CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, TRUE_FALSE, 0);
	}

	@Override
	protected void validateSettings(Key changedKey, String oldValue, String newValue) {
	}
}

Back to the top