Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f5d496607419e2a9f5e1f2cb621fc3d774ee2960 (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
/*****************************************************************************
 * Copyright (c) 2013 CEA LIST.
 *
 * 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:
 *
 *		CEA LIST - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;

import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.preference.IPreferenceStore;

/**
 *
 * Class used to edit integer preferences
 *
 */
public class IntegerDiagramViewObservableValue extends AbstractDiagramPreferencesObservableValue {

	/**
	 *
	 * Constructor.
	 *
	 * @param diagram
	 *            the edited diagram
	 * @param preferenceName
	 *            the name of the edited preference
	 * @param store
	 *            the edited preference store
	 */
	public IntegerDiagramViewObservableValue(final Diagram diagram, final String preferenceName, final IPreferenceStore store) {
		super(diagram, preferenceName, store);
	}

	/**
	 *
	 * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType()
	 *
	 * @return
	 */
	public final Object getValueType() {
		return EcorePackage.eINSTANCE.getEInt();
	}

	/**
	 *
	 * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue()
	 *
	 * @return
	 */
	@Override
	protected final Object doGetValue() {
		final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
		return wsPreferenceStore.getInt(getEditedPreference());
	}

	/**
	 *
	 * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object)
	 *
	 * @param value
	 */
	@Override
	protected void doSetValue(Object value) {
		if (value instanceof Integer) {
			final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
			wsPreferenceStore.setValue(getEditedPreference(), ((Integer) value).intValue());
		}
	}


}

Back to the top