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);
}
}
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;
}
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);
}
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));
}
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());
}
}
}
}
}
Aggregations