Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 590a8177870a4086168d4d8e2ad8f63ddda4f48b (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
/*******************************************************************************
 * Copyright (c) 2018 Red Hat 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:
 * 		Red Hat Inc. - initial implementation
 *******************************************************************************/
package org.eclipse.cdt.cmake.ui.internal;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

public class CMakePropertyCombo implements ICMakePropertyPageControl {
	
	private String name;
	private String initialValue;
	private Combo combo;
	
	public CMakePropertyCombo(Composite composite, String name, String[] values, String initialValue, String tooltip) {
		this.name = name;
		this.initialValue = initialValue;
		Label label = new Label(composite, SWT.NONE);
		label.setText(name);
		label.setLayoutData(new GridData());
		combo = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
		GridData data = new GridData(GridData.FILL_BOTH);
		data.grabExcessHorizontalSpace = true;
		combo.setLayoutData(data);
		combo.setItems(values);
		combo.setText(initialValue);
		combo.setToolTipText(tooltip);
	}


	@Override
	public String getFieldValue() {
		return combo.getText();
	}

	@Override
	public String getFieldName() {
		return name;
	}

	@Override
	public boolean isValueChanged() {
		return !combo.getText().equals(initialValue);
	}

	@Override
	public boolean isValid() {
		return true;
	}
	
	@Override
	public String getErrorMessage() {
		return null;
	}

}

Back to the top