blob: 3d435b61a72a5a9234b646c1e6e0ac685bd650d3 (
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
|
package org.eclipse.papyrus.palette.customization.modelelement;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.diagram.common.service.palette.IAspectAction;
import org.eclipse.papyrus.paletteconfiguration.ToolConfiguration;
import org.eclipse.papyrus.properties.contexts.DataContextElement;
import org.eclipse.papyrus.properties.modelelement.ModelElement;
import org.eclipse.papyrus.properties.modelelement.ModelElementFactory;
public class AspectActionModelElementFactory implements ModelElementFactory {
public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
if(sourceElement instanceof IAspectAction) {
return new AspectActionModelElement((IAspectAction)sourceElement);
} else if(sourceElement instanceof IAdaptable) {
Object adaptedEObject = ((IAdaptable)sourceElement).getAdapter(EObject.class);
if(adaptedEObject instanceof EObject) {
EObject eObject = (EObject)adaptedEObject;
if(eObject instanceof ToolConfiguration) {
return new ToolConfigurationModelElement((ToolConfiguration)eObject);
}
}
}
return null;
}
}
|