Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IClasspathEntry


    if (libs != null) {         
      BeanMapPreferencesStore<IPath, LibraryClasspathEntryInformation> store = WGADesignerPlugin.getDefault().getLibraryClasspathEntryInformationStore();
      store.load();
      Map<IPath, LibraryClasspathEntryInformation> infos = store.getBeans();
      for( File lib: libs ) {
        IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(lib.getAbsolutePath()), null, null);
        IPath srcPath = jarToProjectSource.get(lib.getName());
        if (srcPath != null) {
          if (!infos.containsKey(new Path(lib.getAbsolutePath()))) {
            LibraryClasspathEntryInformation info = new LibraryClasspathEntryInformation();
            info.setSourcePath(srcPath);
            store.getBeans().put(entry.getPath(), info);
          }
        }
          entryList.add(entry);
      }
      store.flush();
View Full Code Here


            if (editor == null) {
                return;
            }
            IPackageFragmentRoot root = editor.getPackageFragmentRoot(editor.getClassFile());
            try {
                IClasspathEntry entry = root.getRawClasspathEntry();
                IPath containerPath = null;
                IJavaProject javaProject = root.getJavaProject();
                if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                    containerPath = entry.getPath();
                    IClasspathContainer container = JavaCore
                        .getClasspathContainer(containerPath, javaProject);
                    if(!isSourceAttachmentPossible(containerPath, javaProject)){
                        editor.setSourceAttachmentPossible(false);
                        attachAction.setEnabled(false);
                        BytecodeOutlinePlugin
                            .error("Unable to configure source attachment:\n"
                                + "classpath entry '" + containerPath +
                                        "'\nis either read-only "
                                + "or source attachment is not supported...", null);
                        return;
                    }
                    entry = JavaModelUtil.findEntryInContainer(container, root
                        .getPath());
                }

                Shell shell = Display.getDefault().getActiveShell();
                IClasspathEntry cpe = BuildPathDialogAccess
                    .configureSourceAttachment(shell, entry);
                if (cpe == null) {
                    return;
                }
                String[] changedAttributes = {CPListElement.SOURCEATTACHMENT};
                BuildPathSupport.modifyClasspathEntry(
                    shell, cpe, changedAttributes, javaProject, containerPath,
                    cpe.getReferencingEntry() != null,
                    new NullProgressMonitor());
            } catch (CoreException e) {
                BytecodeOutlinePlugin.error(
                    "Unable to configure source attachment", e);
            }
View Full Code Here

        if (resource == null) {
            return dir;
        }
        // resolve multiple output locations here
        if (project.exists() && project.getProject().isOpen()) {
            IClasspathEntry entries[] = project.getRawClasspath();
            for (int i = 0; i < entries.length; i++) {
                IClasspathEntry classpathEntry = entries[i];
                if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                    IPath outputPath = classpathEntry.getOutputLocation();
                    if (outputPath != null
                        && classpathEntry.getPath().isPrefixOf(
                            resource.getFullPath())) {
                        path = outputPath;
                        break;
                    }
                }
View Full Code Here

        boolean isRoot = false;
        if (project == null || pack == null || !(pack instanceof IContainer)) {
            return isRoot;
        }
        IPackageFragmentRoot root = project.getPackageFragmentRoot(pack);
        IClasspathEntry clPathEntry = null;
        if (root != null) {
            clPathEntry = root.getRawClasspathEntry();
        }
        isRoot = clPathEntry != null;
        return isRoot;
View Full Code Here

            // BytecodeOutlinePlugin.log(e, IStatus.ERROR);
        }
        if (paths != null) {
            IPath projectPath = javaProject.getProject().getLocation();
            for (int i = 0; i < paths.length; ++i) {
                IClasspathEntry cpEntry = paths[i];
                IPath p = null;
                if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                    // filter out source container - there are unused for class
                    // search - add bytecode output location instead
                    p = cpEntry.getOutputLocation();
                    if (p == null) {
                        // default output used:
                        p = defaultOutputLocation;
                    }
                } else if (cpEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
                    String projName = cpEntry.getPath().toPortableString()
                        .substring(1);
                    IProject proj = workspaceRoot.getProject(projName);
                    IJavaProject projj = JavaCore.create(proj);
                    getClassURLs(projj, urls);
                    continue;
                } else {
                    p = cpEntry.getPath();
                }

                if (p == null) {
                    continue;
                }
View Full Code Here

        // replace JCL_LIB with JCL15_LIB, and JCL_SRC with JCL15_SRC
        IClasspathEntry[] classpath = javaProject.getRawClasspath();
        IPath jclLib = new Path(jclLibString);
        for (int i = 0, length = classpath.length; i < length; i++) {
            IClasspathEntry entry = classpath[i];
            if (entry.getPath().equals(jclLib)) {
                classpath[i] = JavaCore.newVariableEntry(
                    new Path(newJclLibString), null, entry
                        .getSourceAttachmentRootPath(), entry.getAccessRules(),
                    new IClasspathAttribute[0], entry.isExported());
                break;
            }
        }
        javaProject.setRawClasspath(classpath, null);
    }
View Full Code Here

        try {
            IClasspathEntry[] paths = project.getResolvedClasspath(true);
            if (paths != null) {
               
                for ( int i = 0; i < paths.length; i++ ) {
                    IClasspathEntry path = paths[i];
                    if (path.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                        URL url = getRawLocationURL(path.getPath());
                        pathElements.add(url);
                    }
                }
            }
            IPath location = getProjectLocation(project.getProject());
View Full Code Here

        List<IClasspathEntry> result = new ArrayList<IClasspathEntry>(entries.length + 2);
        result.addAll(Arrays.asList(entries));

        // Add the Bnd classpath container entry
        IPath bndContainerPath = BndtoolsConstants.BND_CLASSPATH_ID;
        IClasspathEntry bndContainerEntry = JavaCore.newContainerEntry(bndContainerPath, false);
        result.add(bndContainerEntry);

        return result.toArray(new IClasspathEntry[result.size()]);
    }
View Full Code Here

                calculateWorkspaceBundleAccessRules(projectAccessRules, c);
            }
        }

        for (Container c : containers) {
            IClasspathEntry cpe;

            if (c.getError() == null) {
                File file = c.getFile();
                assert file.isAbsolute();
View Full Code Here

        IClasspathEntry[] entries = project.getRawClasspath();
        List<IClasspathEntry> queue = new ArrayList<IClasspathEntry>(entries.length);
        queue.addAll(Arrays.asList(entries));

        while (!queue.isEmpty()) {
            IClasspathEntry entry = queue.remove(0);

            if (exports && !entry.isExported())
                continue;

            IPath path = entry.getPath();

            switch (entry.getEntryKind()) {
            case IClasspathEntry.CPE_LIBRARY :
                files.add(getFileForPath(path));
                break;
            case IClasspathEntry.CPE_VARIABLE :
                IPath resolvedPath = JavaCore.getResolvedVariablePath(path);
                files.add(getFileForPath(resolvedPath));
                break;
            case IClasspathEntry.CPE_SOURCE :
                IPath outputLocation = entry.getOutputLocation();
                if (exports && outputLocation != null)
                    files.add(getFileForPath(outputLocation));
                break;
            case IClasspathEntry.CPE_CONTAINER :
                IClasspathContainer container = JavaCore.getClasspathContainer(path, project);
                boolean allow = true;
                for (Predicate<IClasspathContainer> filter : containerFilters)
                    if (!filter.select(container))
                        allow = false;
                if (allow)
                    queue.addAll(Arrays.asList(container.getClasspathEntries()));
                break;
            case IClasspathEntry.CPE_PROJECT :
                IProject targetProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());
                IJavaProject targetJavaProject = JavaCore.create(targetProject);
                accumulateClasspath(files, targetJavaProject, true, containerFilters);
                break;
            default :
                logger.logError("Unhandled IPath entryKind of " + entry.getEntryKind(), null);
                break;
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IClasspathEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.