Search in sources :

Example 1 with ProjectModelRepository

use of ch.acanda.eclipse.pmd.repository.ProjectModelRepository in project eclipse-pmd by acanda.

the class PMDPlugin method start.

@Override
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void start(final BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    V07ToV08Converter.moveSettings(getPreferenceStore(), new ProjectModelRepository());
    initWorkspaceModel();
    initPMD();
}
Also used : ProjectModelRepository(ch.acanda.eclipse.pmd.repository.ProjectModelRepository)

Example 2 with ProjectModelRepository

use of ch.acanda.eclipse.pmd.repository.ProjectModelRepository in project eclipse-pmd by acanda.

the class PMDPlugin method initWorkspaceModel.

private void initWorkspaceModel() {
    workspaceModel = new WorkspaceModel();
    final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    final ProjectModelRepository projectModelRepository = new ProjectModelRepository();
    for (final IProject project : projects) {
        final Optional<ProjectModel> model = projectModelRepository.load(project.getName());
        if (model.isPresent()) {
            workspaceModel.add(model.get());
        } else {
            workspaceModel.add(new ProjectModel(project.getName()));
        }
    }
    final IResourceChangeListener workspaceChangeListener = new WorkspaceChangeListener(workspaceModel, projectModelRepository);
    ResourcesPlugin.getWorkspace().addResourceChangeListener(workspaceChangeListener, IResourceChangeEvent.POST_CHANGE);
}
Also used : WorkspaceModel(ch.acanda.eclipse.pmd.domain.WorkspaceModel) ProjectModelRepository(ch.acanda.eclipse.pmd.repository.ProjectModelRepository) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) ProjectModel(ch.acanda.eclipse.pmd.domain.ProjectModel) IProject(org.eclipse.core.resources.IProject)

Example 3 with ProjectModelRepository

use of ch.acanda.eclipse.pmd.repository.ProjectModelRepository in project eclipse-pmd by acanda.

the class PMDPropertyPageController method save.

public void save() {
    projectModel.setPMDEnabled(model.isPMDEnabled());
    projectModel.setRuleSets(toDomainModels(model.getActiveRuleSets()));
    final ProjectModelRepository projectModelRepository = new ProjectModelRepository();
    projectModelRepository.save(projectModel);
    try {
        if (model.isPMDEnabled()) {
            PMDNature.addTo(project);
        } else {
            PMDNature.removeFrom(project);
        }
    } catch (final CoreException e) {
        PMDPlugin.getDefault().error("Cannot change PMD nature of project " + project.getName(), e);
    }
}
Also used : ProjectModelRepository(ch.acanda.eclipse.pmd.repository.ProjectModelRepository) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ProjectModelRepository (ch.acanda.eclipse.pmd.repository.ProjectModelRepository)3 ProjectModel (ch.acanda.eclipse.pmd.domain.ProjectModel)1 WorkspaceModel (ch.acanda.eclipse.pmd.domain.WorkspaceModel)1 IProject (org.eclipse.core.resources.IProject)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 CoreException (org.eclipse.core.runtime.CoreException)1