use of fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo in project InformationSystem by ObeoNetwork.
the class ScaffoldingUtils method getScaffoldInfoFromSelection.
public static ScaffoldInfo getScaffoldInfoFromSelection(Object selectedElement) {
if (selectedElement instanceof Resource) {
Resource emfResource = (Resource) selectedElement;
if (emfResource != null && emfResource.getContents() != null && emfResource.getContents().isEmpty() == false) {
EObject root = emfResource.getContents().get(0);
if (root instanceof ScaffoldInfo) {
return (ScaffoldInfo) root;
}
}
} else if (selectedElement instanceof EObject) {
return getScaffoldInfo((EObject) selectedElement);
} else if (selectedElement instanceof IFile) {
URI modelURI = URI.createPlatformResourceURI(((IFile) selectedElement).getFullPath().toString(), true);
Resource emfResource = ScaffoldingUtils.getResourceFromSession(modelURI);
if (emfResource != null && emfResource.getContents() != null && emfResource.getContents().isEmpty() == false) {
EObject root = emfResource.getContents().get(0);
if (root instanceof ScaffoldInfo) {
return (ScaffoldInfo) root;
}
}
}
return null;
}
Aggregations