Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a6d8b3cec042e5336e5282083ea6b5c963f4171a (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*****************************************************************************
 * 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.EStructuralFeature;
import org.eclipse.gmf.runtime.notation.MeasurementUnit;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.impl.StandardDiagramImpl;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagramImpl;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.ForceValueHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSDiagramStyle;
import org.eclipse.papyrus.infra.gmfdiag.css.style.impl.CSSDiagramStyleDelegate;

public class CSSStandardDiagramImpl extends StandardDiagramImpl implements CSSDiagramStyle {

	protected ExtendedCSSEngine engine;

	private CSSDiagramStyle diagramStyle;

	protected CSSDiagramStyle getDiagramStyle() {
		if(diagramStyle == null) {
			diagramStyle = new  CSSDiagramStyleDelegate(this, getEngine());
		}
		return diagramStyle;
	}

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


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


	public int getCSSPageX(){
		int value = super.getPageX();

		if (ForceValueHelper.isSet(this, NotationPackage.eINSTANCE.getPageStyle_PageX(), value)){
			return value;
		} else {
			return getDiagramStyle().getCSSPageX();
		}
	}

	public int getCSSPageY(){
		int value = super.getPageY();

		if (ForceValueHelper.isSet(this, NotationPackage.eINSTANCE.getPageStyle_PageY(), value)){
			return value;
		} else {
			return getDiagramStyle().getCSSPageY();
		}
	}

	public int getCSSPageWidth(){
		int value = super.getPageWidth();

		if (ForceValueHelper.isSet(this, NotationPackage.eINSTANCE.getPageStyle_PageWidth(), value)){
			return value;
		} else {
			return getDiagramStyle().getCSSPageWidth();
		}
	}

	public int getCSSPageHeight(){
		int value = super.getPageHeight();

		if (ForceValueHelper.isSet(this, NotationPackage.eINSTANCE.getPageStyle_PageHeight(), value)){
			return value;
		} else {
			return getDiagramStyle().getCSSPageHeight();
		}
	}

	public java.lang.String getCSSDescription(){
		java.lang.String value = super.getDescription();

		if (ForceValueHelper.isSet(this, NotationPackage.eINSTANCE.getDescriptionStyle_Description(), value)){
			return value;
		} else {
			return getDiagramStyle().getCSSDescription();
		}
	}


	@Override
	public int getPageX(){
		//return super.getPageX();
		return getCSSPageX();
	}

	@Override
	public int getPageY(){
		//return super.getPageY();
		return getCSSPageY();
	}

	@Override
	public int getPageWidth(){
		//return super.getPageWidth();
		return getCSSPageWidth();
	}

	@Override
	public int getPageHeight(){
		//return super.getPageHeight();
		return getCSSPageHeight();
	}

	@Override
	public java.lang.String getDescription(){
		//return super.getDescription();
		return getCSSDescription();
	}



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

	@Override
	public void setVisible(boolean value){
		super.setVisible(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getView_Visible();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setType(java.lang.String value){
		super.setType(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getView_Type();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setMutable(boolean value){
		super.setMutable(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getView_Mutable();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setName(java.lang.String value){
		super.setName(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getDiagram_Name();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setMeasurementUnit(MeasurementUnit value){
		super.setMeasurementUnit(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getDiagram_MeasurementUnit();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setPageX(int value){
		super.setPageX(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getPageStyle_PageX();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setPageY(int value){
		super.setPageY(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getPageStyle_PageY();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setPageWidth(int value){
		super.setPageWidth(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getPageStyle_PageWidth();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setPageHeight(int value){
		super.setPageHeight(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getPageStyle_PageHeight();
		ForceValueHelper.setValue(this, feature, value);
	}

	@Override
	public void setDescription(java.lang.String value){
		super.setDescription(value);
	
		EStructuralFeature feature = NotationPackage.eINSTANCE.getDescriptionStyle_Description();
		ForceValueHelper.setValue(this, feature, value);
	}

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

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

		EStructuralFeature feature = eDynamicFeature(featureId);
		ForceValueHelper.unsetValue(this, feature);
	}


}

Back to the top