Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 90a88b4ed45ebad076be7ea1942e17ced45684fe (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*****************************************************************************
 * Copyright (c) 2012 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:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Sorting;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.impl.SortingStyleImpl;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.ForceValueHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSSortingStyle;
import org.eclipse.papyrus.infra.gmfdiag.css.style.impl.CSSSortingStyleDelegate;

public class CSSSortingStyleImpl extends SortingStyleImpl implements CSSSortingStyle {

	protected ExtendedCSSEngine engine;

	private CSSSortingStyle sortingStyle;

	protected CSSSortingStyle getSortingStyle() {
		if (sortingStyle == null) {
			sortingStyle = new CSSSortingStyleDelegate(this, getEngine());
		}
		return sortingStyle;
	}

	protected ExtendedCSSEngine getEngine() {
		if (engine == null) {
			engine = ((CSSDiagram) findView().getDiagram()).getEngine();
		}
		return engine;
	}

	protected View findView() {
		EObject parent = eContainer();
		while (!(parent instanceof View) && parent != null) {
			parent = parent.eContainer();
		}

		if (parent != null) {
			return (View) parent;
		}

		return null;
	}


	// ////////////////////////////////////////
	// Forwards accesses to CSS properties //
	// ////////////////////////////////////////


	@Override
	public Sorting getCSSSorting() {
		Sorting value = super.getSorting();

		if (ForceValueHelper.isSet(findView(), this, NotationPackage.eINSTANCE.getSortingStyle_Sorting(), value)) {
			return value;
		} else {
			return getSortingStyle().getCSSSorting();
		}
	}

	@Override
	public java.util.Map getCSSSortingKeys() {
		java.util.Map value = super.getSortingKeys();

		if (ForceValueHelper.isSet(findView(), this, NotationPackage.eINSTANCE.getSortingStyle_SortingKeys(), value)) {
			return value;
		} else {
			return getSortingStyle().getCSSSortingKeys();
		}
	}


	@Override
	public Sorting getSorting() {
		return getCSSSorting();
	}

	@Override
	public java.util.Map getSortingKeys() {
		return getCSSSortingKeys();
	}



	// //////////////////////////////////////////////
	// Implements a setter for each CSS property //
	// //////////////////////////////////////////////

	@Override
	public void setSorting(Sorting value) {
		super.setSorting(value);

		EStructuralFeature feature = NotationPackage.eINSTANCE.getSortingStyle_Sorting();
		ForceValueHelper.setValue(findView(), feature, value);
	}

	@Override
	public void setSortingKeys(java.util.Map value) {
		super.setSortingKeys(value);

		EStructuralFeature feature = NotationPackage.eINSTANCE.getSortingStyle_SortingKeys();
		ForceValueHelper.setValue(findView(), feature, value);
	}

	// ////////////////////////////////
	// Implements the unset method //
	// ////////////////////////////////

	@Override
	public void eUnset(int featureId) {
		super.eUnset(featureId);

		EStructuralFeature feature = eClass().getEStructuralFeature(featureId);
		ForceValueHelper.unsetValue(findView(), feature);
	}


}

Back to the top