Examples of IJavaProject


Examples of org.eclipse.jdt.core.IJavaProject

        String dir = ""; //$NON-NLS-1$
        if (javaElement == null) {
            return dir;
        }

        IJavaProject project = javaElement.getJavaProject();

        if (project == null) {
            return dir;
        }
        // default bytecode location
        IPath path = project.getOutputLocation();

        IResource resource = javaElement.getUnderlyingResource();
        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;
                    }
                }
            }
        }

        if (path == null) {
            // check the default location if not already included
            IPath def = project.getOutputLocation();
            if (def != null && def.isPrefixOf(resource.getFullPath())){
                path = def;
            }
        }

        if(path == null){
            return dir;
        }

        IWorkspace workspace = ResourcesPlugin.getWorkspace();

        if (!project.getPath().equals(path)) {
            IFolder outputFolder = workspace.getRoot().getFolder(path);
            if (outputFolder != null) {
                // linked resources will be resolved here!
                IPath rawPath = outputFolder.getRawLocation();
                if (rawPath != null) {
                    path = rawPath;
                }
            }
        } else {
            path = project.getProject().getLocation();
        }

        // here we should resolve path variables,
        // probably existing at first place of path
        IPathVariableManager pathManager = workspace.getPathVariableManager();
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

        }
        return null;
    }

    private static boolean isOnClasspath(IJavaElement javaElement) {
        IJavaProject project = javaElement.getJavaProject();
        if (project != null) {
            boolean result = project.isOnClasspath(javaElement);
            return result;
        }
        return false;
    }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

    }

    public static ClassLoader getClassLoader(IJavaElement type) {
        ClassLoader cl;

        IJavaProject javaProject = type.getJavaProject();
        List urls = new ArrayList();

        getClassURLs(javaProject, urls);

        if (urls.isEmpty()) {
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

                    }
                } 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();
                }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

     * an external jar, or a resource internal to the workspace
     */
    protected IPackageFragmentRoot getPackageFragmentRoot(String rootPath)
        throws JavaModelException {

        IJavaProject project = getJavaProject();
        if (project == null) {
            return null;
        }
        IPath path = new Path(rootPath);
        if (path.isAbsolute()) {
            IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()
                .getRoot();
            IResource resource = workspaceRoot.findMember(path);
            IPackageFragmentRoot root1;
            if (resource == null) {
                // external jar
                root1 = project.getPackageFragmentRoot(rootPath);
            } else {
                // resource in the workspace
                root1 = project.getPackageFragmentRoot(resource);
            }
            return root1;
        }
        IPackageFragmentRoot[] roots = project.getPackageFragmentRoots();
        if (roots == null || roots.length == 0) {
            return null;
        }
        for (int i = 0; i < roots.length; i++) {
            IPackageFragmentRoot root1 = roots[i];
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

                        output.create(true, true, null);
                    }
                }

                // set classpath and output location
                IJavaProject javaProject = JavaCore.create(project);
                javaProject.setRawClasspath(entries, projectPath
                    .append(outputPath), null);

                // set compliance level options
                if ("1.5".equals(compliance)) {
                    Map options = new HashMap();
                    options.put(
                        CompilerOptions.OPTION_Compliance,
                        CompilerOptions.VERSION_1_5);
                    options.put(
                        CompilerOptions.OPTION_Source,
                        CompilerOptions.VERSION_1_5);
                    options.put(
                        CompilerOptions.OPTION_TargetPlatform,
                        CompilerOptions.VERSION_1_5);
                    javaProject.setOptions(options);
                }

                result[0] = javaProject;
            }
        };
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

        if(!"1.5".equals(compliance)){
            sdkLib = "JCL_LIB";
        }

        // create project
        IJavaProject javaProject = createJavaProject(
            projectName, new String[]{"src"}, new String[] {sdkLib}, "bin", compliance);

        setUpProjectCompliance(javaProject, compliance);
        return javaProject;
    }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

                        && sourceElement instanceof IAdaptable) {
                    sourceElement = ((IAdaptable) sourceElement)
                            .getAdapter(IJavaElement.class);
                }
            }
            IJavaProject project = null;
            if (sourceElement instanceof IJavaElement) {
                project = ((IJavaElement) sourceElement).getJavaProject();
            } else if (sourceElement instanceof IResource) {
                IJavaProject resourceProject = JavaCore
                        .create(((IResource) sourceElement).getProject());
                if (resourceProject.exists()) {
                    project = resourceProject;
                }
            }
            if (project == null) {
                return null;
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

    }

    private void createDroolsProject() {
        try {
            newProject = createNewProject();
            IJavaProject project = JavaCore.create(newProject);
            createOutputLocation(project);
            addJavaBuilder(project);
            setClasspath(project);
            createInitialContent(project);
            newProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

            for ( int i = 0; i < names.length; i++ ) {
                String projectName = names[i];
                IProject reqProject = project.getProject().getWorkspace()
                    .getRoot().getProject(projectName);
                if (reqProject != null) {
                    IJavaProject reqJavaProject = JavaCore.create(reqProject);
                    pathElements.addAll(getProjectClassPathURLs(reqJavaProject));
                }
            }
        } catch (JavaModelException e) {
            DroolsIDEPlugin.log(e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.