/** * {@inheritDoc} * * @see * org.eclipse.core.resources.mapping.ModelProvider#validateChange(org.eclipse.core.resources.IResourceDelta, * org.eclipse.core.runtime.IProgressMonitor) */ @Override public IStatus validateChange(IResourceDelta delta, IProgressMonitor monitor) { IStatus result = null; if (delta != null) { try { ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); delta.accept(visitor); if (visitor.getProjectContainingSessionToSaveToDelete().size() == 1) { result = new ModelStatus( IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, "This modeling project contains unsaved data. This data will be lost."); } else if (visitor.getProjectContainingSessionToSaveToDelete().size() > 1) { result = new ModelStatus( IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, "Some modeling projects (" + getProjectsName(visitor.getProjectContainingSessionToSaveToDelete()) + ") contain unsaved data. This data will be lost."); } else if (visitor.getMainRepresentationsFilesToDelete().size() == 1) { result = new ModelStatus( IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, "Deletion of the main representations file of \"" + visitor.getMainRepresentationsFilesToDelete().get(0).getProject().getName() + "\" will invalidate it."); } else if (visitor.getMainRepresentationsFilesToDelete().size() > 1) { result = new ModelStatus( IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, "Deletion of the main representations files of some modeling projects (" + getFilesProjectName(visitor.getMainRepresentationsFilesToDelete()) + ") will invalidate them."); } else if (visitor.getRepresentationsFileToAddOnValidModelingProject().size() == 1) { result = new ModelStatus( IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, "Add another representations file to \"" + visitor .getRepresentationsFileToAddOnValidModelingProject() .get(0) .getProject() .getName() + "\" may invalidate it."); } else if (visitor.getRepresentationsFileToAddOnValidModelingProject().size() > 1) { result = new ModelStatus( IStatus.ERROR, SiriusPlugin.ID, ModelingModelProvider.MODELING_MODEL_PROVIDER_ID, "Add another representations file to " + getFilesProjectName( visitor.getRepresentationsFileToAddOnValidModelingProject()) + " may invalidate them."); } } catch (CoreException e) { /* do nothing */ } } if (result == null) { result = super.validateChange(delta, monitor); } return result; }