1 26 27 package org.omg.lifl.eclipse.plugin.project.OpenCCM.utils; 28 29 import java.util.HashMap ; 30 31 import org.eclipse.core.runtime.CoreException; 32 import org.eclipse.core.runtime.IProgressMonitor; 33 import org.eclipse.core.runtime.Path; 34 import org.eclipse.core.runtime.SubProgressMonitor; 35 import org.eclipse.jdt.core.JavaCore; 36 import org.omg.lifl.eclipse.plugin.project.OpenCCM.ProjectCreationWizardPage; 37 38 45 public class CPManager { 46 47 51 public static void setEclipseCP( 52 ProjectCreationWizardPage page, 53 IProgressMonitor monitor) { 54 try { 55 String varSeparator = "__"; 57 HashMap ORBJarConfig = ORBconfigJar(); 58 59 String ORBName = 60 createVarName(page.getOpenccmConfigChooser().get_ORBName()); 61 62 String jarName[] = (String []) ORBJarConfig.get(ORBName); 63 for (int i = 0; i < jarName.length; i++) { 64 JavaCore 65 .setClasspathVariable(ORBName + varSeparator + jarName[i], 66 new Path( 68 page 69 .getOpenccmConfigChooser() 70 .get_ORBpreference() 71 .get_Name() 72 + "/lib/" 73 + jarName[i] 74 + ".jar"), 75 new SubProgressMonitor(monitor, 1)); 76 77 } 78 79 90 91 } catch (CoreException e1) { 92 e1.printStackTrace(); 94 } 95 } 96 97 100 private static HashMap ORBconfigJar() { 101 HashMap result = new HashMap (); 102 String ORBs[] = 103 { createVarName("ORBacus-4.1"), createVarName("OpenORB-1.3.0")}; 104 String jarNameORB[][] = { { "OB", "OBNaming" }, { 105 "openorb-1.3.0", "openorb_tools-1.3.0"} 106 }; 107 108 for (int i = 0; i < ORBs.length; i++) { 109 result.put(ORBs[i], jarNameORB[i]); 110 } 111 112 return result; 113 } 114 115 119 private static String createVarName(String string) { 120 char separator = '_'; 121 char separators[] = { '-', '.' }; 122 123 String result = string; 124 for (int i = 0; i < separators.length; i++) { 125 result = result.replace(separators[i], separator); 126 } 127 return result; 128 } 129 } | Popular Tags |