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