diff options
author | Jose <jose@zeroc.com> | 2011-12-10 01:57:19 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2011-12-10 01:57:19 +0100 |
commit | 42e31f18dc2f34c6b0c427ca0a976ac795349864 (patch) | |
tree | 91f81872e55f06c5d6b859039e3c2a633c70c684 /eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java | |
parent | ICE-4705 voip glacier2 configuration (diff) | |
download | ice-42e31f18dc2f34c6b0c427ca0a976ac795349864.tar.bz2 ice-42e31f18dc2f34c6b0c427ca0a976ac795349864.tar.xz ice-42e31f18dc2f34c6b0c427ca0a976ac795349864.zip |
Eclipse plug-in updates for release 3.4.2.20111024
Diffstat (limited to 'eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java')
-rw-r--r-- | eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java new file mode 100644 index 00000000000..7d16cb2983c --- /dev/null +++ b/eclipse/java/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/internal/IceClasspathContainerIntializer.java @@ -0,0 +1,95 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This plug-in is provided to you under the terms and conditions +// of the Eclipse Public License Version 1.0 ("EPL"). A copy of +// the EPL is available at http://www.eclipse.org/legal/epl-v10.html. +// +// ********************************************************************** + +package com.zeroc.slice2javaplugin.internal; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.ClasspathContainerInitializer; +import org.eclipse.jdt.core.IAccessRule; +import org.eclipse.jdt.core.IClasspathAttribute; +import org.eclipse.jdt.core.IClasspathContainer; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; + +public class IceClasspathContainerIntializer extends ClasspathContainerInitializer +{ + private final static String CONTAINER_ID = "com.zeroc.Slice2JavaPlugin.ICE_FRAMEWORK"; + + @Override + public void initialize(IPath containerPath, IJavaProject project) + throws CoreException + { + if(containerPath.toString().equals(CONTAINER_ID)) + { + Configuration c = new Configuration(project.getProject()); + configure(c, project, containerPath); + } + } + + public static IClasspathEntry getContainerEntry() + { + return JavaCore.newContainerEntry(new Path(CONTAINER_ID)); + } + + public static void reinitialize(IProject project, Configuration c) + throws CoreException + { + IJavaProject javaProject = JavaCore.create(project); + IPath containerPath = new Path(CONTAINER_ID); + + configure(c, javaProject, containerPath); + } + + private static void configure(Configuration c, IJavaProject javaProject, IPath containerPath) + throws JavaModelException + { + if(c.getAddJars()) + { + Path dir = new Path(c.getJarDir()); + List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); + for(String jar : c.getJars()) + { + IPath path = dir.append(new Path(jar)); + IClasspathEntry classpathEntry = JavaCore.newLibraryEntry(path, null, null, new IAccessRule[0], new IClasspathAttribute[0], false); + entries.add(classpathEntry); + } + + IClasspathContainer container = new IceClasspathContainer(entries.toArray(new IClasspathEntry[0]), containerPath); + JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { javaProject }, + new IClasspathContainer[] { container }, new NullProgressMonitor()); + } + } + + public static void updateProjects(String value, List<IJavaProject> projects) + { + for(IJavaProject p : projects) + { + IPath containerPath = new Path(CONTAINER_ID); + Configuration c = new Configuration(p.getProject()); + try + { + configure(c, p, containerPath); + } + catch(JavaModelException e) + { + e.printStackTrace(); + } + } + } +} |