1 11 package org.eclipse.jdt.internal.corext.javadoc; 12 13 import java.net.URL ; 14 15 import org.eclipse.core.runtime.IPath; 16 17 import org.eclipse.jdt.launching.IVMInstall; 18 import org.eclipse.jdt.launching.IVMInstallChangedListener; 19 import org.eclipse.jdt.launching.IVMInstallType; 20 import org.eclipse.jdt.launching.JavaRuntime; 21 import org.eclipse.jdt.launching.LibraryLocation; 22 import org.eclipse.jdt.launching.PropertyChangeEvent; 23 24 import org.eclipse.jdt.ui.JavaUI; 25 26 28 public class JavaDocVMInstallListener implements IVMInstallChangedListener { 29 30 33 public JavaDocVMInstallListener() { 34 } 35 36 public void init() { 37 IVMInstallType[] types= JavaRuntime.getVMInstallTypes(); 38 for (int i = 0; i < types.length; i++) { 39 IVMInstall[] installs= types[i].getVMInstalls(); 40 for (int j = 0; j < installs.length; j++) { 41 updateJavadocLocations(installs[j]); 42 } 43 } 44 45 JavaRuntime.addVMInstallChangedListener(this); 46 } 47 48 public void remove() { 49 JavaRuntime.removeVMInstallChangedListener(this); 50 } 51 52 53 54 57 public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) { 58 } 59 60 private void updateJavadocLocations(IVMInstall install) { 61 URL url= install.getJavadocLocation(); 62 if (url != null) { 63 LibraryLocation[] locations= JavaRuntime.getLibraryLocations(install); 64 if (locations != null) { 65 for (int i = 0; i < locations.length; i++) { 66 IPath path= locations[i].getSystemLibraryPath(); 67 if (path != null) { 68 JavaUI.setLibraryJavadocLocation(path, url); 69 } 70 } 71 } 72 } 73 } 74 75 76 79 public void vmChanged(PropertyChangeEvent event) { 80 String property= event.getProperty(); 81 if (PROPERTY_INSTALL_LOCATION.equals(property) 82 || PROPERTY_JAVADOC_LOCATION.equals(property) 83 || PROPERTY_LIBRARY_LOCATIONS.equals(property)) { 84 updateJavadocLocations((IVMInstall) event.getSource()); 85 } 86 } 87 88 91 public void vmAdded(IVMInstall vm) { 92 updateJavadocLocations(vm); 93 } 94 95 98 public void vmRemoved(IVMInstall vm) { 99 } 100 101 } 102 | Popular Tags |