blob: b0b432daa4693089d998461e6286f02102f3cdeb (
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
|
/*****************************************************************************
* Copyright (c) 2012, 2014 CEA LIST 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:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 417409
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.properties.modelelement;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.properties.Activator;
import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElement;
import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory;
import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
public class CSSModelElementFactory extends CustomStyleModelElementFactory {
@Override
protected CustomStyleModelElement doCreateFromSource(Object sourceElement, DataContextElement context) {
View view = NotationHelper.findView(sourceElement);
if (view == null) {
Activator.log.warn("The selected element cannot be resolved to a GMF View");
return null;
}
EditingDomain domain = EMFHelper.resolveEditingDomain(view);
if (domain == null) {
return new CSSModelElement(view, context);
} else {
return new CSSModelElement(view, domain, context);
}
}
}
|