List of usage examples for org.eclipse.jdt.core JavaCore USER_LIBRARY_CONTAINER_ID
String USER_LIBRARY_CONTAINER_ID
To view the source code for org.eclipse.jdt.core JavaCore USER_LIBRARY_CONTAINER_ID.
Click Source Link
From source file:at.bestsolution.javafx.ide.jdt.internal.jdt.CPUserLibraryElement.java
License:Open Source License
public IPath getPath() { return new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(fName); }
From source file:com.cisco.surf.jenkow.ide.config.UserLibConfigurator.java
License:Open Source License
public void configure(final String name, final File jarFileOrDir) throws CoreException { ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer(JavaCore.USER_LIBRARY_CONTAINER_ID); IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID); initializer.requestClasspathContainerUpdate(containerPath.append(name), null, getClasspathContainer(name, jarFileOrDir)); }
From source file:com.cisco.surf.jenkow.ide.config.UserLibConfigurator.java
License:Open Source License
private IClasspathContainer createClasspathContainer(final String name, final IClasspathEntry[] entries) { return new IClasspathContainer() { public IPath getPath() { return new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(name); }/*from ww w .j a v a 2s .c o m*/ public int getKind() { return K_APPLICATION; } public String getDescription() { return name; } public IClasspathEntry[] getClasspathEntries() { return entries; } }; }
From source file:net.rim.ejde.internal.util.ImportUtils.java
License:Open Source License
static protected IJavaProject internalCreateJavaProject(Project legacyProject, IProject project, int importType, String userLib, IPath REPath, IProgressMonitor monitor) throws CoreException { try {//from www .j a v a 2 s . c o m if (legacyProject == null) throw new IllegalArgumentException( "Can't create Eclipse Java Project from undefind legacy project!"); _log.debug("Create IJavaProject [" + legacyProject.getDisplayName() + "]"); monitor.beginTask("Importing project " + legacyProject.getDisplayName(), 10); monitor.worked(1); if (project == null) return null; // create a IJavaProject IJavaProject eclipseJavaProject = JavaCore.create(project); // set project options initializeProjectOptions(eclipseJavaProject); monitor.worked(2); // get source folders, e.g. src and res IPath[] defaultSources = getCustomSourceFolders(legacyProject); // create classpath entries for source folders IClasspathEntry[] sourceFolderEntries = createSourceFolders(project, defaultSources); IClasspathEntry[] importedLibraries = resolveProjectImports(legacyProject, project); String[] dependencies = getDependsOnProjectNames(legacyProject); IClasspathEntry[] dependentProjects = resolveDependentProjects(dependencies); IClasspathEntry[] jreEntries = getREClasspathEntries(REPath); List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>(); addEntryToList(classpathEntries, sourceFolderEntries); addEntryToList(classpathEntries, importedLibraries); addEntryToList(classpathEntries, dependentProjects); addEntryToList(classpathEntries, jreEntries); classpathEntries = applyExclusionPatterns(project, legacyProject, classpathEntries); // add workspace imports as a user library if (!StringUtils.isBlank(userLib)) { UserLibrary library = JavaModelManager.getUserLibraryManager().getUserLibrary(userLib); if (null != library) { IPath path = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(userLib); IClasspathEntry userLibEntry = JavaCore.newContainerEntry(path); if (!classpathEntries.contains(userLibEntry)) { classpathEntries.add(userLibEntry); } } } if (!eclipseJavaProject.isOpen()) { try { eclipseJavaProject.open(new NullProgressMonitor()); } catch (JavaModelException e) { _log.error(e.getMessage()); throw new CoreException(StatusFactory.createErrorStatus(e.getMessage())); } } setRawClassPath(eclipseJavaProject, classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()])); monitor.worked(2); // link or copy files if (importType == LegacyImportHelper.COPY_IMPORT) { copySourceFiles(legacyProject, eclipseJavaProject.getProject()); int AEPNumber = legacyProject.getNumEntries(); // Copy AEP source files as well. for (int i = 0; i < AEPNumber; i++) { copySourceFiles(legacyProject.getEntry(i), eclipseJavaProject.getProject()); } } else { /** * String: the package id, the container key. Set<File>: the files belonging to the package * */ ResourcesBuffer resourcesBuffer; resourcesBuffer = createProjectResourcesBuffer(legacyProject); createBulkLinks(eclipseJavaProject, resourcesBuffer, legacyProject); int AEPNumber = legacyProject.getNumEntries(); // link AEP source files as well. for (int i = 0; i < AEPNumber; i++) { resourcesBuffer = createProjectResourcesBuffer(legacyProject.getEntry(i)); createBulkLinks(eclipseJavaProject, resourcesBuffer, legacyProject.getEntry(i)); } } monitor.worked(6); return eclipseJavaProject; } finally { monitor.done(); } }
From source file:net.rim.ejde.internal.util.WorkspaceDependencyUtils.java
License:Open Source License
static public void addUserLibraryToProject(String userLibrary, IJavaProject iJavaProject, IProgressMonitor monitor) {/*w w w .j a v a 2 s. c o m*/ UserLibrary library = JavaModelManager.getUserLibraryManager().getUserLibrary(userLibrary); if (null != library && null != iJavaProject) { UserLibraryClasspathContainer container = new UserLibraryClasspathContainer(userLibrary); IPath path = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(userLibrary); try { JavaCore.setClasspathContainer(path, new IJavaProject[] { iJavaProject }, new IClasspathContainer[] { container }, null == monitor ? new NullProgressMonitor() : monitor instanceof SubProgressMonitor ? monitor : new SubProgressMonitor(monitor, 1)); } catch (Throwable e) { _log.error(e.getMessage(), e); } finally { monitor.done(); } } }
From source file:net.rim.ejde.internal.util.WorkspaceDependencyUtils.java
License:Open Source License
static public void addUserLibraryToProjects(String userLibrary, IJavaProject[] iJavaProjects, IProgressMonitor monitor) {/*from w ww. j a v a2 s . c o m*/ UserLibrary library = JavaModelManager.getUserLibraryManager().getUserLibrary(userLibrary); if (null != library && null != iJavaProjects && 0 < iJavaProjects.length) { UserLibraryClasspathContainer[] containers = new UserLibraryClasspathContainer[iJavaProjects.length]; IPath path; path = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(userLibrary); for (int i = 0; i < iJavaProjects.length; i++) containers[i] = new UserLibraryClasspathContainer(userLibrary); try { JavaCore.setClasspathContainer(path, iJavaProjects, containers, null == monitor ? new NullProgressMonitor() : monitor instanceof SubProgressMonitor ? monitor : new SubProgressMonitor(monitor, 1)); } catch (Throwable e) { _log.error(e.getMessage(), e); } finally { monitor.done(); } } }
From source file:org.eclipse.ant.internal.ui.datatransfer.EclipseClasspath.java
License:Open Source License
/** * Initialize object with runtime classpath of given launch configuration. * /* w ww . ja v a2 s. c om*/ * @param project * project that contains given launch configuration conf * @param conf * launch configuration * @param bootstrap * if true only bootstrap entries are added, if false only non-bootstrap entries are added */ public EclipseClasspath(IJavaProject project, ILaunchConfiguration conf, boolean bootstrap) throws CoreException { this.project = project; // convert IRuntimeClasspathEntry to IClasspathEntry IRuntimeClasspathEntry[] runtimeEntries; // see AbstractJavaLaunchConfigurationDelegate runtimeEntries = JavaRuntime.computeUnresolvedRuntimeClasspath(conf); List<IClasspathEntry> classpathEntries = new ArrayList<>(runtimeEntries.length); for (int i = 0; i < runtimeEntries.length; i++) { IRuntimeClasspathEntry entry = runtimeEntries[i]; if (bootstrap && (entry.getClasspathProperty() == IRuntimeClasspathEntry.BOOTSTRAP_CLASSES) || !bootstrap && (entry.getClasspathProperty() != IRuntimeClasspathEntry.BOOTSTRAP_CLASSES)) { // NOTE: See AbstractJavaLaunchConfigurationDelegate.getBootpathExt() // for an alternate bootclasspath detection if (entry.getClass().getName().equals("org.eclipse.jdt.internal.launching.VariableClasspathEntry")) //$NON-NLS-1$ { IClasspathEntry e = convertVariableClasspathEntry(entry); if (e != null) { classpathEntries.add(e); } } else if (entry.getClass().getName() .equals("org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry")) //$NON-NLS-1$ { IClasspathEntry e = JavaCore.newProjectEntry(entry.getPath()); classpathEntries.add(e); } else if (entry.getClasspathEntry() != null) { classpathEntries.add(entry.getClasspathEntry()); } } else if (bootstrap && entry.toString().startsWith(JavaRuntime.JRE_CONTAINER)) { classpathEntries.add(entry.getClasspathEntry()); } else if (bootstrap && entry.toString().startsWith(JavaCore.USER_LIBRARY_CONTAINER_ID)) { classpathEntries.add(entry.getClasspathEntry()); } } IClasspathEntry[] entries = classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]); handle(entries); }
From source file:org.eclipse.ant.internal.ui.datatransfer.EclipseClasspath.java
License:Open Source License
private void handleLibraries(IClasspathEntry entry) throws JavaModelException { if (entry.getContentKind() == IPackageFragmentRoot.K_SOURCE && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { // found library IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project); if (container == null) { // jar missing (project not compile clean) return; }//w ww . ja v a2 s . c o m String jar = entry.getPath().toString(); String refName; if (jar.startsWith(JavaRuntime.JRE_CONTAINER)) { // JRE System Library refName = "${jre.container}"; //$NON-NLS-1$ } else if (jar.startsWith(JavaCore.USER_LIBRARY_CONTAINER_ID)) { // User Library String libraryName = container.getDescription(); refName = "${" + libraryName + ".userclasspath}"; //$NON-NLS-1$ //$NON-NLS-2$ if (container.getKind() == IClasspathContainer.K_SYSTEM) { refName = "${" + libraryName + ".bootclasspath}"; //$NON-NLS-1$ //$NON-NLS-2$ } } else { // Library dependencies: e.g. Plug-in Dependencies String libraryName = container.getDescription(); refName = "${" + libraryName + ".libraryclasspath}"; //$NON-NLS-1$ //$NON-NLS-2$ } userLibraryCache.put(refName, container); srcDirs.add(refName); classDirs.add(refName); rawClassPathEntries.add(refName); rawClassPathEntriesAbsolute.add(refName); inclusionLists.add(new ArrayList<String>()); exclusionLists.add(new ArrayList<String>()); } }
From source file:org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperation.java
License:Open Source License
/** * Constructs a classpath entry for the provided user library. Subclasses can override. * /*w ww . j av a 2 s .co m*/ * @param config the user library provider install operation config * @param libraryName the name of a JDT user library * @return the classpath entry for the provided user library */ protected IClasspathEntry createClasspathEntry(final UserLibraryProviderInstallOperationConfig config, final String libraryName) { final IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(libraryName); return JavaCore.newContainerEntry(containerPath); }
From source file:org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig.java
License:Open Source License
/** * Resets this operation config to its initial state (prior to any user changes). *//*from www. j av a 2s . co m*/ @Override public synchronized void reset() { final IProject project = getFacetedProject().getProject(); final IProjectFacet f = getProjectFacet(); final IProjectFacetVersion fv = getProjectFacetVersion(); List<String> newLibraryNames = null; if (project != null) { final ILibraryProvider currentProvider = LibraryProviderFramework.getCurrentProvider(project, f); if (currentProvider == getLibraryProvider()) { final List<IClasspathEntry> entries; try { entries = ClasspathUtil.getClasspathEntries(project, f); } catch (CoreException e) { throw new RuntimeException(e); } final List<String> libraryNamesList = new ArrayList<String>(); for (IClasspathEntry cpe : entries) { if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { final IPath path = cpe.getPath(); if (path.segmentCount() >= 2 && path.segment(0).equals(JavaCore.USER_LIBRARY_CONTAINER_ID)) { libraryNamesList.add(path.segment(1)); } } } newLibraryNames = libraryNamesList; } } if (newLibraryNames == null) { newLibraryNames = new ArrayList<String>(); try { Preferences prefs = FacetedProjectFramework.getPreferences(f); if (prefs.nodeExists(PREFS_LAST_USED_LIBRARIES)) { prefs = prefs.node(PREFS_LAST_USED_LIBRARIES); if (prefs.nodeExists(fv.getVersionString())) { prefs = prefs.node(fv.getVersionString()); for (String libraryName : prefs.childrenNames()) { newLibraryNames.add(libraryName); } } } } catch (BackingStoreException e) { log(e); } } setLibraryNames(newLibraryNames); }