blob: b6fba3be81712c9b88a3bde7752085fe68782255 (
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
|
/*****************************************************************************
* Copyright (c) 2015 Christian W. Damus 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:
* Christian W. Damus - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.AbstractModelElementFactory;
/**
* Model-element factory for synthetic synchronization properties of GMF notation views.
*/
public class SynchronizationModelElementFactory extends AbstractModelElementFactory<SynchronizationModelElement> {
@Override
protected SynchronizationModelElement doCreateFromSource(Object sourceElement, DataContextElement context) {
SynchronizationModelElement result = null;
IGraphicalEditPart editPart = AdapterUtils.adapt(sourceElement, IGraphicalEditPart.class, null);
if (editPart == null) {
Activator.log.warn("The selected element cannot be resolved to a GEF EditPart");
} else {
result = new SynchronizationModelElement(editPart.getEditingDomain(), editPart);
}
return result;
}
@Override
protected void updateModelElement(SynchronizationModelElement modelElement, Object newSourceElement) {
IGraphicalEditPart editPart = AdapterUtils.adapt(newSourceElement, IGraphicalEditPart.class, null);
if (editPart == null) {
throw new IllegalArgumentException("Cannot resolve EditPart selection: " + newSourceElement);
}
modelElement.domain = editPart.getEditingDomain();
modelElement.editPart = editPart;
}
}
|