Search in sources :

Example 1 with DAnalysis

use of org.eclipse.sirius.viewpoint.DAnalysis in project InformationSystem by ObeoNetwork.

the class CreateTablesAndTreesLocallyDAnalysisSelector method selectSmartlyAnalysisForAddedRepresentation.

/**
 * Overridden to restrict {@link DAnalysis} selection for
 * {@link DRepresentation} creation only on remote {@link DAnalysis} if
 * {@link CDOViewpointPreferenceKeys#PREF_ENABLE_LOCAL_REPRESENTATION_CREATION}
 * preference is at false.
 *
 * {@inheritDoc}
 */
public DAnalysis selectSmartlyAnalysisForAddedRepresentation(DRepresentation createdDRepresentation, Collection<DAnalysis> allDAnalysis) {
    // Tables and trees are created locally
    if (createdDRepresentation instanceof DTable || createdDRepresentation instanceof DTree) {
        DAnalysis selectedDAnalysis = null;
        Collection<DAnalysis> localDAnalysis = getAllLocalDAnalyses(allDAnalysis);
        if (localDAnalysis.size() == 1) {
            selectedDAnalysis = localDAnalysis.iterator().next();
        } else {
            selectedDAnalysis = originalDAnalysisSelector.selectSmartlyAnalysisForAddedRepresentation(createdDRepresentation, localDAnalysis);
        }
        return selectedDAnalysis;
    } else {
        // other representations are created as before
        return originalDAnalysisSelector.selectSmartlyAnalysisForAddedRepresentation(createdDRepresentation, allDAnalysis);
    }
}
Also used : DTree(org.eclipse.sirius.tree.DTree) DAnalysis(org.eclipse.sirius.viewpoint.DAnalysis) DTable(org.eclipse.sirius.table.metamodel.table.DTable)

Example 2 with DAnalysis

use of org.eclipse.sirius.viewpoint.DAnalysis in project InformationSystem by ObeoNetwork.

the class AbstractUserStoryDecorator method getAnalysis.

/**
 * Retrieves the DAnalysis instance from a diagram edit part
 * @param diagramEditPart Diagram edit part corresponding to an element on a viewpoint diagram
 * @return the DAnalysis instance
 */
private static DAnalysis getAnalysis(IDiagramElementEditPart diagramEditPart) {
    EObject viewpointNode = diagramEditPart.resolveSemanticElement();
    // if there is no GMF semantic element, we won't be able to retrieve a DAnalysis
    if (viewpointNode != null) {
        Session session = null;
        // First, try to retrieve the session using the sirius semantic element
        if (viewpointNode instanceof DSemanticDecorator) {
            EObject semanticElement = ((DSemanticDecorator) viewpointNode).getTarget();
            if (semanticElement != null) {
                session = new EObjectQuery(semanticElement).getSession();
            }
        }
        // If it didn't work, let's try using the sirius graphical element
        if (session == null) {
            session = new EObjectQuery(viewpointNode).getSession();
        }
        // If we were able to retrieve a session, let's get the root DAnalysis
        if (session != null) {
            EObject analysisEObject = session.getSessionResource().getContents().get(0);
            if (analysisEObject instanceof DAnalysis) {
                return (DAnalysis) analysisEObject;
            }
        }
        // Nothing worked, let's check if the EMF root element is a DAnalysis
        EObject container = EcoreUtil.getRootContainer(viewpointNode);
        if (container != null && container instanceof DAnalysis) {
            return (DAnalysis) container;
        }
    }
    return null;
}
Also used : DSemanticDecorator(org.eclipse.sirius.viewpoint.DSemanticDecorator) EObjectQuery(org.eclipse.sirius.business.api.query.EObjectQuery) EObject(org.eclipse.emf.ecore.EObject) DAnalysis(org.eclipse.sirius.viewpoint.DAnalysis) Session(org.eclipse.sirius.business.api.session.Session)

Example 3 with DAnalysis

use of org.eclipse.sirius.viewpoint.DAnalysis in project InformationSystem by ObeoNetwork.

the class UserStoriesView method update.

protected void update(Session session, final List<EObject> selectedEObjects) {
    if (session != null) {
        EObject analysisEObject = session.getSessionResource().getContents().get(0);
        if (analysisEObject instanceof DAnalysis) {
            this.activeAnalysis = (DAnalysis) analysisEObject;
            viewer.setInput(selectedEObjects);
            return;
        }
    }
    this.activeAnalysis = null;
    viewer.setInput(null);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) DAnalysis(org.eclipse.sirius.viewpoint.DAnalysis)

Example 4 with DAnalysis

use of org.eclipse.sirius.viewpoint.DAnalysis in project InformationSystem by ObeoNetwork.

the class UIConfigurationImpl method setViewpointAnalysis.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setViewpointAnalysis(DAnalysis newViewpointAnalysis) {
    DAnalysis oldViewpointAnalysis = viewpointAnalysis;
    viewpointAnalysis = newViewpointAnalysis;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, GraalfeatureextensionsPackage.UI_CONFIGURATION__VIEWPOINT_ANALYSIS, oldViewpointAnalysis, viewpointAnalysis));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) DAnalysis(org.eclipse.sirius.viewpoint.DAnalysis)

Example 5 with DAnalysis

use of org.eclipse.sirius.viewpoint.DAnalysis 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

DAnalysis (org.eclipse.sirius.viewpoint.DAnalysis)7 EObject (org.eclipse.emf.ecore.EObject)3 Session (org.eclipse.sirius.business.api.session.Session)3 EObjectQuery (org.eclipse.sirius.business.api.query.EObjectQuery)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 ViewpointQuery (org.eclipse.sirius.business.api.query.ViewpointQuery)1 ViewpointSelector (org.eclipse.sirius.business.api.session.ViewpointSelector)1 DAnalysisSession (org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession)1 DTable (org.eclipse.sirius.table.metamodel.table.DTable)1 DTree (org.eclipse.sirius.tree.DTree)1 IEditingSession (org.eclipse.sirius.ui.business.api.session.IEditingSession)1 DAnalysisSessionEObject (org.eclipse.sirius.viewpoint.DAnalysisSessionEObject)1 DSemanticDecorator (org.eclipse.sirius.viewpoint.DSemanticDecorator)1 DView (org.eclipse.sirius.viewpoint.DView)1 Viewpoint (org.eclipse.sirius.viewpoint.description.Viewpoint)1 MImportExportData (org.obeonetwork.dsl.manifest.MImportExportData)1