Search in sources :

Example 11 with ScaffoldInfo

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;
}
Also used : IFile(org.eclipse.core.resources.IFile) DAnalysisSessionEObject(org.eclipse.sirius.viewpoint.DAnalysisSessionEObject) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo) URI(org.eclipse.emf.common.util.URI)

Aggregations

ScaffoldInfo (fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)11 EObject (org.eclipse.emf.ecore.EObject)7 Resource (org.eclipse.emf.ecore.resource.Resource)5 InternalEObject (org.eclipse.emf.ecore.InternalEObject)2 Transformation (fr.gouv.mindef.safran.database.transfo.Transformation)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 CDOResource (org.eclipse.emf.cdo.eresource.CDOResource)1 URI (org.eclipse.emf.common.util.URI)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)1 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)1 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Session (org.eclipse.sirius.business.api.session.Session)1 DAnalysisSessionEObject (org.eclipse.sirius.viewpoint.DAnalysisSessionEObject)1 TableContainer (org.obeonetwork.dsl.database.TableContainer)1