1 11 package org.eclipse.jdt.internal.junit.buildpath; 12 13 14 import org.eclipse.core.runtime.IPath; 15 16 import org.eclipse.jdt.core.ClasspathVariableInitializer; 17 import org.eclipse.jdt.core.JavaCore; 18 import org.eclipse.jdt.core.JavaModelException; 19 20 import org.eclipse.jdt.internal.junit.ui.JUnitPlugin; 21 22 public class JUnitHomeInitializer extends ClasspathVariableInitializer { 23 24 27 public void initialize(String variable) { 28 if (JUnitPlugin.JUNIT_HOME.equals(variable)) { 29 initializeHome(); 30 } else if (JUnitPlugin.JUNIT_SRC_HOME.equals(variable)) { 31 initializeSource(); 32 } 33 } 34 35 private void initializeHome() { 36 try { 37 IPath location= BuildPathSupport.getBundleLocation(BuildPathSupport.JUNIT3_PLUGIN); 38 if (location != null) { 39 JavaCore.setClasspathVariable(JUnitPlugin.JUNIT_HOME, location, null); 40 } else { 41 JavaCore.removeClasspathVariable(JUnitPlugin.JUNIT_HOME, null); 42 } 43 } catch (JavaModelException e1) { 44 JavaCore.removeClasspathVariable(JUnitPlugin.JUNIT_HOME, null); 45 } 46 } 47 48 private void initializeSource() { 49 try { 50 IPath sourceLocation= BuildPathSupport.getSourceLocation(BuildPathSupport.JUNIT3_PLUGIN); 51 if (sourceLocation != null) { 52 JavaCore.setClasspathVariable(JUnitPlugin.JUNIT_SRC_HOME, sourceLocation, null); 53 } else { 54 JavaCore.removeClasspathVariable(JUnitPlugin.JUNIT_SRC_HOME, null); 55 } 56 } catch (JavaModelException e1) { 57 JavaCore.removeClasspathVariable(JUnitPlugin.JUNIT_SRC_HOME, null); 58 } 59 } 60 } | Popular Tags |