Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6c0f78fae5f0e3ec4fe2861cfdec9a3deff9428d (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
/*****************************************************************************
 * 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.style.impl;

import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.SingleValueStyle;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSSingleValueStyle;
import org.w3c.dom.Element;
import org.w3c.dom.css.CSSValue;

@SuppressWarnings("restriction")
public class CSSSingleValueStyleDelegate implements CSSSingleValueStyle{
	
	private SingleValueStyle singleValueStyle;

	private ExtendedCSSEngine engine;

	private Element element;

	public CSSSingleValueStyleDelegate(SingleValueStyle singleValueStyle, ExtendedCSSEngine engine){
		this.singleValueStyle = singleValueStyle;
 		this.engine = engine;
		this.element = engine.getElement(this.singleValueStyle);
	}

	////////////////////////////////////////////////
	//	Implements a getter for each CSS property //
	////////////////////////////////////////////////

	public java.lang.String getCSSName(){
		CSSValue cssValue = engine.retrievePropertyValue(element, "name");
		if(cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getNamedStyle_Name().getDefaultValue(); 
			return (String)defaultValue;
		}
		return (String)engine.convert(cssValue, String.class, null);
	}

	public java.lang.String getCSSRawValue(){
		CSSValue cssValue = engine.retrievePropertyValue(element, "rawValue");
		if(cssValue == null) {
			Object defaultValue = NotationPackage.eINSTANCE.getSingleValueStyle_RawValue().getDefaultValue(); 
			return (String)defaultValue;
		}
		return (String)engine.convert(cssValue, String.class, null);
	}
}

Back to the top