1 11 package org.eclipse.jdt.launching; 12 13 14 import java.io.File ; 15 import java.net.URL ; 16 import com.ibm.icu.text.MessageFormat; 17 import java.util.ArrayList ; 18 import java.util.List ; 19 20 import org.eclipse.core.runtime.IConfigurationElement; 21 import org.eclipse.core.runtime.IExecutableExtension; 22 import org.eclipse.jdt.internal.launching.LaunchingMessages; 23 24 36 37 public abstract class AbstractVMInstallType implements IVMInstallType, IExecutableExtension { 38 private List fVMs; 39 private String fId; 40 41 44 protected AbstractVMInstallType() { 45 fVMs= new ArrayList (10); 46 } 47 48 52 public IVMInstall[] getVMInstalls() { 53 IVMInstall[] vms= new IVMInstall[fVMs.size()]; 54 return (IVMInstall[])fVMs.toArray(vms); 55 } 56 57 61 public void disposeVMInstall(String id) { 62 for (int i= 0; i < fVMs.size(); i++) { 63 IVMInstall vm= (IVMInstall)fVMs.get(i); 64 if (vm.getId().equals(id)) { 65 fVMs.remove(i); 66 JavaRuntime.fireVMRemoved(vm); 67 return; 68 } 69 } 70 } 71 72 76 public IVMInstall findVMInstall(String id) { 77 for (int i= 0; i < fVMs.size(); i++) { 78 IVMInstall vm= (IVMInstall)fVMs.get(i); 79 if (vm.getId().equals(id)) { 80 return vm; 81 } 82 } 83 return null; 84 } 85 86 90 public IVMInstall createVMInstall(String id) throws IllegalArgumentException { 91 if (findVMInstall(id) != null) { 92 String format= LaunchingMessages.vmInstallType_duplicateVM; 93 throw new IllegalArgumentException (MessageFormat.format(format, new String [] { id })); 94 } 95 IVMInstall vm= doCreateVMInstall(id); 96 fVMs.add(vm); 97 return vm; 98 } 99 100 108 protected abstract IVMInstall doCreateVMInstall(String id); 109 110 113 128 public void setInitializationData(IConfigurationElement config, String propertyName, Object data) { 129 fId= config.getAttribute("id"); } 131 132 136 public String getId() { 137 return fId; 138 } 139 140 143 public IVMInstall findVMInstallByName(String name) { 144 for (int i= 0; i < fVMs.size(); i++) { 145 IVMInstall vm= (IVMInstall)fVMs.get(i); 146 if (vm.getName().equals(name)) { 147 return vm; 148 } 149 } 150 return null; 151 } 152 153 169 public URL getDefaultJavadocLocation(File installLocation) { 170 return null; 171 } 172 } 173 | Popular Tags |