Search in sources :

Example 1 with MavenProjectChangedEvent

use of org.eclipse.m2e.core.project.MavenProjectChangedEvent in project bndtools by bndtools.

the class MavenWorkspaceRepository method mavenProjectChanged.

@Override
public void mavenProjectChanged(MavenProjectChangedEvent[] events, IProgressMonitor monitor) {
    if (events == null)
        return;
    for (MavenProjectChangedEvent event : events) {
        final IMavenProjectFacade oldProject = event.getOldMavenProject();
        final Iterator<Entry<String, Entry<IMavenProjectFacade, MavenProject>>> entries = bsnMap.entrySet().iterator();
        while (entries.hasNext()) {
            final Entry<String, Entry<IMavenProjectFacade, MavenProject>> entry = entries.next();
            if (entry.getValue().getKey().equals(oldProject)) {
                String bsn = entry.getKey();
                bsnMap.remove(bsn);
                break;
            }
        }
        final IMavenProjectFacade newProject = event.getMavenProject();
        try {
            final MavenProject newMavenProject = getMavenProject(newProject, monitor);
            final String newBsn = getBsnFromMavenProject(newMavenProject);
            final Entry<IMavenProjectFacade, MavenProject> newEntry = new SimpleImmutableEntry<>(newProject, newMavenProject);
            bsnMap.put(newBsn, newEntry);
        } catch (Exception e) {
            logger.logError("Error getting bsn for new project " + newProject.getProject().getName(), e);
        }
    }
}
Also used : SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) Entry(java.util.Map.Entry) MavenProject(org.apache.maven.project.MavenProject) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) MavenProjectChangedEvent(org.eclipse.m2e.core.project.MavenProjectChangedEvent) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)1 Entry (java.util.Map.Entry)1 MavenProject (org.apache.maven.project.MavenProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)1 MavenProjectChangedEvent (org.eclipse.m2e.core.project.MavenProjectChangedEvent)1