private void deleteOldMigrationAnnotations(DAnalysis dAnalysis) { Iterator<DAnnotationEntry> iterator = dAnalysis.getEAnnotations().iterator(); while (iterator.hasNext()) { DAnnotationEntry entry = iterator.next(); if (entry.getSource().equals("Migration")) { // $NON-NLS-1$ iterator.remove(); } } }
/** * Retrieve all GMF diagrams of the {@link DAnalysis}. * * @param dAnalysis The analysis of the resource to migrate * @return GMF diagrams of this {@link DAnalysis} */ public List<Diagram> getGMFDiagrams(DAnalysis dAnalysis) { List<Diagram> diagrams = new ArrayList<Diagram>(); for (DView view : dAnalysis.getOwnedViews()) { for (DRepresentation representation : new DViewQuery(view).getLoadedRepresentations()) { if (representation instanceof DDiagram) { DDiagramGraphicalQuery query = new DDiagramGraphicalQuery((DDiagram) representation); Option<Diagram> option = query.getAssociatedGMFDiagram(); if (option.some()) { diagrams.add(option.get()); } } } } return diagrams; }
/** * refresh representations. * * @param dAnalysis {@link DAnalysis} to refresh. * @param view current {@link DView} */ public void refreshRepresentations(final DAnalysis dAnalysis, final DView view) { TransactionalEditingDomain transactionalEditingDomain = TransactionUtil.getEditingDomain(dAnalysis); boolean hasAlreadyModel = false; // The old representations have no a model. if (view instanceof DRepresentationContainer) { if (!((DAnalysis) view.eContainer()).getModels().isEmpty()) { // Set hasAlreadyModel to true only if almost one of the models // is not a proxy for (EObject model : ((DAnalysis) view.eContainer()).getModels()) { if (!model.eIsProxy()) { hasAlreadyModel = true; } } } else if (!hasAlreadyModel) { final Map<EObject, AnyType> extension = ((XMIResource) dAnalysis.eResource()).getEObjectToExtensionMap(); final AnyType viewSettings = extension.get(view); if (viewSettings != null) { for (final FeatureMap.Entry feature : viewSettings.getMixed()) { if ("model".equals(feature.getEStructuralFeature().getName())) { ((DAnalysis) view.eContainer()) .getModels() .add( EcoreUtil.resolve( (EObject) feature.getValue(), view.eResource().getResourceSet())); hasAlreadyModel = true; } } } } } // Command prepareImportsFromSessionCommand = new // PrepareImportsFromSessionCommand(this, view); MigrationCommandExecutor migrationCommandExecutor = new MigrationCommandExecutor(); Command prepareImportsFromSessionCommand = new IdentityCommand() { @Override public void execute() { // Not seem to be necessary (done by handle view command) // initAnalysis(view); for (final EObject model : ((DAnalysis) view.eContainer()).getModels()) { if (!model.eIsProxy()) { InterpreterRegistry.prepareImportsFromSession( SiriusPlugin.getDefault().getInterpreterRegistry().getInterpreter(model), SessionManager.INSTANCE.getSession(model)); } } for (DRepresentation dRepresentation : view.getOwnedRepresentations()) { DialectManager.INSTANCE.refresh(dRepresentation, new NullProgressMonitor()); } } @Override public boolean canUndo() { return false; } }; migrationCommandExecutor.execute(transactionalEditingDomain, prepareImportsFromSessionCommand); // This method calls a RecordingCommand refreshLostDiagramElements(view); refreshAllElementsVisibility(view, transactionalEditingDomain, migrationCommandExecutor); // if (!hasAlreadyModel) { // deinformModel((DRepresentationContainer) view); // } // Recompute the models references after the refresh. // Command cleanModelsCommand = new CleanModelsCommand(this, dAnalysis, // true); // migrationCommandExecutor.execute(transactionalEditingDomain, // cleanModelsCommand); }