use of org.eclipse.sirius.business.api.session.ViewpointSelector 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());
}
}
}
}
}
use of org.eclipse.sirius.business.api.session.ViewpointSelector in project InformationSystem by ObeoNetwork.
the class BusinessProjectImporter method addRepresentationDescriptor.
private void addRepresentationDescriptor(Session session, DRepresentationDescriptor representationDescriptor, Viewpoint viewpoint) {
if (viewpoint != null) {
DView view = getViewForViewpoint(viewpoint, session);
if (view != null) {
view.getOwnedRepresentationDescriptors().add(representationDescriptor);
view.eResource().getContents().add(representationDescriptor.getRepresentation());
return;
}
// If we reach this point it probably means the viewpoint was not selected yet
new ViewpointSelector(session).selectViewpoint(viewpoint, false, new NullProgressMonitor());
view = getViewForViewpoint(viewpoint, session);
if (view != null) {
view.getOwnedRepresentationDescriptors().add(representationDescriptor);
view.eResource().getContents().add(representationDescriptor.getRepresentation());
return;
}
}
}
Aggregations