KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > project > OpenCCM > utils > CPManager


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): offroy ________________________.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.omg.lifl.eclipse.plugin.project.OpenCCM.utils;
28
29 import java.util.HashMap JavaDoc;
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 /**
39  * This class ...
40  *
41  * @author offroy@lifl.fr
42  *
43  * @version 0.1
44  */

45 public class CPManager {
46
47     /**
48      * @param page
49      * @param monitor
50      */

51     public static void setEclipseCP(
52         ProjectCreationWizardPage page,
53         IProgressMonitor monitor) {
54         try {
55             // TODO make ORBacus independent
56
String JavaDoc varSeparator = "__";
57             HashMap JavaDoc ORBJarConfig = ORBconfigJar();
58
59             String JavaDoc ORBName =
60                 createVarName(page.getOpenccmConfigChooser().get_ORBName());
61
62             String JavaDoc jarName[] = (String JavaDoc[]) ORBJarConfig.get(ORBName);
63             for (int i = 0; i < jarName.length; i++) {
64                 JavaCore
65                     .setClasspathVariable(ORBName + varSeparator + jarName[i],
66                 // the name of the new Variable
67
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             // show all variable defined in the workbench
80
/*String varNames[] = JavaCore.getClasspathVariableNames();
81             for (int i = 0; i < varNames.length; i++) {
82                 System.out.println(
83                     "var : "
84                         + varNames[i]
85                         + " = "
86                         + JavaCore
87                             .getClasspathVariable(varNames[i])
88                             .toOSString());
89             }*/

90
91         } catch (CoreException e1) {
92             // TODO Auto-generated catch block
93
e1.printStackTrace();
94         }
95     }
96     
97     /**
98      * @return
99      */

100     private static HashMap JavaDoc ORBconfigJar() {
101         HashMap JavaDoc result = new HashMap JavaDoc();
102         String JavaDoc ORBs[] =
103             { createVarName("ORBacus-4.1"), createVarName("OpenORB-1.3.0")};
104         String JavaDoc 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     /**
116      * @param string
117      * @return
118      */

119     private static String JavaDoc createVarName(String JavaDoc string) {
120         char separator = '_';
121         char separators[] = { '-', '.' };
122
123         String JavaDoc 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