Search in sources :

Example 1 with ViewpointQuery

use of org.eclipse.sirius.business.api.query.ViewpointQuery in project InformationSystem by ObeoNetwork.

the class ProjectLibraryImporter method addReferencedAnalysis.

private void addReferencedAnalysis() {
    // Get main analysis
    Session sourceSession = importData.getSourceSession();
    Session targetSession = importData.getTargetSession();
    DAnalysis sourceMainAnalysis = getMainAnalysis(sourceSession);
    // Add the copied analysis as a referenced analysis
    if (sourceMainAnalysis != null) {
        EObject targetMainAnalysis = importData.getCopyEObject(sourceMainAnalysis);
        if (targetMainAnalysis instanceof DAnalysis && targetSession instanceof DAnalysisSession) {
            ((DAnalysisSession) targetSession).addReferencedAnalysis((DAnalysis) targetMainAnalysis);
        }
    }
    // Add required viewpoints
    for (DView view : sourceMainAnalysis.getOwnedViews()) {
        Viewpoint viewpoint = view.getViewpoint();
        Option<URI> viewpointURI = new ViewpointQuery(viewpoint).getViewpointURI();
        if (viewpointURI.some()) {
            Viewpoint sessionVP = ViewpointRegistry.getInstance().getViewpoint(viewpointURI.get());
            if (sessionVP != null) {
                if (!SiriusResourceHelper.isViewExistForSirius(targetSession, sessionVP)) {
                    // We have to add the viewpoint
                    // TODO Monitor
                    new ViewpointSelector(targetSession).selectViewpoint(sessionVP, false, new NullProgressMonitor());
                }
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ViewpointQuery(org.eclipse.sirius.business.api.query.ViewpointQuery) DAnalysisSession(org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) EObject(org.eclipse.emf.ecore.EObject) DAnalysis(org.eclipse.sirius.viewpoint.DAnalysis) ViewpointSelector(org.eclipse.sirius.business.api.session.ViewpointSelector) URI(org.eclipse.emf.common.util.URI) Session(org.eclipse.sirius.business.api.session.Session) DAnalysisSession(org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession) IEditingSession(org.eclipse.sirius.ui.business.api.session.IEditingSession) DView(org.eclipse.sirius.viewpoint.DView)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 ViewpointQuery (org.eclipse.sirius.business.api.query.ViewpointQuery)1 Session (org.eclipse.sirius.business.api.session.Session)1 ViewpointSelector (org.eclipse.sirius.business.api.session.ViewpointSelector)1 DAnalysisSession (org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession)1 IEditingSession (org.eclipse.sirius.ui.business.api.session.IEditingSession)1 DAnalysis (org.eclipse.sirius.viewpoint.DAnalysis)1 DView (org.eclipse.sirius.viewpoint.DView)1 Viewpoint (org.eclipse.sirius.viewpoint.description.Viewpoint)1