List of usage examples for org.eclipse.jdt.core IPackageFragmentRoot getJavaModel
IJavaModel getJavaModel();
From source file:org.jboss.tools.pde.sourcelookup.core.internal.utils.ClasspathUtils.java
License:Open Source License
public static void attachSource(final IPackageFragmentRoot fragment, final IPath newSourcePath, IProgressMonitor monitor) {// ww w.j a v a 2 s. co m try { if (fragment == null || fragment.getKind() != IPackageFragmentRoot.K_BINARY) { return; } if (!Objects.equals(fragment.getSourceAttachmentPath(), newSourcePath)) { // would be so cool if it refreshed the UI automatically fragment.attachSource(newSourcePath, null, monitor); // close the root so that source attachment cache is flushed. Else UI // won't update fragment.close(); // we have to manually fire a delta to notify the UI about the source // attachment. JavaModelManager manager = JavaModelManager.getJavaModelManager(); JavaElementDelta attachedSourceDelta = new JavaElementDelta(fragment.getJavaModel()); attachedSourceDelta.sourceAttached(fragment); manager.getDeltaProcessor().fire(attachedSourceDelta, ElementChangedEvent.POST_CHANGE); } } catch (CoreException e) { // ignore } }