Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b10b82a6cfd7268b4e0721bcd990a59c5afda326 (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
76
77
78
79
80
/*******************************************************************************
 * Copyright (c) 2000, 2013 IBM Corporation 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.core.internal.variables;

import org.eclipse.core.variables.IValueVariable;

/**
 * Implementation of a value variable.
 */
public class ValueVariable extends StringVariable implements IValueVariable {

	/**
	 * Variable value or <code>null</code> if none
	 */
	private String fValue;

	/**
	 * Whether this variable is read only.  If true, users cannot change the value.
	 */
	private boolean fReadOnly;

	/**
	 * Constructs a new value variable with the given name, description, read only
	 * property and string value.  Value can be null.
	 *
	 * @param name variable name
	 * @param description variable description or <code>null</code>
	 * @param readOnly whether the variable should be a read only variable
	 * @param value the initial value of the variable or <code>null</code>
	 */
	public ValueVariable(String name, String description, boolean readOnly, String value) {
		super(name, description, null);
		fReadOnly = readOnly;
		fValue = value;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.core.variables.IValueVariable#setValue(java.lang.String)
	 */
	@Override
	public void setValue(String value) {
		if (!isReadOnly()){
			fValue = value;
			StringVariableManager.getDefault().notifyChanged(this);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.core.variables.IValueVariable#getValue()
	 */
	@Override
	public String getValue() {
		return fValue;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.core.variables.IValueVariable#isReadOnly()
	 */
	@Override
	public boolean isReadOnly() {
		return fReadOnly;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.core.variables.IValueVariable#isContributed()
	 */
	@Override
	public boolean isContributed() {
		return false;
	}

}

Back to the top